You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/04/16 18:53:05 UTC
incubator-tinkerpop git commit: Add javadoc around refactored Io.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/refactor-io 3d38e2e3a -> 69d7761c1
Add javadoc around refactored Io.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/69d7761c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/69d7761c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/69d7761c
Branch: refs/heads/refactor-io
Commit: 69d7761c164bff5e28eb261248043559dc8ec9e8
Parents: 3d38e2e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 16 12:52:38 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 16 12:52:38 2015 -0400
----------------------------------------------------------------------
.../gremlin/structure/io/GraphReader.java | 7 ++++
.../gremlin/structure/io/GraphWriter.java | 7 ++++
.../gremlin/structure/io/IoRegistry.java | 35 +++++++++++++++-----
3 files changed, 40 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/69d7761c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
index cf5ee04..157ee29 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphReader.java
@@ -96,7 +96,14 @@ public interface GraphReader {
*/
public Edge readEdge(final InputStream inputStream, final Function<DetachedEdge, Edge> edgeMaker) throws IOException;
+ /**
+ * Largely a marker interface for builder classes that construct a {@link GraphReader}.
+ */
public interface ReaderBuilder<T extends GraphReader> {
+ /**
+ * Creates the {@link GraphReader} implementation given options provided to the {@link ReaderBuilder}
+ * implementation.
+ */
T create();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/69d7761c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphWriter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphWriter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphWriter.java
index c63476f..0eb9f65 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphWriter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/GraphWriter.java
@@ -87,7 +87,14 @@ public interface GraphWriter {
*/
public void writeEdge(final OutputStream outputStream, final Edge e) throws IOException;
+ /**
+ * Largely a marker interface for builder classes that construct a {@link GraphWriter}.
+ */
public interface WriterBuilder<T extends GraphWriter> {
+ /**
+ * Creates the {@link GraphWriter} implementation given options provided to the {@link WriterBuilder}
+ * implementation.
+ */
T create();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/69d7761c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
index 7bd8560..baf2668 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
@@ -18,6 +18,9 @@
*/
package org.apache.tinkerpop.gremlin.structure.io;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
import org.javatuples.Pair;
import java.util.Arrays;
@@ -28,34 +31,48 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
+ * A generalized custom serializer registry for vendors implementing a {@link Graph}. Vendors should register
+ * custom serializers to this registry via the {@link #register(Class, Class, Object)} method. The serializers
+ * registered depend on the {@link Io} implementations that are expected to be supported. There are currently
+ * just two core implementations in {@link GryoIo} and {@link GraphSONIo}. Both of these should be supported
+ * for full compliance with the test suite. There is no need to use this class if the {@link Graph} does not
+ * have custom classes that require serialization.
+ *
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class IoRegistry {
- private final Map<Class<? extends Io.Builder>, List<Pair<Class, Object>>> registeredSerializers = new HashMap<>();
+ private final Map<Class<? extends Io>, List<Pair<Class, Object>>> registeredSerializers = new HashMap<>();
/**
* Add a "serializer" for the {@code Mapper}. Note that what is accepted as a "serializer" is implementation
- * specific. Note that the {@link Io.Builder} implementation will consult this registry for "serializer" classes
- * it expects so consult the {@link Io.Builder} implementation to understand what is expected for these values.
+ * specific. An {@link Io} implementation will consult this registry for "serializer" classes
+ * it expects so refer to the {@link Io} implementation to understand what is expected for these values.
*
* @param clazz usually this is the class that is to be serialized - may be {@code null}
* @param serializer a serializer implementation
*/
- public void register(final Class<? extends Io.Builder> builderClass, final Class clazz, final Object serializer) {
- if (registeredSerializers.containsKey(builderClass))
- registeredSerializers.get(builderClass).add(Pair.with(clazz, serializer));
+ public void register(final Class<? extends Io> ioClass, final Class clazz, final Object serializer) {
+ if (registeredSerializers.containsKey(ioClass))
+ registeredSerializers.get(ioClass).add(Pair.with(clazz, serializer));
else
- registeredSerializers.put(builderClass, Arrays.asList(Pair.with(clazz, serializer)));
+ registeredSerializers.put(ioClass, Arrays.asList(Pair.with(clazz, serializer)));
}
+ /**
+ * Find a list of all the serializers registered to an {@link Io} class by the {@link Graph}.
+ */
public List<Pair<Class,Object>> find(final Class<? extends Io> builderClass) {
return Collections.unmodifiableList(registeredSerializers.get(builderClass).stream()
.collect(Collectors.toList()));
}
- public <S> List<Pair<Class,S>> find(final Class<? extends Io> builderClass, final Class<S> c) {
+ /**
+ * Find a list of all the serializers, of a particular type, registered to an {@link Io} class by the
+ * {@link Graph}.
+ */
+ public <S> List<Pair<Class,S>> find(final Class<? extends Io> builderClass, final Class<S> serializerType) {
return Collections.unmodifiableList(registeredSerializers.get(builderClass).stream()
- .filter(p -> p.getValue1().getClass().isAssignableFrom(c))
+ .filter(p -> p.getValue1().getClass().isAssignableFrom(serializerType))
.map(p -> Pair.with(p.getValue0(), (S) p.getValue1()))
.collect(Collectors.toList()));
}