You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/08/30 14:48:57 UTC

[2/3] incubator-tinkerpop git commit: Renamed DefaultBulkLoader to IncrementalBulkLoader as requested by @okram.

Renamed DefaultBulkLoader to IncrementalBulkLoader as requested by @okram.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/9cc985da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/9cc985da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/9cc985da

Branch: refs/heads/blvp
Commit: 9cc985da58ac17eda88f4347310f03d8a69883bc
Parents: 9f467c4
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Sun Aug 30 14:46:31 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Sun Aug 30 14:46:31 2015 +0200

----------------------------------------------------------------------
 .../computer/bulkloading/DefaultBulkLoader.java | 153 -------------------
 .../bulkloading/IncrementalBulkLoader.java      | 153 +++++++++++++++++++
 2 files changed, 153 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9cc985da/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/DefaultBulkLoader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/DefaultBulkLoader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/DefaultBulkLoader.java
deleted file mode 100644
index 75d3494..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/DefaultBulkLoader.java
+++ /dev/null
@@ -1,153 +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.process.computer.bulkloading;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-
-import java.util.Iterator;
-
-/**
- * @author Daniel Kuppitz (http://gremlin.guru)
- */
-public class DefaultBulkLoader implements BulkLoader {
-
-    public final static String USER_SUPPLIED_IDS_CFG_KEY = "userSuppliedIds";
-    public final static String KEEP_ORIGINAL_IDS_CFG_KEY = "keepOriginalIds";
-
-    private String bulkLoaderVertexId = BulkLoaderVertexProgram.DEFAULT_BULK_LOADER_VERTEX_ID;
-    private boolean keepOriginalIds = true;
-    private boolean userSuppliedIds = false;
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
-        final Iterator<Vertex> iterator = useUserSuppliedIds()
-                ? graph.vertices(vertex.id())
-                : g.V().has(vertex.label(), getVertexIdProperty(), vertex.id());
-        return iterator.hasNext()
-                ? iterator.next()
-                : useUserSuppliedIds()
-                ? graph.addVertex(T.id, vertex.id(), T.label, vertex.label())
-                : graph.addVertex(T.label, vertex.label(), getVertexIdProperty(), vertex.id());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Edge getOrCreateEdge(final Edge edge, final Vertex outVertex, final Vertex inVertex, final Graph graph, final GraphTraversalSource g) {
-        final Edge e;
-        final Traversal<Vertex, Edge> t = g.V(outVertex).outE(edge.label()).filter(__.inV().is(inVertex));
-        if (t.hasNext()) {
-            e = t.next();
-            edge.properties().forEachRemaining(property -> {
-                final Property<?> existing = e.property(property.key());
-                if (!existing.isPresent() || !existing.value().equals(property.value())) {
-                    e.property(property.key(), property.value());
-                }
-            });
-        } else {
-            e = outVertex.addEdge(edge.label(), inVertex);
-            edge.properties().forEachRemaining(property -> e.property(property.key(), property.value()));
-        }
-        return e;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public VertexProperty getOrCreateVertexProperty(final VertexProperty<?> property, final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
-        final VertexProperty<?> vp;
-        final VertexProperty<?> existing = vertex.property(property.key());
-        if (!existing.isPresent() || !existing.value().equals(property.value())) {
-            vp = vertex.property(property.key(), property.value());
-        } else {
-            vp = existing;
-        }
-        property.properties().forEachRemaining(metaProperty -> {
-            final Property<?> existing2 = vp.property(metaProperty.key());
-            if (!existing2.isPresent() || !existing2.value().equals(metaProperty.value())) {
-                vp.property(metaProperty.key(), metaProperty.value());
-            }
-        });
-        return vp;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Vertex getVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
-        return useUserSuppliedIds()
-                ? getVertexById(vertex.id(), graph, g)
-                : g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id()).next();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean useUserSuppliedIds() {
-        return userSuppliedIds;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean keepOriginalIds() {
-        return keepOriginalIds;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public String getVertexIdProperty() {
-        return bulkLoaderVertexId;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void configure(final Configuration configuration) {
-        if (configuration.containsKey(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY)) {
-            bulkLoaderVertexId = configuration.getString(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY);
-        }
-        if (configuration.containsKey(USER_SUPPLIED_IDS_CFG_KEY)) {
-            userSuppliedIds = configuration.getBoolean(USER_SUPPLIED_IDS_CFG_KEY);
-        }
-        if (configuration.containsKey(KEEP_ORIGINAL_IDS_CFG_KEY)) {
-            keepOriginalIds = configuration.getBoolean(KEEP_ORIGINAL_IDS_CFG_KEY);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9cc985da/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/IncrementalBulkLoader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/IncrementalBulkLoader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/IncrementalBulkLoader.java
new file mode 100644
index 0000000..2177d0b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/IncrementalBulkLoader.java
@@ -0,0 +1,153 @@
+/*
+ * 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.process.computer.bulkloading;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+
+import java.util.Iterator;
+
+/**
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ */
+public class IncrementalBulkLoader implements BulkLoader {
+
+    public final static String USER_SUPPLIED_IDS_CFG_KEY = "userSuppliedIds";
+    public final static String KEEP_ORIGINAL_IDS_CFG_KEY = "keepOriginalIds";
+
+    private String bulkLoaderVertexId = BulkLoaderVertexProgram.DEFAULT_BULK_LOADER_VERTEX_ID;
+    private boolean keepOriginalIds = true;
+    private boolean userSuppliedIds = false;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Vertex getOrCreateVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
+        final Iterator<Vertex> iterator = useUserSuppliedIds()
+                ? graph.vertices(vertex.id())
+                : g.V().has(vertex.label(), getVertexIdProperty(), vertex.id());
+        return iterator.hasNext()
+                ? iterator.next()
+                : useUserSuppliedIds()
+                ? graph.addVertex(T.id, vertex.id(), T.label, vertex.label())
+                : graph.addVertex(T.label, vertex.label(), getVertexIdProperty(), vertex.id());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Edge getOrCreateEdge(final Edge edge, final Vertex outVertex, final Vertex inVertex, final Graph graph, final GraphTraversalSource g) {
+        final Edge e;
+        final Traversal<Vertex, Edge> t = g.V(outVertex).outE(edge.label()).filter(__.inV().is(inVertex));
+        if (t.hasNext()) {
+            e = t.next();
+            edge.properties().forEachRemaining(property -> {
+                final Property<?> existing = e.property(property.key());
+                if (!existing.isPresent() || !existing.value().equals(property.value())) {
+                    e.property(property.key(), property.value());
+                }
+            });
+        } else {
+            e = outVertex.addEdge(edge.label(), inVertex);
+            edge.properties().forEachRemaining(property -> e.property(property.key(), property.value()));
+        }
+        return e;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public VertexProperty getOrCreateVertexProperty(final VertexProperty<?> property, final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
+        final VertexProperty<?> vp;
+        final VertexProperty<?> existing = vertex.property(property.key());
+        if (!existing.isPresent() || !existing.value().equals(property.value())) {
+            vp = vertex.property(property.key(), property.value());
+        } else {
+            vp = existing;
+        }
+        property.properties().forEachRemaining(metaProperty -> {
+            final Property<?> existing2 = vp.property(metaProperty.key());
+            if (!existing2.isPresent() || !existing2.value().equals(metaProperty.value())) {
+                vp.property(metaProperty.key(), metaProperty.value());
+            }
+        });
+        return vp;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Vertex getVertex(final Vertex vertex, final Graph graph, final GraphTraversalSource g) {
+        return useUserSuppliedIds()
+                ? getVertexById(vertex.id(), graph, g)
+                : g.V().has(vertex.label(), bulkLoaderVertexId, vertex.id()).next();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean useUserSuppliedIds() {
+        return userSuppliedIds;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean keepOriginalIds() {
+        return keepOriginalIds;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getVertexIdProperty() {
+        return bulkLoaderVertexId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void configure(final Configuration configuration) {
+        if (configuration.containsKey(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY)) {
+            bulkLoaderVertexId = configuration.getString(BulkLoaderVertexProgram.BULK_LOADER_VERTEX_ID_CFG_KEY);
+        }
+        if (configuration.containsKey(USER_SUPPLIED_IDS_CFG_KEY)) {
+            userSuppliedIds = configuration.getBoolean(USER_SUPPLIED_IDS_CFG_KEY);
+        }
+        if (configuration.containsKey(KEEP_ORIGINAL_IDS_CFG_KEY)) {
+            keepOriginalIds = configuration.getBoolean(KEEP_ORIGINAL_IDS_CFG_KEY);
+        }
+    }
+}