Projects >> blueprints >>62c686b70ebbdb54895f95714bffcb49bac2a22d

Chunk
Conflicting content
 * 

* BatchGraph wraps {@link TransactionalGraph}. To wrap arbitrary graphs, use {@link #wrap(com.tinkerpop.blueprints.Graph)} * which will additionally wrap non-transactional graphs using {@link WritethroughGraph}. <<<<<<< HEAD * * BatchGraph can also automatically set the provided element ids as properties on the respective element. Use * {@link #setVertexIDKey(String)} and {@link #setEdgeIDKey(String)} to set the keys for the vertex and edge properties * respectively. This allows to make the loaded graph compatible for later wrapping with {@link IdGraph}. ======= *

* BatchGraph can also automatically set the provided element ids as properties on the respective element. Use * {@link #setVertexIdKey} and {@link #setEdgeIdKey} to set the keys for the vertex and edge properties * respectively. For wrapped graphs which ignore supplied ids, these default to IdGraph.ID. >>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a * * @author Matthias Broecheler (http://www.matthiasb.com) */

Solution content
 * 

* BatchGraph wraps {@link TransactionalGraph}. To wrap arbitrary graphs, use {@link #wrap(com.tinkerpop.blueprints.Graph)} * which will additionally wrap non-transactional graphs using {@link WritethroughGraph}. *

* BatchGraph can also automatically set the provided element ids as properties on the respective element. Use * {@link #setVertexIdKey(String)} and {@link #setEdgeIdKey(String)} to set the keys for the vertex and edge properties * respectively. This allows to make the loaded graph compatible for later wrapping with {@link IdGraph}. * * @author Matthias Broecheler (http://www.matthiasb.com) */

File
BatchGraph.java
Developer's decision
Manual
Kind of conflict
Comment
Chunk
Conflicting content
        this.graph = graph;
        this.bufferSize = bufferSize;

<<<<<<< HEAD
        this.ignoreSuppliedIDs = graph.getFeatures().ignoresSuppliedIds;

        vertexIDKey = null;
        edgeIDKey = null;

=======
        this.ignoreSuppliedIds = graph.getFeatures().ignoresSuppliedIds;
        if (!ignoreSuppliedIds) {
            vertexIdKey = null;
            edgeIdKey = null;
        } else {
            vertexIdKey = IdGraph.ID;
            edgeIdKey = IdGraph.ID;
        }
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a

        cache = type.getVertexCache(this.graph);
Solution content
        this.graph = graph;
        this.bufferSize = bufferSize;

        this.ignoreSuppliedIds = graph.getFeatures().ignoresSuppliedIds;

        vertexIdKey = null;
        edgeIdKey = null;

        cache = type.getVertexCache(this.graph);
File
BatchGraph.java
Developer's decision
Combination
Kind of conflict
Attribute
If statement
Method invocation
Chunk
Conflicting content
        loadingTest(5000, 100, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());
        loadingTest(200000, 10000, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());

<<<<<<< HEAD
        assignKeys=true;
        loadingTest(5000,100, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        loadingTest(50000,10000, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        assignKeys=false;

        ignoreIDs=true;
        loadingTest(5000,100, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        loadingTest(50000,10000, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        ignoreIDs=false;
=======
        assignKeys = true;
        loadingTest(5000, 100, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());
        loadingTest(50000, 10000, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());
        assignKeys = false;
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
    }

    public void testObjectIdLoading() {
Solution content
        loadingTest(5000, 100, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());
        loadingTest(200000, 10000, BatchGraph.IDType.NUMBER, new NumberLoadingFactory());

        assignKeys=true;
        loadingTest(5000,100, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        loadingTest(50000,10000, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        assignKeys=false;

        ignoreIDs=true;
        loadingTest(5000,100, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        loadingTest(50000,10000, BatchGraph.IDType.NUMBER,new NumberLoadingFactory());
        ignoreIDs=false;
    }

    public void testObjectIdLoading() {
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
    public void loadingTest(int total, int bufferSize, BatchGraph.IDType type, LoadingFactory ids) {
        final VertexEdgeCounter counter = new VertexEdgeCounter();
<<<<<<< HEAD
        MockTransactionalGraph tgraph = null;
        if (ignoreIDs) {
            tgraph = new MockTransactionalGraph(new IgnoreIdTinkerGraph());
        } else {
            tgraph = new MockTransactionalGraph(new TinkerGraph());
        }

        BLGraph graph = new BLGraph(tgraph,counter,ids);
        BatchGraph loader = new BatchGraph(graph,type,bufferSize);
=======
        BLGraph graph = new BLGraph(counter, ids);
        BatchGraph loader = new BatchGraph(graph, type, bufferSize);
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
        if (assignKeys) {
            loader.setVertexIdKey(vertexIDKey);
            loader.setEdgeIdKey(edgeIDKey);
Solution content
    public void loadingTest(int total, int bufferSize, BatchGraph.IDType type, LoadingFactory ids) {
        final VertexEdgeCounter counter = new VertexEdgeCounter();

        MockTransactionalGraph tgraph = null;
        if (ignoreIDs) {
            tgraph = new MockTransactionalGraph(new IgnoreIdTinkerGraph());
        } else {
            tgraph = new MockTransactionalGraph(new TinkerGraph());
        }

        BLGraph graph = new BLGraph(tgraph,counter,ids);
        BatchGraph loader = new BatchGraph(graph,type,bufferSize);

        if (assignKeys) {
            loader.setVertexIdKey(vertexIDKey);
            loader.setEdgeIdKey(edgeIDKey);
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
If statement
Method invocation
Variable
Chunk
Conflicting content
        }

        loader.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
<<<<<<< HEAD
        assertTrue(tgraph.allSuccessful());
        assertTrue(tgraph.allFinished());
=======
        assertEquals(0, graph.getNumTransactionsAborted());
        assertEquals(graph.getNumTransactionStarted(), graph.getNumTransactionsCommitted());
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
        loader.shutdown();
    }
Solution content
        }

        loader.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
        assertTrue(tgraph.allSuccessful());
        assertTrue(tgraph.allFinished());

        loader.shutdown();
    }
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
=======

        
        int totalVertices = 0;

    }
<<<<<<< HEAD
    
    static class BLGraph implements TransactionalGraph {
    static class BLGraph extends MockTransactionalTinkerGraph {

>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
        private static final int keepLast = 10;

        private final VertexEdgeCounter counter;
Solution content
        int totalVertices = 0;

    }

    
    static class BLGraph implements TransactionalGraph {
        
        private static final int keepLast = 10;

        private final VertexEdgeCounter counter;
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Class signature
Chunk
Conflicting content
        private boolean first = true;
        private final LoadingFactory ids;

<<<<<<< HEAD
        private final TransactionalGraph graph;
                
        BLGraph(TransactionalGraph graph, final VertexEdgeCounter counter, LoadingFactory ids) {
            this.graph=graph;
            this.counter=counter;
            this.ids=ids;
=======
        BLGraph(final VertexEdgeCounter counter, LoadingFactory ids) {
            this.counter = counter;
            this.ids = ids;
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
        }

        private static final Object parseID(Object id) {
Solution content
        private boolean first = true;
        private final LoadingFactory ids;

        private final TransactionalGraph graph;
                
        BLGraph(TransactionalGraph graph, final VertexEdgeCounter counter, LoadingFactory ids) {
            this.graph=graph;
            this.counter=counter;
            this.ids=ids;
        }

        private static final Object parseID(Object id) {
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method signature
Variable
Chunk
Conflicting content
            } else return id;
        }

<<<<<<< HEAD
        @Override
        public void startTransaction() throws IllegalStateException {
            graph.startTransaction();
        }

=======
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
        @Override
        public void stopTransaction(Conclusion conclusion) {
            graph.stopTransaction(conclusion);
Solution content
            } else return id;
        }

        @Override
        public void startTransaction() throws IllegalStateException {
            graph.startTransaction();
        }

        @Override
        public void stopTransaction(Conclusion conclusion) {
            graph.stopTransaction(conclusion);
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
        public void stopTransaction(Conclusion conclusion) {
            graph.stopTransaction(conclusion);
            //System.out.println("Committed (vertices/edges): " + counter.numVertices + " / " + counter.numEdges);
<<<<<<< HEAD
            assertEquals(counter.numVertices, BaseTest.count(graph.getVertices()) - (first ? 0 : keepLast));
            assertEquals(counter.numEdges,BaseTest.count(graph.getEdges()));
            for (Edge e : getEdges()) {
                int id = ((Number)e.getProperty(UID)).intValue();
                if (!ignoreIDs) {
                    assertEquals(ids.getEdgeID(id),parseID(e.getId()));
                }
                assertEquals(1,(Integer)e.getVertex(Direction.IN).getProperty(UID)-(Integer)e.getVertex(Direction.OUT).getProperty(UID));
=======
            assertEquals(counter.numVertices, BaseTest.count(super.getVertices()) - (first ? 0 : keepLast));
            assertEquals(counter.numEdges, BaseTest.count(super.getEdges()));
            for (Edge e : getEdges()) {
                int id = ((Number) e.getProperty(UID)).intValue();
                assertEquals(ids.getEdgeID(id), parseID(e.getId()));
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
                if (assignKeys) {
                    assertEquals(ids.getEdgeID(id), e.getProperty(edgeIDKey));
                }
Solution content
        public void stopTransaction(Conclusion conclusion) {
            graph.stopTransaction(conclusion);
            //System.out.println("Committed (vertices/edges): " + counter.numVertices + " / " + counter.numEdges);
            assertEquals(counter.numVertices, BaseTest.count(graph.getVertices()) - (first ? 0 : keepLast));
            assertEquals(counter.numEdges,BaseTest.count(graph.getEdges()));
            for (Edge e : getEdges()) {
                int id = ((Number)e.getProperty(UID)).intValue();
                if (!ignoreIDs) {
                    assertEquals(ids.getEdgeID(id),parseID(e.getId()));
                }
                assertEquals(1,(Integer)e.getVertex(Direction.IN).getProperty(UID)-(Integer)e.getVertex(Direction.OUT).getProperty(UID));
                if (assignKeys) {
                    assertEquals(ids.getEdgeID(id), e.getProperty(edgeIDKey));
                }
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
For statement
If statement
Method invocation
Variable
Chunk
Conflicting content
                }
            }
            for (Vertex v : getVertices()) {
<<<<<<< HEAD
                int id = ((Number)v.getProperty(UID)).intValue();
                if (!ignoreIDs) {
                    assertEquals(ids.getVertexID(id),parseID(v.getId()));
                }
                assertTrue(2>=BaseTest.count(v.getEdges(Direction.BOTH)));
                assertTrue(1>=BaseTest.count(v.getEdges(Direction.IN)));
                assertTrue(1>=BaseTest.count(v.getEdges(Direction.OUT)));

                if (assignKeys) {
                    assertEquals(ids.getVertexID(id), v.getProperty(vertexIDKey));
                }

            }
            for (Vertex v : getVertices()) {
                int id = ((Number)v.getProperty(UID)).intValue();
                if (id>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
                    removeVertex(v);
                }
            }
Solution content
                }
            }
            for (Vertex v : getVertices()) {
                int id = ((Number)v.getProperty(UID)).intValue();
                if (!ignoreIDs) {
                    assertEquals(ids.getVertexID(id),parseID(v.getId()));
                }
                assertTrue(2>=BaseTest.count(v.getEdges(Direction.BOTH)));
                assertTrue(1>=BaseTest.count(v.getEdges(Direction.IN)));
                assertTrue(1>=BaseTest.count(v.getEdges(Direction.OUT)));

                if (assignKeys) {
                    assertEquals(ids.getVertexID(id), v.getProperty(vertexIDKey));
                }

            }
            for (Vertex v : getVertices()) {
                int id = ((Number)v.getProperty(UID)).intValue();
                if (id
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
For statement
If statement
Method invocation
Variable
Chunk
Conflicting content
                }
            }
            for (Edge e : getEdges()) removeEdge(e);
<<<<<<< HEAD
            assertEquals(keepLast,BaseTest.count(graph.getVertices()));
            counter.numVertices=0;
            counter.numEdges=0;
=======
            assertEquals(keepLast, BaseTest.count(super.getVertices()));
            counter.numVertices = 0;
            counter.numEdges = 0;
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
            first = false;
            //System.out.println("------");
        }
Solution content
                }
            }
            for (Edge e : getEdges()) removeEdge(e);
            assertEquals(keepLast,BaseTest.count(graph.getVertices()));
            counter.numVertices=0;
            counter.numEdges=0;
            first = false;
            //System.out.println("------");
        }
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method invocation
Variable
Chunk
Conflicting content
            //System.out.println("------");
        }

<<<<<<< HEAD
        @Override
        public Features getFeatures() {
            return graph.getFeatures();
        }

        @Override
        public Vertex addVertex(Object id) {
            return graph.addVertex(id);
        }

        @Override
        public Vertex getVertex(Object id) {
            return graph.getVertex(id);
        }

        @Override
        public void removeVertex(Vertex vertex) {
            graph.removeVertex(vertex);
        }

        @Override
        public Iterable getVertices() {
            return graph.getVertices();
        }

        @Override
        public Iterable getVertices(String key, Object value) {
            return graph.getVertices(key,value);
        }

        @Override
        public Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label) {
            return graph.addEdge(id,outVertex,inVertex,label);
        }

        @Override
        public Edge getEdge(Object id) {
            return graph.getEdge(id);
        }

        @Override
        public void removeEdge(Edge edge) {
            graph.removeEdge(edge);
        }

        @Override
        public Iterable getEdges() {
            return graph.getEdges();
        }

        @Override
        public Iterable getEdges(String key, Object value) {
            return graph.getEdges(key,value);
        }

        @Override
        public void shutdown() {
            graph.shutdown();
        }

=======
>>>>>>> 6d2de4bd160e605047d0f11bb37238a726b1271a
    }

    interface LoadingFactory {
Solution content
            //System.out.println("------");
        }

        @Override
        public Features getFeatures() {
            return graph.getFeatures();
        }

        @Override
        public Vertex addVertex(Object id) {
            return graph.addVertex(id);
        }

        @Override
        public Vertex getVertex(Object id) {
            return graph.getVertex(id);
        }

        @Override
        public void removeVertex(Vertex vertex) {
            graph.removeVertex(vertex);
        }

        @Override
        public Iterable getVertices() {
            return graph.getVertices();
        }

        @Override
        public Iterable getVertices(String key, Object value) {
            return graph.getVertices(key,value);
        }

        @Override
        public Edge addEdge(Object id, Vertex outVertex, Vertex inVertex, String label) {
            return graph.addEdge(id,outVertex,inVertex,label);
        }

        @Override
        public Edge getEdge(Object id) {
            return graph.getEdge(id);
        }

        @Override
        public void removeEdge(Edge edge) {
            graph.removeEdge(edge);
        }

        @Override
        public Iterable getEdges() {
            return graph.getEdges();
        }

        @Override
        public Iterable getEdges(String key, Object value) {
            return graph.getEdges(key,value);
        }

        @Override
        public void shutdown() {
            graph.shutdown();
        }


    }

    interface LoadingFactory {
File
BatchGraphTest.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration