You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2022/10/19 06:59:34 UTC

[GitHub] [tinkerpop] ministat opened a new pull request, #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

ministat opened a new pull request, #1835:
URL: https://github.com/apache/tinkerpop/pull/1835

   Hadoop GraphSONRecordReader and GraphSONRecordWriter does not support 'java.lang.Byte' type, which is supported by both GraphSONXModuleV2d0 and GraphSONXModuleV3d0, but both of them are custom modules and excluded by default.
   
   This fix adds GraphSONXModuleV2d0 and GraphSONXModuleV3d0 as custom module for GraphSON V2_0 and V3_0 by default to avoid the failure of TINKERPOP-2817.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1003210814


##########
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordWriter.java:
##########
@@ -58,11 +61,15 @@ public final class GraphSONRecordWriter extends RecordWriter<NullWritable, Verte
     public GraphSONRecordWriter(final DataOutputStream outputStream, final Configuration configuration) {
         this.outputStream = outputStream;
         this.hasEdges = configuration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_WRITER_HAS_EDGES, true);
-        this.graphsonWriter = GraphSONWriter.build().mapper(
-                GraphSONMapper.build().
-                        version(GraphSONVersion.valueOf(configuration.get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"))).
-                        typeInfo(TypeInfo.PARTIAL_TYPES).
-                        addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(configuration))).create()).create();
+        GraphSONVersion graphSONVersion =

Review Comment:
   nit: `final` local variables



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002997320


##########
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java:
##########
@@ -56,11 +59,33 @@ public GraphSONRecordReader() {
     public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException {
         this.lineRecordReader.initialize(genericSplit, context);
         this.hasEdges = context.getConfiguration().getBoolean(Constants.GREMLIN_HADOOP_GRAPH_READER_HAS_EDGES, true);
-        this.graphsonReader = GraphSONReader.build().mapper(
-                GraphSONMapper.build().
-                        version(GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"))).
-                        typeInfo(TypeInfo.PARTIAL_TYPES).
-                        addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(context.getConfiguration()))).create()).create();
+        GraphSONVersion graphSONVersion =
+                GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"));
+        Mapper mapper = null;
+
+        if (graphSONVersion == GraphSONVersion.V2_0) {

Review Comment:
   DONE.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002905316


##########
hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONXModuleV3d0RecordReaderWriterTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ *  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.graphson;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.*;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.RecordReaderWriterTest;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GraphSONXModuleV3d0RecordReaderWriterTest extends RecordReaderWriterTest {

Review Comment:
   RecordReaderWriterTest expects to use grateful-daed-xxx.json because the validateFileSplits wants to check the vertex count, inEdge count, and outEdge count. I can add another grateful-daed-byteid-xxx.json, then it will reuse RecordReaderWriterTest with a tiny change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#issuecomment-1293140433

   @spmallette Could you please help approve running workflows?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002767340


##########
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java:
##########
@@ -56,11 +59,33 @@ public GraphSONRecordReader() {
     public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException {
         this.lineRecordReader.initialize(genericSplit, context);
         this.hasEdges = context.getConfiguration().getBoolean(Constants.GREMLIN_HADOOP_GRAPH_READER_HAS_EDGES, true);
-        this.graphsonReader = GraphSONReader.build().mapper(
-                GraphSONMapper.build().
-                        version(GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"))).
-                        typeInfo(TypeInfo.PARTIAL_TYPES).
-                        addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(context.getConfiguration()))).create()).create();
+        GraphSONVersion graphSONVersion =
+                GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"));
+        Mapper mapper = null;
+
+        if (graphSONVersion == GraphSONVersion.V2_0) {

Review Comment:
   might be nice if you make this code a bit more compact - like, create a builder instance with the common things and then just `addCustomModule(...)` in the if-then parts. i can do it after it's merged if you don't have time. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1003924906


##########
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordWriter.java:
##########
@@ -58,11 +61,15 @@ public final class GraphSONRecordWriter extends RecordWriter<NullWritable, Verte
     public GraphSONRecordWriter(final DataOutputStream outputStream, final Configuration configuration) {
         this.outputStream = outputStream;
         this.hasEdges = configuration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_WRITER_HAS_EDGES, true);
-        this.graphsonWriter = GraphSONWriter.build().mapper(
-                GraphSONMapper.build().
-                        version(GraphSONVersion.valueOf(configuration.get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"))).
-                        typeInfo(TypeInfo.PARTIAL_TYPES).
-                        addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(configuration))).create()).create();
+        GraphSONVersion graphSONVersion =

Review Comment:
   ack



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002767954


##########
hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONXModuleV3d0RecordReaderWriterTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ *  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.graphson;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.*;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.RecordReaderWriterTest;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GraphSONXModuleV3d0RecordReaderWriterTest extends RecordReaderWriterTest {

Review Comment:
   nice that got some testing in place for this. rather than copy/paste this class would it be possible to just make `RecordReaderWriterTest ` more flexible so as to validate the `Byte`? isn't that the only difference included in this test?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette commented on pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette commented on PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#issuecomment-1288905211

   Aside from a nit and CHANGELOG entry this looks good - the committer can handle both on merge if necessary: VOTE +1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002905316


##########
hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONXModuleV3d0RecordReaderWriterTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ *  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.graphson;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.mapreduce.*;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
+import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.RecordReaderWriterTest;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class GraphSONXModuleV3d0RecordReaderWriterTest extends RecordReaderWriterTest {

Review Comment:
   RecordReaderWriterTest is binding with grateful-dead-xxx.json because the validateFileSplits wants to check the vertex count, inEdge count, and outEdge count. I used tinkerpop-classic-xxx.json instead of grateful-dead-xxx.json, because I just replaced the 
    vertex id type from Int32 to Byte since tinkerpop-classic-xxx.json only has 6 vertice. I cannot change any type in grateful-dead-xxx.json to Byte.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] ministat commented on a diff in pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
ministat commented on code in PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#discussion_r1002910849


##########
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/graphson/GraphSONRecordReader.java:
##########
@@ -56,11 +59,33 @@ public GraphSONRecordReader() {
     public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException {
         this.lineRecordReader.initialize(genericSplit, context);
         this.hasEdges = context.getConfiguration().getBoolean(Constants.GREMLIN_HADOOP_GRAPH_READER_HAS_EDGES, true);
-        this.graphsonReader = GraphSONReader.build().mapper(
-                GraphSONMapper.build().
-                        version(GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"))).
-                        typeInfo(TypeInfo.PARTIAL_TYPES).
-                        addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(context.getConfiguration()))).create()).create();
+        GraphSONVersion graphSONVersion =
+                GraphSONVersion.valueOf(context.getConfiguration().get(Constants.GREMLIN_HADOOP_GRAPHSON_VERSION, "V3_0"));
+        Mapper mapper = null;
+
+        if (graphSONVersion == GraphSONVersion.V2_0) {

Review Comment:
   I can do that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette closed pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette closed pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader
URL: https://github.com/apache/tinkerpop/pull/1835


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tinkerpop] spmallette commented on pull request #1835: TINKERPOP-2817 Support java.lang.Byte in hadoop GraphSONRecordWriter/GraphSONRecordReader

Posted by GitBox <gi...@apache.org>.
spmallette commented on PR #1835:
URL: https://github.com/apache/tinkerpop/pull/1835#issuecomment-1317328761

   sorry for the delay here. thanks for your help on this @ministat  - merged with: f73b3f84d6d32e8c1ee8b3fc29749bb89cab2dd9 and included e4775a699e6c2140238add91036b2e6d39da89cb


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org