You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/01 15:03:42 UTC
[1/2] incubator-tinkerpop git commit: Dropped BatchGraph.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master be4bb3e42 -> 4150a16d3
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/BatchTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/BatchTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/BatchTest.java
deleted file mode 100644
index bebbc97..0000000
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/BatchTest.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure;
-
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.FeatureRequirement;
-import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
-import org.apache.tinkerpop.gremlin.GraphManager;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
-import org.apache.tinkerpop.gremlin.structure.util.batch.Exists;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures.FEATURE_USER_SUPPLIED_IDS;
-import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexPropertyFeatures.FEATURE_INTEGER_VALUES;
-import static org.junit.Assert.*;
-
-/**
- * BatchGraph tests are also handled by the IOTest battery. These tests focus mostly on issues with the incremental
- * loading setting turned on since that is not supported by the IO library.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class BatchTest extends AbstractGremlinTest {
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadVerticesIncrementallyWithSuppliedIdentifier() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .bufferSize(1).create();
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Vertex.class);
- final Object id2 = GraphManager.getGraphProvider().convertId("2", Vertex.class);
- batchGraph.addVertex(T.id, id1, "name", "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, id2, "name", "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, id1, "name", "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadVerticesIncrementallyWithNamedIdentifier() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .vertexIdKey("name")
- .bufferSize(1).create();
- batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadVerticesIncrementallyWithSuppliedIdentifierThrowOnExistingVertex() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.THROW, Exists.IGNORE)
- .bufferSize(1).create();
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Vertex.class);
- batchGraph.addVertex(T.id, id1, "name", "marko", "age", 29);
- try {
- batchGraph.addVertex(T.id, id1, "name", "marko", "age", 34);
- fail("Should have thrown an error because the vertex already exists");
- } catch (Exception ex) {
- assertTrue(ex instanceof IllegalStateException);
- }
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- public void shouldLoadVerticesIncrementallyWithNamedIdentifierThrowOnExistingVertex() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.THROW, Exists.IGNORE)
- .vertexIdKey("name")
- .bufferSize(1).create();
- batchGraph.addVertex(T.id, "marko", "age", 29);
- try {
- batchGraph.addVertex(T.id, "marko", "age", 34);
- fail("Should have thrown an error because the vertex already exists");
- } catch (Exception ex) {
- assertTrue(ex instanceof IllegalStateException);
- }
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadVerticesIncrementallyWithSuppliedIdentifierOverwriteSingleExistingVertex() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.OVERWRITE_SINGLE, Exists.IGNORE)
- .bufferSize(1).create();
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Vertex.class);
- final Object id2 = GraphManager.getGraphProvider().convertId("2", Vertex.class);
- batchGraph.addVertex(T.id, id1, "name", "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, id2, "name", "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, id1, "name", "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(34, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadVerticesIncrementallyWithNamedIdentifierOverwriteSingleExistingVertex() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.OVERWRITE_SINGLE, Exists.IGNORE)
- .vertexIdKey("name")
- .bufferSize(1).create();
- batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(34, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadVerticesIncrementallyWithSuppliedIdentifierOverwriteExistingVertex() {
- final BatchGraph<?> batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.OVERWRITE, Exists.IGNORE)
- .bufferSize(1).create();
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Vertex.class);
- final Object id2 = GraphManager.getGraphProvider().convertId("2", Vertex.class);
- batchGraph.addVertex(T.id, id1, "name", "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, id2, "name", "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, id1, "name", "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(2, IteratorUtils.count(vMarko.properties("age")));
- assertEquals(2, IteratorUtils.count(vMarko.properties("name")));
- assertTrue(((List) g.V(vMarko).valueMap().next().get("age")).contains(29));
- assertTrue(((List) g.V(vMarko).valueMap().next().get("age")).contains(34));
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
- public void shouldLoadVerticesIncrementallyWithNamedIdentifierAddMultiPropertyExistingVertex() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.OVERWRITE, Exists.IGNORE)
- .vertexIdKey("name")
- .bufferSize(1).create();
- batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 34);
- v1.addEdge("knows", v2, "weight", 1.0d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(2, IteratorUtils.count(vMarko.properties("age")));
- assertEquals(2, IteratorUtils.count(vMarko.properties("name")));
- assertTrue(((List) g.V(vMarko).valueMap().next().get("age")).contains(29));
- assertTrue(((List) g.V(vMarko).valueMap().next().get("age")).contains(34));
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadEdgesIncrementallyWithSuppliedIdentifier() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .vertexIdKey("name")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
-
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Edge.class);
-
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, id1);
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, id1); // second edge is ignored as it already exists
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyWithNamedIdentifier() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .vertexIdKey("name")
- .edgeIdKey("uid")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, "abcde");
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, "abcde"); // second edge is ignored as it already exists
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("uid", "abcde").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadEdgesIncrementallyWithSuppliedIdentifierOverwriteSingleExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.OVERWRITE_SINGLE)
- .vertexIdKey("name")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Edge.class);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, id1);
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, id1); // second edge is overwrites properties of the first
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyWithNamedIdentifierOverwriteSingleExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.OVERWRITE_SINGLE)
- .vertexIdKey("name")
- .edgeIdKey("uid")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, "abcde");
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, "abcde"); // second edge overwrites properties of the first
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("uid", "abcde").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadEdgesIncrementallyWithSuppliedIdentifierOverwriteExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.OVERWRITE)
- .vertexIdKey("name")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Edge.class);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, id1);
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, id1); // second edge is overwrites properties of the first
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyWithNamedIdentifierOverwriteExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.OVERWRITE)
- .vertexIdKey("name")
- .edgeIdKey("uid")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, "abcde");
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, "abcde"); // second edge overwrites properties of the first
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(0), g.V(vStephen).outE("knows").has("uid", "abcde").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_USER_SUPPLIED_IDS)
- public void shouldLoadEdgesIncrementallyWithSuppliedIdentifierThrowOnExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.THROW)
- .vertexIdKey("name")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- final Object id1 = GraphManager.getGraphProvider().convertId("1", Edge.class);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, id1);
- try {
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, id1); // second edge is overwrites properties of the first
- fail("Should have thrown an error because the vertex already exists");
- } catch (Exception ex) {
- assertTrue(ex instanceof IllegalStateException);
- }
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyWithNamedIdentifierThrowOnExistingEdge() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true, Exists.IGNORE, Exists.THROW)
- .vertexIdKey("name")
- .edgeIdKey("uid")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d, T.id, "abcde");
- try {
- v1.addEdge("knows", v2, "weight", 0.5d, T.id, "abcde"); // second edge is overwrites properties of the first
- fail("Should have thrown an error because the vertex already exists");
- } catch (Exception ex) {
- assertTrue(ex instanceof IllegalStateException);
- }
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyNoIdSpecified() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .vertexIdKey("name")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d);
- v1.addEdge("knows", v2, "weight", 0.5d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-
- @Test
- @FeatureRequirementSet(FeatureRequirementSet.Package.SIMPLE)
- @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = FEATURE_INTEGER_VALUES)
- @FeatureRequirement(featureClass = Graph.Features.EdgePropertyFeatures.class, feature = Graph.Features.EdgePropertyFeatures.FEATURE_DOUBLE_VALUES)
- public void shouldLoadEdgesIncrementallyWithNamedIdentifierAndNoIdSpecified() {
- final BatchGraph batchGraph = BatchGraph.build(graph)
- .incrementalLoading(true)
- .vertexIdKey("name")
- .edgeIdKey("uid")
- .bufferSize(1).create();
- final Vertex v2 = batchGraph.addVertex(T.id, "marko", "age", 29);
- final Vertex v1 = batchGraph.addVertex(T.id, "stephen", "age", 37);
- v1.addEdge("knows", v2, "weight", 1.0d);
- v1.addEdge("knows", v2, "weight", 0.5d);
- tryCommit(batchGraph);
-
- final Vertex vStephen = g.V().has("name", "stephen").next();
- assertEquals(37, vStephen.property("age").value());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 1.0d).inV().has("name", "marko").count().next());
- assertEquals(new Long(1), g.V(vStephen).outE("knows").has("weight", 0.5d).inV().has("name", "marko").count().next());
-
- final Vertex vMarko = g.V().has("name", "marko").next();
- assertEquals(29, vMarko.property("age").value());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/StructureStandardSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/StructureStandardSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/StructureStandardSuite.java
index 209c9e7..4625bc7 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/StructureStandardSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/StructureStandardSuite.java
@@ -36,11 +36,6 @@ import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.RunnerBuilder;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
/**
* The {@code StructureStandardSuite} is a JUnit test runner that executes the Gremlin Test Suite over a
* {@link Graph} implementation. This specialized test suite and runner is for use by
@@ -76,7 +71,6 @@ public class StructureStandardSuite extends AbstractGremlinSuite {
* as needed to enforce tests upon implementations.
*/
private static final Class<?>[] allTests = new Class<?>[]{
- BatchTest.class,
CommunityGeneratorTest.class,
DetachedGraphTest.class,
DetachedEdgeTest.class,
[2/2] incubator-tinkerpop git commit: Dropped BatchGraph.
Posted by sp...@apache.org.
Dropped BatchGraph.
It will be replaced by OLAP style loaders.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/4150a16d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4150a16d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4150a16d
Branch: refs/heads/master
Commit: 4150a16d3b098446ed8a2f51c98eb762b36a2038
Parents: be4bb3e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 1 09:01:44 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 1 09:01:44 2015 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../structure/io/graphml/GraphMLReader.java | 3 +-
.../structure/io/graphson/GraphSONReader.java | 3 +-
.../io/graphson/LegacyGraphSONReader.java | 3 +-
.../gremlin/structure/io/gryo/GryoReader.java | 3 +-
.../structure/util/batch/BatchFeatures.java | 216 -------
.../structure/util/batch/BatchGraph.java | 643 -------------------
.../gremlin/structure/util/batch/Exists.java | 62 --
.../structure/util/batch/VertexIdType.java | 65 --
.../util/batch/cache/AbstractIDVertexCache.java | 78 ---
.../util/batch/cache/LongIDVertexCache.java | 94 ---
.../util/batch/cache/ObjectIDVertexCache.java | 25 -
.../util/batch/cache/StringCompression.java | 29 -
.../util/batch/cache/StringIDVertexCache.java | 87 ---
.../util/batch/cache/URLCompression.java | 67 --
.../structure/util/batch/cache/VertexCache.java | 36 --
.../driver/benchmark/ProfilingApplication.java | 27 +-
.../AbstractImportCustomizerProvider.java | 2 -
.../tinkerpop/gremlin/structure/BatchTest.java | 475 --------------
.../structure/StructureStandardSuite.java | 6 -
20 files changed, 26 insertions(+), 1899 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 9fc55cf..35926dd 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
TinkerPop 3.0.0.M9 (NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Dropped `BatchGraph` from the code base - it will be replaced by bulk loader functionality over OLAP.
* `TraversalSideEffects` now implements `Optional` semantics. Less code as Java8 provides the helper methods.
* `TraversalScriptSupplier` now takes an `Object` var args for setting `ScriptEngine` bindings if needed.
* `Compare` is now more lenient on `Number`-types.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
index bcb462d..6a50679 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
@@ -29,7 +29,6 @@ import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -318,7 +317,7 @@ public class GraphMLReader implements GraphReader {
public static final class Builder implements ReaderBuilder<GraphMLReader> {
private String edgeLabelKey = GraphMLTokens.LABEL_E;
private String vertexLabelKey = GraphMLTokens.LABEL_V;
- private long batchSize = BatchGraph.DEFAULT_BUFFER_SIZE;
+ private long batchSize = 10000;
private Builder() {
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
index 79365af..e90faa3 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
@@ -31,7 +31,6 @@ import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.Host;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
@@ -240,7 +239,7 @@ public class GraphSONReader implements GraphReader {
}
public static class Builder implements ReaderBuilder<GraphSONReader> {
- private long batchSize = BatchGraph.DEFAULT_BUFFER_SIZE;
+ private long batchSize = 10000;
private GraphSONMapper mapper = GraphSONMapper.build().create();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
index 11fd97b..e2834c2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/LegacyGraphSONReader.java
@@ -34,7 +34,6 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
import java.io.IOException;
import java.io.InputStream;
@@ -205,7 +204,7 @@ public class LegacyGraphSONReader implements GraphReader {
public static class Builder {
private boolean loadCustomModules = false;
private List<SimpleModule> customModules = new ArrayList<>();
- private long batchSize = BatchGraph.DEFAULT_BUFFER_SIZE;
+ private long batchSize = 10000;
private boolean embedTypes = false;
private Builder() {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
index 70eae85..bdce1af 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
@@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.shaded.kryo.io.Input;
@@ -238,7 +237,7 @@ public class GryoReader implements GraphReader {
public static class Builder implements ReaderBuilder<GryoReader> {
- private long batchSize = BatchGraph.DEFAULT_BUFFER_SIZE;
+ private long batchSize = 10000;
/**
* Always use the most recent gryo version by default
*/
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchFeatures.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchFeatures.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchFeatures.java
deleted file mode 100644
index 7c9a533..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchFeatures.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class BatchFeatures implements Graph.Features {
-
- private final Graph.Features baseFeatures;
- private final BatchGraphFeatures graphFeatures = new BatchGraphFeatures();
-
- private final VertexFeatures vertexFeatures = new VertexFeatures() {
- @Override
- public boolean supportsUserSuppliedIds() {
- // batch loading supports user supplied ids
- return true;
- }
-
- @Override
- public VertexPropertyFeatures properties() {
- return vertexPropertyFeatures;
- }
- };
-
- private final EdgeFeatures edgeFeatures = new EdgeFeatures() {
- @Override
- public boolean supportsUserSuppliedIds() {
- // batch loading supports user supplied identifiers
- return true;
- }
-
- @Override
- public EdgePropertyFeatures properties() {
- return edgePropertyFeatures;
- }
- };
-
- private final EdgePropertyFeatures edgePropertyFeatures = new BatchEdgePropertyFeatures();
- private final VertexPropertyFeatures vertexPropertyFeatures = new BatchVertexPropertyFeatures();
-
- public BatchFeatures(final Graph.Features baseFeatures) {
- this.baseFeatures = baseFeatures;
- }
-
- @Override
- public GraphFeatures graph() {
- return graphFeatures;
- }
-
- @Override
- public VertexFeatures vertex() {
- return vertexFeatures;
- }
-
- @Override
- public EdgeFeatures edge() {
- return edgeFeatures;
- }
-
- class BatchVertexPropertyFeatures extends BatchDataTypeFeature implements VertexPropertyFeatures {
- @Override
- public boolean supportsProperties() {
- return baseFeatures.vertex().properties().supportsProperties();
- }
- }
-
- class BatchEdgePropertyFeatures extends BatchDataTypeFeature implements EdgePropertyFeatures {
- @Override
- public boolean supportsProperties() {
- return baseFeatures.edge().properties().supportsProperties();
- }
- }
-
- class BatchGraphFeatures implements GraphFeatures {
-
- @Override
- public boolean supportsComputer() {
- return false;
- }
-
- @Override
- public boolean supportsPersistence() {
- return baseFeatures.graph().supportsPersistence();
- }
-
- @Override
- public boolean supportsTransactions() {
- // the transaction is true because as a wrapper the BatchGraph will check the features of the
- // underlying graph and not let it fail if the underlying graph does not support tx.
- return true;
- }
-
- @Override
- public boolean supportsThreadedTransactions() {
- return false;
- }
-
- @Override
- public VariableFeatures variables() {
- return new BatchVariableFeatures();
- }
- }
-
- class BatchVariableFeatures extends BatchDataTypeFeature implements VariableFeatures {
- @Override
- public boolean supportsVariables() {
- return baseFeatures.graph().variables().supportsVariables();
- }
- }
-
- class BatchDataTypeFeature implements DataTypeFeatures {
- @Override
- public boolean supportsBooleanValues() {
- return baseFeatures.graph().variables().supportsBooleanValues();
- }
-
- @Override
- public boolean supportsDoubleValues() {
- return baseFeatures.graph().variables().supportsDoubleValues();
- }
-
- @Override
- public boolean supportsFloatValues() {
- return baseFeatures.graph().variables().supportsFloatValues();
- }
-
- @Override
- public boolean supportsIntegerValues() {
- return baseFeatures.graph().variables().supportsIntegerValues();
- }
-
- @Override
- public boolean supportsLongValues() {
- return baseFeatures.graph().variables().supportsLongValues();
- }
-
- @Override
- public boolean supportsMapValues() {
- return baseFeatures.graph().variables().supportsMapValues();
- }
-
- @Override
- public boolean supportsByteValues() {
- return baseFeatures.graph().variables().supportsByteValues();
- }
-
- @Override
- public boolean supportsMixedListValues() {
- return baseFeatures.graph().variables().supportsMixedListValues();
- }
-
- @Override
- public boolean supportsBooleanArrayValues() {
- return baseFeatures.graph().variables().supportsBooleanArrayValues();
- }
-
- @Override
- public boolean supportsByteArrayValues() {
- return baseFeatures.graph().variables().supportsByteArrayValues();
- }
-
- @Override
- public boolean supportsDoubleArrayValues() {
- return baseFeatures.graph().variables().supportsDoubleArrayValues();
- }
-
- @Override
- public boolean supportsFloatArrayValues() {
- return baseFeatures.graph().variables().supportsFloatArrayValues();
- }
-
- @Override
- public boolean supportsIntegerArrayValues() {
- return baseFeatures.graph().variables().supportsIntegerArrayValues();
- }
-
- @Override
- public boolean supportsLongArrayValues() {
- return baseFeatures.graph().variables().supportsLongArrayValues();
- }
-
- @Override
- public boolean supportsSerializableValues() {
- return baseFeatures.graph().variables().supportsSerializableValues();
- }
-
- @Override
- public boolean supportsStringValues() {
- return baseFeatures.graph().variables().supportsStringValues();
- }
-
- @Override
- public boolean supportsUniformListValues() {
- return baseFeatures.graph().variables().supportsUniformListValues();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchGraph.java
deleted file mode 100644
index ffa5fff..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/BatchGraph.java
+++ /dev/null
@@ -1,643 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch;
-
-import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.Transaction;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.VertexCache;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-/**
- * {@code BatchGraph} is a wrapper that enables batch loading of a large number of edges and vertices by chunking the
- * entire load into smaller batches and maintaining a sideEffects-efficient vertex cache so that the entire
- * transactional state can be flushed after each chunk is loaded.
- * <br />
- * {@code BatchGraph} is ONLY meant for loading data and does not support any retrieval or removal operations.
- * That is, BatchGraph only supports the following methods:
- * - {@link #addVertex(Object...)} for adding vertices
- * - {@link Vertex#addEdge(String, org.apache.tinkerpop.gremlin.structure.Vertex, Object...)} for adding edges
- * - Property getter, setter and removal methods for vertices and edges.
- * <br />
- * An important limitation of BatchGraph is that edge properties can only be set immediately after the edge has been
- * added. If other vertices or edges have been created in the meantime, setting, getting or removing properties will
- * throw exceptions. This is done to avoid caching of edges which would require a great amount of sideEffects.
- * <br />
- * {@code BatchGraph} can also automatically set the provided element ids as properties on the respective element. Use
- * {@link Builder#vertexIdKey(String)} and {@link Builder#edgeIdKey(String)} to set the keys
- * for the vertex and edge properties respectively. This allows to make the loaded baseGraph compatible for later
- * operation with {@link ElementIdStrategy}.
- *
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class BatchGraph<G extends Graph> implements Graph {
- /**
- * Default buffer size is 10000.
- */
- public static final long DEFAULT_BUFFER_SIZE = 10000;
-
- private final G baseGraph;
-
- private final String vertexIdKey;
- private final String edgeIdKey;
- private final boolean incrementalLoading;
- private final boolean baseSupportsSuppliedVertexId;
- private final boolean baseSupportsSuppliedEdgeId;
- private final boolean baseSupportsTransactions;
- private final BiConsumer<Element, Object[]> existingVertexStrategy;
- private final BiConsumer<Element, Object[]> existingEdgeStrategy;
-
- private final VertexCache cache;
-
- private final long bufferSize;
- private long remainingBufferSize;
-
- private BatchEdge currentEdge = null;
- private Edge currentEdgeCached = null;
-
- private Object previousOutVertexId = null;
-
- private final BatchFeatures batchFeatures;
-
- private final Transaction batchTransaction;
-
- /**
- * Constructs a BatchGraph wrapping the provided baseGraph, using the specified buffer size and expecting vertex
- * ids of the specified IdType. Supplying vertex ids which do not match this type will throw exceptions.
- *
- * @param graph Graph to be wrapped
- * @param type Type of vertex id expected. This information is used to apply the vertex cache
- * sideEffects footprint.
- * @param bufferSize Defines the number of vertices and edges loaded before starting a new transaction. The
- * larger this value, the more sideEffects is required but the faster the loading process.
- */
- private BatchGraph(final G graph, final VertexIdType type, final long bufferSize, final String vertexIdKey,
- final String edgeIdKey, final boolean incrementalLoading,
- final BiConsumer<Element, Object[]> existingVertexStrategy,
- final BiConsumer<Element, Object[]> existingEdgeStrategy) {
- this.baseGraph = graph;
- this.batchTransaction = new BatchTransaction();
- this.batchFeatures = new BatchFeatures(graph.features());
- this.bufferSize = bufferSize;
- this.cache = type.getVertexCache();
- this.remainingBufferSize = this.bufferSize;
- this.vertexIdKey = vertexIdKey;
- this.edgeIdKey = edgeIdKey;
- this.incrementalLoading = incrementalLoading;
- this.baseSupportsSuppliedEdgeId = this.baseGraph.features().edge().supportsUserSuppliedIds();
- this.baseSupportsSuppliedVertexId = this.baseGraph.features().vertex().supportsUserSuppliedIds();
- this.baseSupportsTransactions = this.baseGraph.features().graph().supportsTransactions();
- this.existingEdgeStrategy = existingEdgeStrategy;
- this.existingVertexStrategy = existingVertexStrategy;
- }
-
- private void nextElement() {
- currentEdge = null;
- currentEdgeCached = null;
- if (remainingBufferSize <= 0) {
- if (this.baseSupportsTransactions) baseGraph.tx().commit();
- cache.newTransaction();
- remainingBufferSize = bufferSize;
- }
- remainingBufferSize--;
- }
-
- private Vertex retrieveFromCache(final Object externalID) {
- final Object internal = cache.getEntry(externalID);
- if (internal instanceof Vertex) {
- return (Vertex) internal;
- } else if (internal != null) { //its an internal id
- final Vertex v = baseGraph.traversal().V(internal).next();
- cache.set(v, externalID);
- return v;
- } else return null;
- }
-
- private Vertex getCachedVertex(final Object externalID) {
- final Vertex v = retrieveFromCache(externalID);
- if (v == null) throw new IllegalArgumentException("Vertex for given ID cannot be found: " + externalID);
- return v;
- }
-
- @Override
- public Vertex addVertex(final Object... keyValues) {
- final Object id = ElementHelper.getIdValue(keyValues).orElseThrow(() -> new IllegalArgumentException("Vertex id value cannot be null"));
- if (!incrementalLoading && retrieveFromCache(id) != null)
- throw new IllegalArgumentException("Vertex id already exists");
- nextElement();
-
- // if the vertexIdKey is not the T.id then append it as a name/value pair. this will overwrite what
- // is present in that field already
- final Object[] keysVals = T.id.getAccessor().equals(vertexIdKey) ? keyValues : ElementHelper.upsert(keyValues, vertexIdKey, id);
-
- // if the graph doesn't support vertex ids or the vertex id is not the T.id then remove that key
- // value pair as it will foul up insertion (i.e. an exception for graphs that don't support it and the
- // id will become the value of the vertex id which might not be expected.
- final Optional<Object[]> kvs = this.baseSupportsSuppliedVertexId && T.id.getAccessor().equals(vertexIdKey) ?
- Optional.ofNullable(keyValues) : ElementHelper.remove(T.id, keysVals);
-
- Vertex currentVertex;
- if (!incrementalLoading)
- currentVertex = kvs.isPresent() ? baseGraph.addVertex(kvs.get()) : baseGraph.addVertex();
- else {
- final Traversal<Vertex, Vertex> traversal = baseGraph.traversal().V().has(vertexIdKey, id);
- if (traversal.hasNext()) {
- final Vertex v = traversal.next();
- if (traversal.hasNext())
- throw new IllegalStateException(String.format("There is more than one vertex identified by %s=%s", vertexIdKey, id));
-
- // let the caller decide how to handle conflict
- kvs.ifPresent(keyvals -> existingVertexStrategy.accept(v, keyvals));
- currentVertex = v;
- } else
- currentVertex = kvs.isPresent() ? baseGraph.addVertex(kvs.get()) : baseGraph.addVertex();
- }
-
- cache.set(currentVertex, id);
-
- return new BatchVertex(id);
- }
-
- @Override
- public Iterator<Vertex> vertices(final Object... vertexIds) {
- if (vertexIds.length > 1)
- throw new IllegalArgumentException("BatchGraph only allows a single vertex id at one time");
- if ((this.previousOutVertexId != null) && (this.previousOutVertexId.equals(vertexIds[0]))) {
- return IteratorUtils.of(new BatchVertex(this.previousOutVertexId));
- } else {
- Vertex vertex = retrieveFromCache(vertexIds[0]);
- if (null == vertex) {
- if (!this.incrementalLoading) return Collections.emptyIterator();
- else {
- final Iterator<Vertex> iterator = this.baseGraph.traversal().V().has(this.vertexIdKey, vertexIds[0]);
- if (!iterator.hasNext()) return Collections.emptyIterator();
- vertex = iterator.next();
- if (iterator.hasNext())
- throw new IllegalStateException("There are multiple vertices with the provided id in the graph: " + vertexIds[0]);
- this.cache.set(vertex, vertexIds[0]);
- }
- }
- return IteratorUtils.of(new BatchVertex(vertexIds[0]));
- }
- }
-
- @Override
- public Iterator<Edge> edges(final Object... edgeIds) {
- throw retrievalNotSupported();
- }
-
- @Override
- public <C extends GraphComputer> C compute(final Class<C> graphComputerClass) {
- throw Exceptions.graphComputerNotSupported();
- }
-
- @Override
- public GraphComputer compute() {
- throw Exceptions.graphComputerNotSupported();
- }
-
- @Override
- public Transaction tx() {
- return this.batchTransaction;
- }
-
- @Override
- public Variables variables() {
- throw Exceptions.variablesNotSupported();
- }
-
- @Override
- public Configuration configuration() {
- return new BaseConfiguration();
- }
-
- @Override
- public Features features() {
- return this.batchFeatures;
- }
-
- @Override
- public void close() throws Exception {
- baseGraph.close();
-
- // call reset after the close in case the close behavior fails
- reset();
- }
-
- private void reset() {
- currentEdge = null;
- currentEdgeCached = null;
- remainingBufferSize = 0;
- }
-
- public static <T extends Graph> Builder build(final T g) {
- return new Builder<>(g);
- }
-
- private class BatchTransaction implements Transaction {
- private final boolean supportsTx;
-
- public BatchTransaction() {
- supportsTx = baseGraph.features().graph().supportsTransactions();
- }
-
- @Override
- public Transaction onClose(final Consumer<Transaction> consumer) {
- throw new UnsupportedOperationException("Transaction behavior cannot be altered in batch mode - set the behavior on the base graph");
- }
-
- @Override
- public Transaction onReadWrite(final Consumer<Transaction> consumer) {
- throw new UnsupportedOperationException("Transaction behavior cannot be altered in batch mode - set the behavior on the base graph");
- }
-
- @Override
- public void close() {
- if (supportsTx) baseGraph.tx().close();
-
- // call reset after the close in case the close behavior fails
- reset();
- }
-
- @Override
- public void readWrite() {
- if (supportsTx) baseGraph.tx().readWrite();
- }
-
- @Override
- public boolean isOpen() {
- return !supportsTx || baseGraph.tx().isOpen();
- }
-
- @Override
- public <G extends Graph> G create() {
- throw new UnsupportedOperationException("Cannot start threaded transaction during batch loading");
- }
-
- @Override
- public <R> Workload<R> submit(final Function<Graph, R> work) {
- throw new UnsupportedOperationException("Cannot submit a workload during batch loading");
- }
-
- @Override
- public void rollback() {
- throw new UnsupportedOperationException("Cannot issue a rollback during batch loading");
- }
-
- @Override
- public void commit() {
- if (supportsTx) baseGraph.tx().commit();
-
- // call reset after the close in case the close behavior fails
- reset();
- }
-
- @Override
- public void open() {
- if (supportsTx) baseGraph.tx().open();
- }
-
- @Override
- public void addTransactionListener(final Consumer<Status> listener) {
- throw new UnsupportedOperationException("Listeners not supported during batch loading");
- }
-
- @Override
- public void removeTransactionListener(final Consumer<Status> listener) {
- throw new UnsupportedOperationException("Listeners not supported during batch loading");
- }
-
- @Override
- public void clearTransactionListeners() {
- throw new UnsupportedOperationException("Listeners not supported during batch loading");
- }
- }
-
- private class BatchVertex implements Vertex {
-
- private final Object externalID;
-
- BatchVertex(final Object id) {
- if (id == null) throw new IllegalArgumentException("External id may not be null");
- externalID = id;
- }
-
- @Override
- public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
- if (!BatchVertex.class.isInstance(inVertex))
- throw new IllegalArgumentException("Given element was not created in this baseGraph");
- nextElement();
-
- final Vertex ov = getCachedVertex(externalID);
- final Vertex iv = getCachedVertex(inVertex.id());
-
- previousOutVertexId = externalID; //keep track of the previous out vertex id
-
- if (!incrementalLoading) {
- final Optional<Object[]> kvs = baseSupportsSuppliedEdgeId && T.id.getAccessor().equals(edgeIdKey) ?
- Optional.ofNullable(keyValues) : ElementHelper.remove(T.id, keyValues);
- currentEdgeCached = kvs.isPresent() ? ov.addEdge(label, iv, kvs.get()) : ov.addEdge(label, iv);
- } else {
- final Optional<Object> id = ElementHelper.getIdValue(keyValues);
- // if the edgeIdKey is not the Element.ID then append it as a name/value pair. this will overwrite what
- // is present in that field already
- final Object[] keysVals = id.isPresent() && T.id.getAccessor().equals(edgeIdKey) ? keyValues :
- id.isPresent() ? ElementHelper.upsert(keyValues, edgeIdKey, id.get()) : keyValues;
-
- // if the graph doesn't support edge ids or the edge id is not the Element.ID then remove that key
- // value pair as it will foul up insertion (i.e. an exception for graphs that don't support it and the
- // id will become the value of the edge id which might not be expected.
- final Optional<Object[]> kvs = baseSupportsSuppliedEdgeId && T.id.getAccessor().equals(edgeIdKey) ?
- Optional.ofNullable(keyValues) : ElementHelper.remove(T.id, keysVals);
-
- if (id.isPresent()) {
- final Traversal<Edge, Edge> traversal = baseGraph.traversal().E().has(edgeIdKey, id.get());
- if (traversal.hasNext()) {
- final Edge e = traversal.next();
- // let the user decide how to handle conflict
- kvs.ifPresent(keyvals -> existingEdgeStrategy.accept(e, keyvals));
- currentEdgeCached = e;
- } else
- currentEdgeCached = kvs.isPresent() ? ov.addEdge(label, iv, kvs.get()) : ov.addEdge(label, iv);
- } else {
- currentEdgeCached = kvs.isPresent() ? ov.addEdge(label, iv, kvs.get()) : ov.addEdge(label, iv);
- }
- }
-
- currentEdge = new BatchEdge();
-
- return currentEdge;
- }
-
- @Override
- public Object id() {
- return this.externalID;
- }
-
- @Override
- public Graph graph() {
- return getCachedVertex(externalID).graph();
- }
-
- @Override
- public String label() {
- return getCachedVertex(externalID).label();
- }
-
- @Override
- public void remove() {
- throw removalNotSupported();
- }
-
- @Override
- public Set<String> keys() {
- return getCachedVertex(externalID).keys();
- }
-
- @Override
- public <V> VertexProperty<V> property(VertexProperty.Cardinality cardinality, String key, V value, Object... keyValues) {
- return getCachedVertex(externalID).property(cardinality, key, value, keyValues);
- }
-
- @Override
- public <V> VertexProperty<V> property(final String key) {
- return getCachedVertex(externalID).property(key);
- }
-
- @Override
- public <V> VertexProperty<V> property(final String key, final V value, final Object... keyValues) {
- return getCachedVertex(externalID).property(key, value, keyValues);
- }
-
- @Override
- public <V> V value(final String key) throws NoSuchElementException {
- return getCachedVertex(externalID).value(key);
- }
-
- @Override
- public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
- throw retrievalNotSupported();
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction, final String... labels) {
- throw retrievalNotSupported();
- }
-
- @Override
- public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
- return getCachedVertex(externalID).properties(propertyKeys);
- }
- }
-
- private class BatchEdge implements Edge {
-
-
- @Override
- public Graph graph() {
- return getWrappedEdge().graph();
- }
-
- @Override
- public Object id() {
- return getWrappedEdge().label();
- }
-
- @Override
- public String label() {
- return getWrappedEdge().label();
- }
-
- @Override
- public void remove() {
- throw removalNotSupported();
- }
-
- @Override
- public <V> Property<V> property(final String key) {
- return getWrappedEdge().property(key);
- }
-
- @Override
- public <V> Property<V> property(final String key, final V value) {
- return getWrappedEdge().property(key, value);
- }
-
- @Override
- public Set<String> keys() {
- return getWrappedEdge().keys();
- }
-
- @Override
- public <V> V value(final String key) throws NoSuchElementException {
- return getWrappedEdge().value(key);
- }
-
- private Edge getWrappedEdge() {
- if (this != currentEdge) {
- throw new UnsupportedOperationException("This edge is no longer in scope");
- }
- return currentEdgeCached;
- }
-
- @Override
- public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
- return getWrappedEdge().properties(propertyKeys);
- }
-
- @Override
- public Iterator<Vertex> vertices(final Direction direction) {
- return getWrappedEdge().vertices(direction);
- }
- }
-
- private static UnsupportedOperationException retrievalNotSupported() {
- return new UnsupportedOperationException("Retrieval operations are not supported during batch loading");
- }
-
- private static UnsupportedOperationException removalNotSupported() {
- return new UnsupportedOperationException("Removal operations are not supported during batch loading");
- }
-
- public static class Builder<G extends Graph> {
- private final G graphToLoad;
- private boolean incrementalLoading = false;
- private String vertexIdKey = T.id.getAccessor();
- private String edgeIdKey = T.id.getAccessor();
- private long bufferSize = DEFAULT_BUFFER_SIZE;
- private VertexIdType vertexIdType = VertexIdType.OBJECT;
- private BiConsumer<Element, Object[]> existingVertexStrategy = Exists.IGNORE;
- private BiConsumer<Element, Object[]> existingEdgeStrategy = Exists.IGNORE;
-
- private Builder(final G g) {
- if (null == g) throw new IllegalArgumentException("Graph may not be null");
- if (g instanceof BatchGraph)
- throw new IllegalArgumentException("BatchGraph cannot wrap another BatchGraph instance");
- this.graphToLoad = g;
- }
-
- /**
- * Sets the key to be used when setting the vertex id as a property on the respective vertex. If this
- * value is not set it defaults to {@link T#id}.
- *
- * @param key Key to be used.
- */
- public Builder vertexIdKey(final String key) {
- if (null == key) throw new IllegalArgumentException("Key cannot be null");
- this.vertexIdKey = key;
- return this;
- }
-
- /**
- * Sets the key to be used when setting the edge id as a property on the respective edge.
- * If the key is null, then no property will be set.
- *
- * @param key Key to be used.
- */
- public Builder edgeIdKey(final String key) {
- if (null == key) throw new IllegalArgumentException("Optional value for key cannot be null");
- this.edgeIdKey = key;
- return this;
- }
-
- /**
- * Number of mutations to perform between calls to {@link org.apache.tinkerpop.gremlin.structure.Transaction#commit}.
- */
- public Builder bufferSize(long bufferSize) {
- if (bufferSize <= 0) throw new IllegalArgumentException("BufferSize must be positive");
- this.bufferSize = bufferSize;
- return this;
- }
-
- /**
- * Sets the type of the id used for the vertex which in turn determines the cache type that is used.
- */
- public Builder vertexIdType(final VertexIdType type) {
- if (null == type) throw new IllegalArgumentException("Type may not be null");
- this.vertexIdType = type;
- return this;
- }
-
- /**
- * Sets whether the graph loaded through this instance of {@link BatchGraph} is loaded from scratch
- * (i.e. the wrapped graph is initially empty) or whether graph is loaded incrementally into an
- * existing graph.
- * <p/>
- * In the former case, BatchGraph does not need to check for the existence of vertices with the wrapped
- * graph but only needs to consult its own cache which can be significantly faster. In the latter case,
- * the cache is checked first but an additional check against the wrapped graph may be necessary if
- * the vertex does not exist.
- * <p/>
- * By default, BatchGraph assumes that the data is loaded from scratch.
- */
- public Builder incrementalLoading(final boolean incrementalLoading) {
- this.incrementalLoading = incrementalLoading;
- return this;
- }
-
- /**
- * Sets whether the graph loaded through this instance of {@link BatchGraph} is loaded from scratch
- * (i.e. the wrapped graph is initially empty) or whether graph is loaded incrementally into an
- * existing graph.
- * <p/>
- * In the former case, BatchGraph does not need to check for the existence of vertices with the wrapped
- * graph but only needs to consult its own cache which can be significantly faster. In the latter case,
- * the cache is checked first but an additional check against the wrapped graph may be necessary if
- * the vertex does not exist.
- * <p/>
- * By default, BatchGraph assumes that the data is loaded from scratch.
- */
- public Builder incrementalLoading(final boolean incrementalLoading,
- final BiConsumer<Element, Object[]> existingVertexStrategy,
- final BiConsumer<Element, Object[]> existingEdgeStrategy) {
- this.incrementalLoading = incrementalLoading;
- this.existingVertexStrategy = existingVertexStrategy;
- this.existingEdgeStrategy = existingEdgeStrategy;
- return this;
- }
-
- public BatchGraph<G> create() {
- return new BatchGraph<>(graphToLoad, vertexIdType, bufferSize, vertexIdKey, edgeIdKey,
- incrementalLoading, this.existingVertexStrategy, this.existingEdgeStrategy);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/Exists.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/Exists.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/Exists.java
deleted file mode 100644
index a4a9a4e..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/Exists.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch;
-
-import org.apache.tinkerpop.gremlin.structure.Element;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
-
-import java.util.function.BiConsumer;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public enum Exists implements BiConsumer<Element, Object[]> {
- IGNORE {
- @Override
- public void accept(final Element element, final Object[] objects) {
- // do nothing
- }
- },
- THROW {
- @Override
- public void accept(final Element element, final Object[] objects) {
- throw new IllegalStateException(String.format(
- "Element of type %s with id of [%s] was not expected to exist in target graph",
- element.getClass().getSimpleName(), element.id()));
- }
- },
- OVERWRITE {
- @Override
- public void accept(final Element element, final Object[] keyValues) {
- if (element instanceof Vertex)
- ElementHelper.attachProperties((Vertex) element, VertexProperty.Cardinality.list, keyValues);
- else
- ElementHelper.attachProperties(element, keyValues);
-
- }
- },
- OVERWRITE_SINGLE {
- @Override
- public void accept(final Element element, final Object[] keyValues) {
- ElementHelper.attachProperties(element, keyValues);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/VertexIdType.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/VertexIdType.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/VertexIdType.java
deleted file mode 100644
index 29cf4ce..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/VertexIdType.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch;
-
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.LongIDVertexCache;
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.ObjectIDVertexCache;
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.StringIDVertexCache;
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.URLCompression;
-import org.apache.tinkerpop.gremlin.structure.util.batch.cache.VertexCache;
-
-/**
- * Type of vertex ids expected by BatchGraph. The default is IdType.OBJECT.
- * Use the IdType that best matches the used vertex id types in order to save sideEffects.
- *
- * @author Matthias Broecheler (http://www.matthiasb.com)
- */
-public enum VertexIdType {
-
- OBJECT {
- @Override
- public VertexCache getVertexCache() {
- return new ObjectIDVertexCache();
- }
- },
-
- NUMBER {
- @Override
- public VertexCache getVertexCache() {
- return new LongIDVertexCache();
- }
- },
-
- STRING {
- @Override
- public VertexCache getVertexCache() {
- return new StringIDVertexCache();
- }
- },
-
- URL {
- @Override
- public VertexCache getVertexCache() {
- return new StringIDVertexCache(new URLCompression());
-
- }
- };
-
- public abstract VertexCache getVertexCache();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/AbstractIDVertexCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/AbstractIDVertexCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/AbstractIDVertexCache.java
deleted file mode 100644
index 5672842..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/AbstractIDVertexCache.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-abstract class AbstractIDVertexCache implements VertexCache {
-
- static final int INITIAL_CAPACITY = 1000;
- static final int INITIAL_TX_CAPACITY = 100;
-
- private final Map<Object, Object> map;
- private final Set<Object> mapKeysInCurrentTx;
-
- AbstractIDVertexCache() {
- map = new HashMap<>(INITIAL_CAPACITY);
- mapKeysInCurrentTx = new HashSet<>(INITIAL_TX_CAPACITY);
- }
-
- @Override
- public Object getEntry(final Object externalId) {
- return map.get(externalId);
- }
-
- @Override
- public void set(final Vertex vertex, final Object externalId) {
- setId(vertex, externalId);
- }
-
- @Override
- public void setId(final Object vertexId, final Object externalId) {
- map.put(externalId, vertexId);
- mapKeysInCurrentTx.add(externalId);
- }
-
- @Override
- public boolean contains(final Object externalId) {
- return map.containsKey(externalId);
- }
-
- @Override
- public void newTransaction() {
- for (Object id : mapKeysInCurrentTx) {
- Object o = map.get(id);
- assert null != o;
- if (o instanceof Vertex) {
- Vertex v = (Vertex) o;
- map.put(id, v.id());
- }
- }
- mapKeysInCurrentTx.clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/LongIDVertexCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/LongIDVertexCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/LongIDVertexCache.java
deleted file mode 100644
index aef4a72..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/LongIDVertexCache.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-import com.carrotsearch.hppc.LongArrayList;
-import com.carrotsearch.hppc.LongObjectMap;
-import com.carrotsearch.hppc.LongObjectOpenHashMap;
-import com.carrotsearch.hppc.procedures.LongProcedure;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class LongIDVertexCache implements VertexCache {
-
- private final LongObjectMap<Object> map;
- private final LongArrayList mapKeysInCurrentTx;
- private final LongProcedure newTransactionProcedure;
-
- public LongIDVertexCache() {
- map = new LongObjectOpenHashMap<>(AbstractIDVertexCache.INITIAL_CAPACITY);
- mapKeysInCurrentTx = new LongArrayList(AbstractIDVertexCache.INITIAL_TX_CAPACITY);
- newTransactionProcedure = new VertexConverterLP();
- }
-
- private static long getID(final Object externalID) {
- if (!(externalID instanceof Number)) throw new IllegalArgumentException("Number expected.");
- return ((Number) externalID).longValue();
- }
-
- @Override
- public Object getEntry(final Object externalId) {
- return map.get(getID(externalId));
- }
-
- @Override
- public void set(final Vertex vertex, final Object externalId) {
- setId(vertex, externalId);
- }
-
- @Override
- public void setId(final Object vertexId, final Object externalId) {
- final long id = getID(externalId);
- map.put(id, vertexId);
- mapKeysInCurrentTx.add(id);
- }
-
- @Override
- public boolean contains(final Object externalId) {
- return map.containsKey(getID(externalId));
- }
-
- @Override
- public void newTransaction() {
- mapKeysInCurrentTx.forEach(newTransactionProcedure);
- mapKeysInCurrentTx.clear();
- }
-
- /**
- * See {@link LongIDVertexCache#newTransaction()}
- */
- private class VertexConverterLP implements LongProcedure {
- /**
- * Retrieve the Object associated with each long from {@code map}. If it
- * is an {@code instanceof Vertex}, then replace it in the map with
- * {@link Vertex#id()}. Otherwise, do nothing.
- */
- @Override
- public void apply(final long l) {
- final Object o = map.get(l);
- assert null != o;
- if (o instanceof Vertex) {
- map.put(l, ((Vertex) o).id());
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/ObjectIDVertexCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/ObjectIDVertexCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/ObjectIDVertexCache.java
deleted file mode 100644
index 7487430..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/ObjectIDVertexCache.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- */
-public class ObjectIDVertexCache extends AbstractIDVertexCache {
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringCompression.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringCompression.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringCompression.java
deleted file mode 100644
index c862f71..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringCompression.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface StringCompression {
- public static final StringCompression NO_COMPRESSION = input -> input;
-
- public String compress(final String input);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringIDVertexCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringIDVertexCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringIDVertexCache.java
deleted file mode 100644
index 865fd70..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/StringIDVertexCache.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class StringIDVertexCache implements VertexCache {
-
- private static final int INITIAL_CAPACITY = 1000;
- private static final int INITIAL_TX_CAPACITY = 100;
-
- private final Map<String, Object> map;
- private final Set<String> mapKeysInCurrentTx;
- private final StringCompression compression;
-
- public StringIDVertexCache(final StringCompression compression) {
- if (compression == null) throw new IllegalArgumentException("Compression expected.");
- this.compression = compression;
- map = new HashMap<>(INITIAL_CAPACITY);
- mapKeysInCurrentTx = new HashSet<>(INITIAL_TX_CAPACITY);
- }
-
- public StringIDVertexCache() {
- this(StringCompression.NO_COMPRESSION);
- }
-
- @Override
- public Object getEntry(final Object externalId) {
- final String id = compression.compress(externalId.toString());
- return map.get(id);
- }
-
- @Override
- public void set(final Vertex vertex, final Object externalId) {
- setId(vertex, externalId);
- }
-
- @Override
- public void setId(final Object vertexId, final Object externalId) {
- final String id = compression.compress(externalId.toString());
- map.put(id, vertexId);
- mapKeysInCurrentTx.add(id);
- }
-
- @Override
- public boolean contains(final Object externalId) {
- return map.containsKey(compression.compress(externalId.toString()));
- }
-
- @Override
- public void newTransaction() {
- for (String id : mapKeysInCurrentTx) {
- final Object o = map.get(id);
- assert null != o;
- if (o instanceof Vertex) {
- Vertex v = (Vertex) o;
- map.put(id, v.id());
- }
- }
- mapKeysInCurrentTx.clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/URLCompression.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/URLCompression.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/URLCompression.java
deleted file mode 100644
index 4113cc7..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/URLCompression.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class URLCompression implements StringCompression {
-
- private static final String DELIMITER = "$";
-
- private int prefixCounter = 0;
-
- private final Map<String, String> urlPrefix = new HashMap<>();
-
- @Override
- public String compress(final String input) {
- final String[] url = splitURL(input);
- String prefix = urlPrefix.get(url[0]);
- if (prefix == null) {
- //New Prefix
- prefix = Long.toString(prefixCounter, Character.MAX_RADIX) + DELIMITER;
- prefixCounter++;
- urlPrefix.put(url[0], prefix);
- }
- return prefix + url[1];
- }
-
- private final static char[] urlDelimiters = new char[]{'/', '#', ':'};
-
- private static String[] splitURL(final String url) {
- final String[] res = new String[2];
- int pos = -1;
- for (char delimiter : urlDelimiters) {
- int currentpos = url.lastIndexOf(delimiter);
- if (currentpos > pos) pos = currentpos;
- }
- if (pos < 0) {
- res[0] = "";
- res[1] = url;
- } else {
- res[0] = url.substring(0, pos + 1);
- res[1] = url.substring(pos + 1);
- }
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/VertexCache.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/VertexCache.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/VertexCache.java
deleted file mode 100644
index 3ee7626..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/batch/cache/VertexCache.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.util.batch.cache;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-/**
- * @author Matthias Broecheler (http://www.matthiasb.com)
- */
-public interface VertexCache {
- public Object getEntry(final Object externalId);
-
- public void set(final Vertex vertex, final Object externalId);
-
- public void setId(final Object vertexId, final Object externalId);
-
- public boolean contains(final Object externalId);
-
- public void newTransaction();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/benchmark/ProfilingApplication.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/benchmark/ProfilingApplication.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/benchmark/ProfilingApplication.java
index 839a13b..6b96eed 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/benchmark/ProfilingApplication.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/benchmark/ProfilingApplication.java
@@ -24,6 +24,9 @@ import org.apache.tinkerpop.gremlin.driver.Cluster;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -37,13 +40,15 @@ public class ProfilingApplication {
final String host = args.length == 0 ? "localhost" : args[0];
- final int clients = 2;
+ final int clients = 1;
final int requests = 10000;
final Cluster cluster = Cluster.build(host)
- .minConnectionPoolSize(64)
- .maxConnectionPoolSize(128)
+ .minConnectionPoolSize(256)
+ .maxConnectionPoolSize(256)
.nioPoolSize(clients)
- .workerPoolSize(clients * 4).create();
+ .workerPoolSize(clients * 2).create();
+
+ final AtomicInteger tooSlow = new AtomicInteger(0);
// let all the clients fully init before starting to send messages
final CyclicBarrier barrier = new CyclicBarrier(clients);
@@ -61,7 +66,17 @@ public class ProfilingApplication {
System.out.println("Executing at [" + t + "]:" + start);
IntStream.range(0, requests).forEach(i -> {
- client.submitAsync("1+1").thenAccept(r -> r.all()).thenRun(latch::countDown);
+ client.submitAsync("1+1").thenAcceptAsync(r -> {
+ try {
+ r.all().get(100, TimeUnit.MILLISECONDS);
+ } catch (TimeoutException ex) {
+ tooSlow.incrementAndGet();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ } finally {
+ latch.countDown();
+ }
+ });
});
latch.await();
@@ -74,7 +89,7 @@ public class ProfilingApplication {
final long totalSeconds = Math.round(total / 1000000000d);
final long requestCount = requests;
final long reqSec = Math.round(requestCount / totalSeconds);
- System.out.println(String.format("[" + t + "] clients: %s requests: %s time(s): %s req/sec: %s", clients, requestCount, totalSeconds, reqSec));
+ System.out.println(String.format("[" + t + "] clients: %s | requests: %s | time(s): %s | req/sec: %s | too slow: %s", clients, requestCount, totalSeconds, reqSec, tooSlow.get()));
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4150a16d/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
index c9d2228..c78497b 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
@@ -53,7 +53,6 @@ import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
-import org.apache.tinkerpop.gremlin.structure.util.batch.BatchGraph;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedElement;
import org.apache.tinkerpop.gremlin.util.Gremlin;
import org.apache.tinkerpop.gremlin.util.TimeUtil;
@@ -82,7 +81,6 @@ public abstract class AbstractImportCustomizerProvider implements ImportCustomiz
// graph structure
imports.add(Graph.class.getPackage().getName() + DOT_STAR);
imports.add(GraphFactory.class.getPackage().getName() + DOT_STAR);
- imports.add(BatchGraph.class.getPackage().getName() + DOT_STAR);
imports.add(DetachedElement.class.getPackage().getName() + DOT_STAR);
staticImports.add(T.class.getCanonicalName() + DOT_STAR);
staticImports.add(Direction.class.getCanonicalName() + DOT_STAR);