You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/03/03 19:10:35 UTC
[3/8] incubator-tinkerpop git commit: Renamed Gremlin Kryo to simply
Gryo.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
index ae4746a..2b6f728 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
@@ -28,8 +28,7 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.process.Path;
import org.apache.tinkerpop.gremlin.process.util.metric.TraversalMetrics;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoMapper;
-import org.junit.Ignore;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
@@ -54,8 +53,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final Vertex v = g.V(convertToVertexId("marko")).next();
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final Output output = new Output(stream);
@@ -75,8 +74,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdgeAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final Output output = new Output(stream);
@@ -94,8 +93,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePropertyAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final Property p = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final Output output = new Output(stream);
@@ -112,8 +111,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexPropertyAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final VertexProperty vp = g.V(convertToVertexId("marko")).next().property("name");
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final Output output = new Output(stream);
@@ -132,8 +131,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithPropertiesAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final VertexProperty vp = g.V(convertToVertexId("marko")).next().iterators().propertyIterator("location").next();
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
final Output output = new Output(stream);
@@ -156,8 +155,8 @@ public class SerializationTest {
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePathAsDetached() throws Exception {
- final KryoMapper kryoMapper = g.io().kryoMapper().create();
- final Kryo kryo = kryoMapper.createMapper();
+ final GryoMapper gryoMapper = g.io().gryoMapper().create();
+ final Kryo kryo = gryoMapper.createMapper();
final Path p = g.V(convertToVertexId("marko")).as("a").outE().as("b").inV().as("c").path()
.filter(t -> ((Vertex) t.get().objects().get(2)).value("name").equals("lop")).next();
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoResourceAccess.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoResourceAccess.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoResourceAccess.java
new file mode 100644
index 0000000..905da9b
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoResourceAccess.java
@@ -0,0 +1,27 @@
+/*
+ * 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.io.gryo;
+
+/**
+ * Provides path access to test data resources.
+ *
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GryoResourceAccess {
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoResourceAccess.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoResourceAccess.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoResourceAccess.java
deleted file mode 100644
index 8e25b28..0000000
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoResourceAccess.java
+++ /dev/null
@@ -1,27 +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.io.kryo;
-
-/**
- * Provides path access to test data resources.
- *
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class KryoResourceAccess {
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead-vertices.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead-vertices.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead-vertices.kryo
new file mode 100644
index 0000000..2031c24
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead-vertices.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead.kryo
new file mode 100644
index 0000000..97143b1
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/grateful-dead.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic-vertices.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic-vertices.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic-vertices.kryo
new file mode 100644
index 0000000..33f8766
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic-vertices.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic.kryo
new file mode 100644
index 0000000..e2f72c6
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-classic.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew-vertices.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew-vertices.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew-vertices.kryo
new file mode 100644
index 0000000..8289cd8
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew-vertices.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew.kryo
new file mode 100644
index 0000000..3e8ac2d
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-crew.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern-vertices.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern-vertices.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern-vertices.kryo
new file mode 100644
index 0000000..760e4d4
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern-vertices.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern.kryo
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern.kryo b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern.kryo
new file mode 100644
index 0000000..05e6101
Binary files /dev/null and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/tinkerpop-modern.kryo differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead-vertices.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead-vertices.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead-vertices.gio
deleted file mode 100644
index 2031c24..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead-vertices.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio
deleted file mode 100644
index 97143b1..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic-vertices.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic-vertices.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic-vertices.gio
deleted file mode 100644
index 33f8766..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic-vertices.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic.gio
deleted file mode 100644
index e2f72c6..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-classic.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew-vertices.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew-vertices.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew-vertices.gio
deleted file mode 100644
index 8289cd8..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew-vertices.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew.gio
deleted file mode 100644
index 3e8ac2d..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-crew.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern-vertices.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern-vertices.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern-vertices.gio
deleted file mode 100644
index 760e4d4..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern-vertices.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern.gio
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern.gio b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern.gio
deleted file mode 100644
index 05e6101..0000000
Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/kryo/tinkerpop-modern.gio and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
new file mode 100644
index 0000000..21bc5bc
--- /dev/null
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.io.gryo;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GryoMapperTest {
+ @Test
+ public void shouldGetMostRecentVersion() {
+ final GryoMapper.Builder b = GryoMapper.build();
+ assertNotSame(b, GryoMapper.build());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoMapperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoMapperTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoMapperTest.java
deleted file mode 100644
index 4c9e742..0000000
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/kryo/KryoMapperTest.java
+++ /dev/null
@@ -1,34 +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.io.kryo;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotSame;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class KryoMapperTest {
- @Test
- public void shouldGetMostRecentVersion() {
- final KryoMapper.Builder b = KryoMapper.build();
- assertNotSame(b, KryoMapper.build());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/conf/hadoop-gryo.properties
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/conf/hadoop-gryo.properties b/hadoop-gremlin/conf/hadoop-gryo.properties
new file mode 100644
index 0000000..7813ad7
--- /dev/null
+++ b/hadoop-gremlin/conf/hadoop-gryo.properties
@@ -0,0 +1,31 @@
+# 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.
+gremlin.graph=org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph
+gremlin.hadoop.graphInputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat
+gremlin.hadoop.graphOutputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat
+gremlin.hadoop.memoryOutputFormat=org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat
+gremlin.hadoop.deriveMemory=false
+gremlin.hadoop.jarsInDistributedCache=true
+
+gremlin.hadoop.inputLocation=tinkerpop-modern-vertices.kryo
+gremlin.hadoop.outputLocation=output
+#gremlin.vertexProgram=org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram
+#gremlin.traversalVertexProgram.traversalSupplier.type=CLASS
+#gremlin.traversalVertexProgram.traversalSupplier.object=org.apache.tinkerpop.gremlin.hadoop.process.computer.example.TraversalSupplier1
+
+giraph.minWorkers=2
+giraph.maxWorkers=2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/conf/hadoop-kryo.properties
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/conf/hadoop-kryo.properties b/hadoop-gremlin/conf/hadoop-kryo.properties
deleted file mode 100644
index d546da7..0000000
--- a/hadoop-gremlin/conf/hadoop-kryo.properties
+++ /dev/null
@@ -1,31 +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.
-gremlin.graph=org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph
-gremlin.hadoop.graphInputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.KryoInputFormat
-gremlin.hadoop.graphOutputFormat=org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.KryoOutputFormat
-gremlin.hadoop.memoryOutputFormat=org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat
-gremlin.hadoop.deriveMemory=false
-gremlin.hadoop.jarsInDistributedCache=true
-
-gremlin.hadoop.inputLocation=tinkerpop-modern-vertices.gio
-gremlin.hadoop.outputLocation=output
-#gremlin.vertexProgram=org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram
-#gremlin.traversalVertexProgram.traversalSupplier.type=CLASS
-#gremlin.traversalVertexProgram.traversalSupplier.object=org.apache.tinkerpop.gremlin.hadoop.process.computer.example.TraversalSupplier1
-
-giraph.minWorkers=2
-giraph.maxWorkers=2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
index 2609ddf..c91d445 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPlugin.java
@@ -35,7 +35,7 @@ import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph;
import org.apache.tinkerpop.gremlin.hadoop.structure.hdfs.HDFSTools;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson.GraphSONInputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.KryoInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptInputFormat;
import org.apache.tinkerpop.gremlin.hadoop.structure.util.ConfUtil;
@@ -62,7 +62,7 @@ public class HadoopGremlinPlugin extends AbstractGremlinPlugin {
add(IMPORT_SPACE + HadoopConfiguration.class.getPackage().getName() + DOT_STAR);
add(IMPORT_SPACE + ConfUtil.class.getPackage().getName() + DOT_STAR);
add(IMPORT_SPACE + VertexWritable.class.getPackage().getName() + DOT_STAR);
- add(IMPORT_SPACE + KryoInputFormat.class.getPackage().getName() + DOT_STAR);
+ add(IMPORT_SPACE + GryoInputFormat.class.getPackage().getName() + DOT_STAR);
add(IMPORT_SPACE + GraphSONInputFormat.class.getPackage().getName() + DOT_STAR);
add(IMPORT_SPACE + ScriptInputFormat.class.getPackage().getName() + DOT_STAR);
add(IMPORT_SPACE + HDFSTools.class.getPackage().getName() + DOT_STAR);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
index f392c4c..00e1adf 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/GiraphComputeVertex.java
@@ -27,8 +27,8 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoReader;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoWriter;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.strategy.StrategyVertex;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
@@ -57,8 +57,8 @@ public final class GiraphComputeVertex extends Vertex<LongWritable, Text, NullWr
private static final String VERTEX_ID = Graph.Hidden.hide("giraph.gremlin.vertexId");
private TinkerVertex tinkerVertex;
private StrategyVertex wrappedVertex;
- private static KryoWriter KRYO_WRITER = KryoWriter.build().create();
- private static KryoReader KRYO_READER = KryoReader.build().create();
+ private static GryoWriter KRYO_WRITER = GryoWriter.build().create();
+ private static GryoReader KRYO_READER = GryoReader.build().create();
public GiraphComputeVertex() {
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/RuleWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/RuleWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/RuleWritable.java
index d69edaf..ed309e7 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/RuleWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/giraph/RuleWritable.java
@@ -78,7 +78,7 @@ public class RuleWritable implements Writable {
bytes[i] = input.readByte();
}
final Input in = new Input(new ByteArrayInputStream(bytes));
- this.object = Constants.KRYO.readClassAndObject(in);
+ this.object = Constants.GRYO.readClassAndObject(in);
in.close();*/
}
@@ -92,7 +92,7 @@ public class RuleWritable implements Writable {
/*
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Output out = new Output(outputStream);
- Constants.KRYO.writeClassAndObject(out, this.object);
+ Constants.GRYO.writeClassAndObject(out, this.object);
out.flush();
WritableUtils.writeVInt(output, this.rule.ordinal());
WritableUtils.writeVInt(output, outputStream.toByteArray().length);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
index 55a78a0..1d5cd69 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
@@ -60,7 +60,7 @@ public final class ObjectWritable<T> implements WritableComparable<ObjectWritabl
} catch (final ClassNotFoundException e) {
throw new IOException(e.getMessage(), e);
}
- //this.t = (T) Constants.KRYO.readClassAndObject(new Input(new ByteArrayInputStream(WritableUtils.readCompressedByteArray(input))));
+ //this.t = (T) Constants.GRYO.readClassAndObject(new Input(new ByteArrayInputStream(WritableUtils.readCompressedByteArray(input))));
}
@Override
@@ -68,7 +68,7 @@ public final class ObjectWritable<T> implements WritableComparable<ObjectWritabl
WritableUtils.writeCompressedByteArray(output, Serializer.serializeObject(this.t));
/*final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final Output out = new Output(outputStream);
- Constants.KRYO.writeClassAndObject(out, this.t);
+ Constants.GRYO.writeClassAndObject(out, this.t);
out.flush();
WritableUtils.writeCompressedByteArray(output, outputStream.toByteArray());
out.close();*/
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
index 09d26ce..a42060c 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
@@ -21,8 +21,8 @@ package org.apache.tinkerpop.gremlin.hadoop.structure.io;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoReader;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoWriter;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
@@ -42,8 +42,8 @@ import java.io.IOException;
public final class VertexWritable<V extends Vertex> implements Writable {
private Vertex vertex;
- private static final KryoWriter KRYO_WRITER = KryoWriter.build().create();
- private static final KryoReader KRYO_READER = KryoReader.build().create();
+ private static final GryoWriter KRYO_WRITER = GryoWriter.build().create();
+ private static final GryoReader KRYO_READER = GryoReader.build().create();
public VertexWritable(final Vertex vertex) {
this.vertex = vertex;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoInputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoInputFormat.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoInputFormat.java
new file mode 100644
index 0000000..1fc2ecd
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoInputFormat.java
@@ -0,0 +1,63 @@
+/*
+ * 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.hadoop.structure.io.gryo;
+
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.hadoop.conf.Configurable;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.compress.CompressionCodecFactory;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+
+import java.io.IOException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GryoInputFormat extends FileInputFormat<NullWritable, VertexWritable> implements Configurable {
+
+ private Configuration config;
+
+ @Override
+ public RecordReader<NullWritable, VertexWritable> createRecordReader(final InputSplit split, final TaskAttemptContext context) throws IOException, InterruptedException {
+ final RecordReader<NullWritable, VertexWritable> reader = new GryoRecordReader();
+ reader.initialize(split, context);
+ return reader;
+ }
+
+ @Override
+ protected boolean isSplitable(final JobContext context, final Path file) {
+ return null == new CompressionCodecFactory(context.getConfiguration()).getCodec(file);
+ }
+
+ @Override
+ public void setConf(final Configuration config) {
+ this.config = config;
+ }
+
+ @Override
+ public Configuration getConf() {
+ return this.config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoOutputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoOutputFormat.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoOutputFormat.java
new file mode 100644
index 0000000..7a214f8
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoOutputFormat.java
@@ -0,0 +1,43 @@
+/*
+ * 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.hadoop.structure.io.gryo;
+
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.CommonFileOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GryoOutputFormat extends CommonFileOutputFormat {
+
+ @Override
+ public RecordWriter<NullWritable, VertexWritable> getRecordWriter(final TaskAttemptContext job) throws IOException, InterruptedException {
+ return new GryoRecordWriter(getDataOuputStream(job));
+ }
+
+ public RecordWriter<NullWritable, VertexWritable> getRecordWriter(final TaskAttemptContext job, final DataOutputStream outputStream) throws IOException, InterruptedException {
+ return new GryoRecordWriter(outputStream);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
new file mode 100644
index 0000000..d120a6f
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordReader.java
@@ -0,0 +1,113 @@
+/*
+ * 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.hadoop.structure.io.gryo;
+
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.compress.CompressionCodecFactory;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+import java.io.IOException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GryoRecordReader extends RecordReader<NullWritable, VertexWritable> {
+
+ private VertexStreamIterator vertexStreamIterator;
+ private FSDataInputStream inputStream;
+
+ private static final byte[] PATTERN = GryoMapper.build().create().getVersionedHeader();
+
+ public GryoRecordReader() {
+ }
+
+ @Override
+ public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException {
+ final FileSplit split = (FileSplit) genericSplit;
+ final Configuration job = context.getConfiguration();
+ long start = split.getStart();
+ final Path file = split.getPath();
+ if (null != new CompressionCodecFactory(job).getCodec(file)) {
+ throw new IllegalStateException("Compression is not supported for the (binary) Gryo format");
+ }
+ // open the file and seek to the start of the split
+ this.inputStream = file.getFileSystem(job).open(split.getPath());
+ this.inputStream.seek(start);
+ final long newStart = seekToHeader(this.inputStream, start);
+ this.vertexStreamIterator = new VertexStreamIterator(this.inputStream, split.getLength() - (newStart - start));
+ }
+
+ private static long seekToHeader(final FSDataInputStream inputStream, final long start) throws IOException {
+ long nextStart = start;
+ final byte[] buffer = new byte[32];
+ while (true) {
+ if ((buffer[0] = PATTERN[0]) == inputStream.readByte()) {
+ inputStream.read(nextStart + 1, buffer, 1, 31);
+ if (patternMatch(buffer)) {
+ inputStream.seek(nextStart);
+ return nextStart;
+ }
+ } else {
+ nextStart = nextStart + 1;
+ inputStream.seek(nextStart);
+ }
+ }
+ }
+
+ private static boolean patternMatch(final byte[] bytes) {
+ for (int i = 0; i < 31; i++) {
+ if (bytes[i] != PATTERN[i])
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean nextKeyValue() throws IOException {
+ return this.vertexStreamIterator.hasNext();
+ }
+
+ @Override
+ public NullWritable getCurrentKey() {
+ return NullWritable.get();
+ }
+
+ @Override
+ public VertexWritable getCurrentValue() {
+ return this.vertexStreamIterator.next();
+ }
+
+ @Override
+ public float getProgress() throws IOException {
+ return this.vertexStreamIterator.getProgress();
+ }
+
+ @Override
+ public synchronized void close() throws IOException {
+ this.inputStream.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordWriter.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordWriter.java
new file mode 100644
index 0000000..9af8597
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/GryoRecordWriter.java
@@ -0,0 +1,54 @@
+/*
+ * 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.hadoop.structure.io.gryo;
+
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.RecordWriter;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GryoRecordWriter extends RecordWriter<NullWritable, VertexWritable> {
+
+ private final DataOutputStream out;
+ private static final GryoWriter GRYO_WRITER = GryoWriter.build().create();
+
+ public GryoRecordWriter(final DataOutputStream out) {
+ this.out = out;
+ }
+
+ @Override
+ public void write(final NullWritable key, final VertexWritable vertex) throws IOException {
+ if (null != vertex) {
+ GRYO_WRITER.writeVertex(out, vertex.get(), Direction.BOTH);
+ }
+ }
+
+ @Override
+ public synchronized void close(TaskAttemptContext context) throws IOException {
+ this.out.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/VertexStreamIterator.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/VertexStreamIterator.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/VertexStreamIterator.java
new file mode 100644
index 0000000..b32a944
--- /dev/null
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/gryo/VertexStreamIterator.java
@@ -0,0 +1,147 @@
+/*
+ * 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.hadoop.structure.io.gryo;
+
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+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.gryo.GryoReader;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.function.Function;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class VertexStreamIterator implements Iterator<VertexWritable> {
+
+ // this is VertexTerminator's long terminal 4185403236219066774L as an array of positive int's
+ private static final int[] TERMINATOR = new int[]{58, 21, 138, 17, 112, 155, 153, 150};
+
+ private static int BUFLEN = TERMINATOR.length;
+
+ private final InputStream inputStream;
+ private static final GryoReader GRYO_READER = GryoReader.build().create();
+ private final ByteArrayOutputStream output = new ByteArrayOutputStream();
+ private final int[] buffer = new int[BUFLEN];
+
+ private int len;
+ private int currentByte;
+ private Vertex currentVertex;
+ private final long maxLength;
+ private long currentLength = 0;
+
+ public VertexStreamIterator(final InputStream inputStream, final long maxLength) {
+ this.inputStream = inputStream;
+ this.maxLength = maxLength;
+ }
+
+ public float getProgress() {
+ if (0 == this.currentLength || 0 == this.maxLength)
+ return 0.0f;
+ else if (this.currentLength >= this.maxLength || this.maxLength == Long.MAX_VALUE)
+ return 1.0f;
+ else
+ return (float) this.currentLength / (float) this.maxLength;
+
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (this.currentLength >= this.maxLength) // gone beyond the split boundary
+ return false;
+ if (null != this.currentVertex)
+ return true;
+ else if (-1 == this.currentByte)
+ return false;
+ else {
+ try {
+ this.currentVertex = advanceToNextVertex();
+ return null != this.currentVertex;
+ } catch (final IOException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public VertexWritable next() {
+ try {
+ if (null == this.currentVertex) {
+ if (this.hasNext())
+ return new VertexWritable(this.currentVertex);
+ else
+ throw new IllegalStateException("There are no more vertices in this split");
+ } else
+ return new VertexWritable(this.currentVertex);
+ } finally {
+ this.currentVertex = null;
+ this.len = 0;
+ this.output.reset();
+ }
+ }
+
+ private final Vertex advanceToNextVertex() throws IOException {
+ while (true) {
+ this.currentByte = this.inputStream.read();
+ this.currentLength++;
+ if (-1 == this.currentByte) {
+ if (this.len > 0) {
+ throw new IllegalStateException("Remainder of stream exhausted without matching a vertex");
+ } else {
+ return null;
+ }
+ }
+
+ if (this.len >= BUFLEN)
+ this.output.write(this.buffer[this.len % BUFLEN]);
+
+ this.buffer[this.len % BUFLEN] = this.currentByte;
+ this.len++;
+
+ if (this.len > BUFLEN) {
+ boolean terminated = true;
+ for (int i = 0; i < BUFLEN; i++) {
+ if (this.buffer[(this.len + i) % BUFLEN] != TERMINATOR[i]) {
+ terminated = false;
+ break;
+ }
+ }
+
+ if (terminated) {
+ final Graph gLocal = TinkerGraph.open();
+ final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> DetachedVertex.addTo(gLocal, detachedVertex);
+ final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> DetachedEdge.addTo(gLocal, detachedEdge);
+ try (InputStream in = new ByteArrayInputStream(this.output.toByteArray())) {
+ return GRYO_READER.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker);
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoInputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoInputFormat.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoInputFormat.java
deleted file mode 100644
index cad79f6..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoInputFormat.java
+++ /dev/null
@@ -1,63 +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.hadoop.structure.io.kryo;
-
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.hadoop.conf.Configurable;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.io.compress.CompressionCodecFactory;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.JobContext;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
-
-import java.io.IOException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class KryoInputFormat extends FileInputFormat<NullWritable, VertexWritable> implements Configurable {
-
- private Configuration config;
-
- @Override
- public RecordReader<NullWritable, VertexWritable> createRecordReader(final InputSplit split, final TaskAttemptContext context) throws IOException, InterruptedException {
- RecordReader<NullWritable, VertexWritable> reader = new KryoRecordReader();
- reader.initialize(split, context);
- return reader;
- }
-
- @Override
- protected boolean isSplitable(final JobContext context, final Path file) {
- return null == new CompressionCodecFactory(context.getConfiguration()).getCodec(file);
- }
-
- @Override
- public void setConf(final Configuration config) {
- this.config = config;
- }
-
- @Override
- public Configuration getConf() {
- return this.config;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoOutputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoOutputFormat.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoOutputFormat.java
deleted file mode 100644
index 8b26a7c..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoOutputFormat.java
+++ /dev/null
@@ -1,43 +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.hadoop.structure.io.kryo;
-
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.CommonFileOutputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.mapreduce.RecordWriter;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class KryoOutputFormat extends CommonFileOutputFormat {
-
- @Override
- public RecordWriter<NullWritable, VertexWritable> getRecordWriter(final TaskAttemptContext job) throws IOException, InterruptedException {
- return new KryoRecordWriter(getDataOuputStream(job));
- }
-
- public RecordWriter<NullWritable, VertexWritable> getRecordWriter(final TaskAttemptContext job, final DataOutputStream outputStream) throws IOException, InterruptedException {
- return new KryoRecordWriter(outputStream);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordReader.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordReader.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordReader.java
deleted file mode 100644
index 7ed405d..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordReader.java
+++ /dev/null
@@ -1,113 +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.hadoop.structure.io.kryo;
-
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoMapper;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.io.compress.CompressionCodecFactory;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.lib.input.FileSplit;
-
-import java.io.IOException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class KryoRecordReader extends RecordReader<NullWritable, VertexWritable> {
-
- private VertexStreamIterator vertexStreamIterator;
- private FSDataInputStream inputStream;
-
- private static final byte[] PATTERN = KryoMapper.build().create().getVersionedHeader();
-
- public KryoRecordReader() {
- }
-
- @Override
- public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException {
- final FileSplit split = (FileSplit) genericSplit;
- final Configuration job = context.getConfiguration();
- long start = split.getStart();
- final Path file = split.getPath();
- if (null != new CompressionCodecFactory(job).getCodec(file)) {
- throw new IllegalStateException("Compression is not supported for the (binary) Gremlin Kryo format");
- }
- // open the file and seek to the start of the split
- this.inputStream = file.getFileSystem(job).open(split.getPath());
- this.inputStream.seek(start);
- final long newStart = seekToHeader(this.inputStream, start);
- this.vertexStreamIterator = new VertexStreamIterator(this.inputStream, split.getLength() - (newStart - start));
- }
-
- private static long seekToHeader(final FSDataInputStream inputStream, final long start) throws IOException {
- long nextStart = start;
- final byte[] buffer = new byte[32];
- while (true) {
- if ((buffer[0] = PATTERN[0]) == inputStream.readByte()) {
- inputStream.read(nextStart + 1, buffer, 1, 31);
- if (patternMatch(buffer)) {
- inputStream.seek(nextStart);
- return nextStart;
- }
- } else {
- nextStart = nextStart + 1;
- inputStream.seek(nextStart);
- }
- }
- }
-
- private static boolean patternMatch(final byte[] bytes) {
- for (int i = 0; i < 31; i++) {
- if (bytes[i] != PATTERN[i])
- return false;
- }
- return true;
- }
-
- @Override
- public boolean nextKeyValue() throws IOException {
- return this.vertexStreamIterator.hasNext();
- }
-
- @Override
- public NullWritable getCurrentKey() {
- return NullWritable.get();
- }
-
- @Override
- public VertexWritable getCurrentValue() {
- return this.vertexStreamIterator.next();
- }
-
- @Override
- public float getProgress() throws IOException {
- return this.vertexStreamIterator.getProgress();
- }
-
- @Override
- public synchronized void close() throws IOException {
- this.inputStream.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordWriter.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordWriter.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordWriter.java
deleted file mode 100644
index c9d1b8f..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/KryoRecordWriter.java
+++ /dev/null
@@ -1,54 +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.hadoop.structure.io.kryo;
-
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoWriter;
-import org.apache.hadoop.io.NullWritable;
-import org.apache.hadoop.mapreduce.RecordWriter;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class KryoRecordWriter extends RecordWriter<NullWritable, VertexWritable> {
-
- private final DataOutputStream out;
- private static final KryoWriter KRYO_WRITER = KryoWriter.build().create();
-
- public KryoRecordWriter(final DataOutputStream out) {
- this.out = out;
- }
-
- @Override
- public void write(final NullWritable key, final VertexWritable vertex) throws IOException {
- if (null != vertex) {
- KRYO_WRITER.writeVertex(out, vertex.get(), Direction.BOTH);
- }
- }
-
- @Override
- public synchronized void close(TaskAttemptContext context) throws IOException {
- this.out.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/VertexStreamIterator.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/VertexStreamIterator.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/VertexStreamIterator.java
deleted file mode 100644
index 6784d92..0000000
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/kryo/VertexStreamIterator.java
+++ /dev/null
@@ -1,147 +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.hadoop.structure.io.kryo;
-
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
-import org.apache.tinkerpop.gremlin.structure.Direction;
-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.kryo.KryoReader;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.function.Function;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class VertexStreamIterator implements Iterator<VertexWritable> {
-
- // this is VertexTerminator's long terminal 4185403236219066774L as an array of positive int's
- private static final int[] TERMINATOR = new int[]{58, 21, 138, 17, 112, 155, 153, 150};
-
- private static int BUFLEN = TERMINATOR.length;
-
- private final InputStream inputStream;
- private static final KryoReader KRYO_READER = KryoReader.build().create();
- private final ByteArrayOutputStream output = new ByteArrayOutputStream();
- private final int[] buffer = new int[BUFLEN];
-
- private int len;
- private int currentByte;
- private Vertex currentVertex;
- private final long maxLength;
- private long currentLength = 0;
-
- public VertexStreamIterator(final InputStream inputStream, final long maxLength) {
- this.inputStream = inputStream;
- this.maxLength = maxLength;
- }
-
- public float getProgress() {
- if (0 == this.currentLength || 0 == this.maxLength)
- return 0.0f;
- else if (this.currentLength >= this.maxLength || this.maxLength == Long.MAX_VALUE)
- return 1.0f;
- else
- return (float) this.currentLength / (float) this.maxLength;
-
- }
-
- @Override
- public boolean hasNext() {
- if (this.currentLength >= this.maxLength) // gone beyond the split boundary
- return false;
- if (null != this.currentVertex)
- return true;
- else if (-1 == this.currentByte)
- return false;
- else {
- try {
- this.currentVertex = advanceToNextVertex();
- return null != this.currentVertex;
- } catch (final IOException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
- }
-
- @Override
- public VertexWritable next() {
- try {
- if (null == this.currentVertex) {
- if (this.hasNext())
- return new VertexWritable(this.currentVertex);
- else
- throw new IllegalStateException("There are no more vertices in this split");
- } else
- return new VertexWritable(this.currentVertex);
- } finally {
- this.currentVertex = null;
- this.len = 0;
- this.output.reset();
- }
- }
-
- private final Vertex advanceToNextVertex() throws IOException {
- while (true) {
- this.currentByte = this.inputStream.read();
- this.currentLength++;
- if (-1 == this.currentByte) {
- if (this.len > 0) {
- throw new IllegalStateException("Remainder of stream exhausted without matching a vertex");
- } else {
- return null;
- }
- }
-
- if (this.len >= BUFLEN)
- this.output.write(this.buffer[this.len % BUFLEN]);
-
- this.buffer[this.len % BUFLEN] = this.currentByte;
- this.len++;
-
- if (this.len > BUFLEN) {
- boolean terminated = true;
- for (int i = 0; i < BUFLEN; i++) {
- if (this.buffer[(this.len + i) % BUFLEN] != TERMINATOR[i]) {
- terminated = false;
- break;
- }
- }
-
- if (terminated) {
- final Graph gLocal = TinkerGraph.open();
- final Function<DetachedVertex, Vertex> vertexMaker = detachedVertex -> DetachedVertex.addTo(gLocal, detachedVertex);
- final Function<DetachedEdge, Edge> edgeMaker = detachedEdge -> DetachedEdge.addTo(gLocal, detachedEdge);
- try (InputStream in = new ByteArrayInputStream(this.output.toByteArray())) {
- return KRYO_READER.readVertex(in, Direction.BOTH, vertexMaker, edgeMaker);
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
index 7153d8f..300def1 100644
--- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
@@ -32,11 +32,11 @@ import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraphVariables;
import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopProperty;
import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopVertex;
import org.apache.tinkerpop.gremlin.hadoop.structure.HadoopVertexProperty;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.KryoInputFormat;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.KryoOutputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoOutputFormat;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONResourceAccess;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoResourceAccess;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoResourceAccess;
import org.apache.tinkerpop.gremlin.structure.io.script.ScriptResourceAccess;
import java.util.Arrays;
@@ -67,12 +67,12 @@ public class HadoopGraphProvider extends AbstractGraphProvider {
static {
try {
final List<String> kryoResources = Arrays.asList(
- "tinkerpop-modern-vertices.gio",
- "grateful-dead-vertices.gio",
- "tinkerpop-classic-vertices.gio",
- "tinkerpop-crew-vertices.gio");
+ "tinkerpop-modern-vertices.kryo",
+ "grateful-dead-vertices.kryo",
+ "tinkerpop-classic-vertices.kryo",
+ "tinkerpop-crew-vertices.kryo");
for (final String fileName : kryoResources) {
- PATHS.put(fileName, TestHelper.generateTempFileFromResource(KryoResourceAccess.class, fileName, "").getAbsolutePath());
+ PATHS.put(fileName, TestHelper.generateTempFileFromResource(GryoResourceAccess.class, fileName, "").getAbsolutePath());
}
final List<String> graphsonResources = Arrays.asList(
@@ -97,8 +97,8 @@ public class HadoopGraphProvider extends AbstractGraphProvider {
public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName) {
return new HashMap<String, Object>() {{
put("gremlin.graph", HadoopGraph.class.getName());
- put(Constants.GREMLIN_HADOOP_GRAPH_INPUT_FORMAT, KryoInputFormat.class.getCanonicalName());
- put(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT, KryoOutputFormat.class.getCanonicalName());
+ put(Constants.GREMLIN_HADOOP_GRAPH_INPUT_FORMAT, GryoInputFormat.class.getCanonicalName());
+ put(Constants.GREMLIN_HADOOP_GRAPH_OUTPUT_FORMAT, GryoOutputFormat.class.getCanonicalName());
//put(Constants.GREMLIN_GIRAPH_MEMORY_OUTPUT_FORMAT_CLASS, TextOutputFormat.class.getCanonicalName());
put(Constants.GREMLIN_HADOOP_MEMORY_OUTPUT_FORMAT, SequenceFileOutputFormat.class.getCanonicalName());
put(GiraphConstants.MIN_WORKERS, 1);
@@ -109,7 +109,7 @@ public class HadoopGraphProvider extends AbstractGraphProvider {
put("giraph.zkServerPort", "2181"); // you must have a local zookeeper running on this port
put("giraph.nettyServerUseExecutionHandler", false); // this prevents so many integration tests running out of threads
put("giraph.nettyClientUseExecutionHandler", false); // this prevents so many integration tests running out of threads
- //put(Constants.GREMLIN_GIRAPH_INPUT_LOCATION, KryoInputFormat.class.getResource("tinkerpop-classic-vertices.gio").getPath());
+ //put(Constants.GREMLIN_GIRAPH_INPUT_LOCATION, GryoInputFormat.class.getResource("tinkerpop-classic-vertices.kryo").getPath());
put(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, "hadoop-gremlin/target/test-output");
put(Constants.GREMLIN_HADOOP_DERIVE_MEMORY, true);
put(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, false);
@@ -135,13 +135,13 @@ public class HadoopGraphProvider extends AbstractGraphProvider {
public void loadGraphDataViaHadoopConfig(final Graph g, final LoadGraphWith.GraphData graphData) {
if (graphData.equals(LoadGraphWith.GraphData.GRATEFUL)) {
- ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("grateful-dead-vertices.gio"));
+ ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("grateful-dead-vertices.kryo"));
} else if (graphData.equals(LoadGraphWith.GraphData.MODERN)) {
- ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-modern-vertices.gio"));
+ ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-modern-vertices.kryo"));
} else if (graphData.equals(LoadGraphWith.GraphData.CLASSIC)) {
- ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-classic-vertices.gio"));
+ ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-classic-vertices.kryo"));
} else if (graphData.equals(LoadGraphWith.GraphData.CREW)) {
- ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-crew-vertices.gio"));
+ ((HadoopGraph) g).configuration().setInputLocation(PATHS.get("tinkerpop-crew-vertices.kryo"));
} else {
throw new RuntimeException("Could not load graph with " + graphData);
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/929a2889/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/VertexStreamIteratorTest.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/VertexStreamIteratorTest.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/VertexStreamIteratorTest.java
index 138e4a0..1cedfd9 100644
--- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/VertexStreamIteratorTest.java
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/VertexStreamIteratorTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.tinkerpop.gremlin.hadoop.structure.io.graphson;
-import org.apache.tinkerpop.gremlin.hadoop.structure.io.kryo.VertexStreamIterator;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.VertexStreamIterator;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.kryo.KryoWriter;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import org.junit.Test;
@@ -42,7 +42,7 @@ public class VertexStreamIteratorTest {
Graph g = TinkerFactory.createClassic();
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- final KryoWriter writer = KryoWriter.build().create();
+ final GryoWriter writer = GryoWriter.build().create();
writer.writeVertices(os, g.V(), Direction.BOTH);
final AtomicInteger called = new AtomicInteger(0);
VertexStreamIterator vsi = new VertexStreamIterator(new ByteArrayInputStream(os.toByteArray()), Long.MAX_VALUE);