From ce6ba491a4886e2d0b9e96052f6fab4b8dc968a8 Mon Sep 17 00:00:00 2001 From: Alexander Patrikalakis Date: Thu, 7 Apr 2016 18:02:36 +0900 Subject: [PATCH] fix fulgora readBatchSize number overflow fault --- .../titan/graphdb/olap/computer/FulgoraGraphComputer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/olap/computer/FulgoraGraphComputer.java b/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/olap/computer/FulgoraGraphComputer.java index d139c9907e..c1a55af542 100644 --- a/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/olap/computer/FulgoraGraphComputer.java +++ b/titan-core/src/main/java/com/thinkaurelius/titan/graphdb/olap/computer/FulgoraGraphComputer.java @@ -52,6 +52,7 @@ public class FulgoraGraphComputer implements TitanGraphComputer { public static final Set NON_PERSISTING_KEYS = ImmutableSet.of(TraversalSideEffects.SIDE_EFFECTS, TraversalVertexProgram.HALTED_TRAVERSERS); + public static final int WRITE_BATCH_SIZE_LIMIT = Math.floorDiv(Integer.MAX_VALUE, 10); private VertexProgram vertexProgram; private final Set mapReduces = new HashSet<>(); @@ -63,8 +64,8 @@ public class FulgoraGraphComputer implements TitanGraphComputer { private boolean executed = false; private int numThreads = 1;//Math.max(1,Runtime.getRuntime().availableProcessors()); - private int readBatchSize = 10000; - private int writeBatchSize; + private final int readBatchSize; + private final int writeBatchSize; private ResultGraph resultGraphMode = null; private Persist persistMode = null; @@ -76,6 +77,9 @@ public class FulgoraGraphComputer implements TitanGraphComputer { public FulgoraGraphComputer(final StandardTitanGraph graph, final Configuration configuration) { this.graph = graph; this.writeBatchSize = configuration.get(GraphDatabaseConfiguration.BUFFER_SIZE); + if(this.writeBatchSize > WRITE_BATCH_SIZE_LIMIT) { + throw new IllegalArgumentException("Set storage.buffer-size less than Int.MAX_VALUE/10. Otherwise Fulgora readBatchSize will overflow."); + } this.readBatchSize = this.writeBatchSize * 10; this.name = "compute" + computerCounter.incrementAndGet(); }