@Parameterized.Parameters(name = "{0}") public static Iterable<Object[]> data() { final GraphSONMapper v1mapper = GraphSONMapper.build().version(GraphSONVersion.V1_0).typeInfo(TypeInfo.PARTIAL_TYPES).addRegistry(JanusGraphIoRegistryV1d0.getInstance()).create(); final GraphSONMapper v2mapper = GraphSONMapper.build().version(GraphSONVersion.V2_0).typeInfo(TypeInfo.PARTIAL_TYPES).addRegistry(JanusGraphIoRegistry.getInstance()).create(); final GraphSONMapper v3mapper = GraphSONMapper.build().version(GraphSONVersion.V3_0).typeInfo(TypeInfo.PARTIAL_TYPES).addRegistry(JanusGraphIoRegistry.getInstance()).create(); return Arrays.asList(new Object[][]{ {"graphson-v1-embedded", (Function<Graph, GraphReader>) g -> GraphSONReader.build().mapper(v1mapper).create(), (Function<Graph, GraphWriter>) g -> GraphSONWriter.build().mapper(v1mapper).create()}, {"graphson-v2-embedded", (Function<Graph, GraphReader>) g -> GraphSONReader.build().mapper(v2mapper).create(), (Function<Graph, GraphWriter>) g -> GraphSONWriter.build().mapper(v2mapper).create()}, {"graphson-v3", (Function<Graph, GraphReader>) g -> GraphSONReader.build().mapper(v3mapper).create(), (Function<Graph, GraphWriter>) g -> GraphSONWriter.build().mapper(v3mapper).create()}, {"gryo", (Function<Graph, GraphReader>) g -> g.io(IoCore.gryo()).reader().mapper(g.io(IoCore.gryo()).mapper().create()).create(), (Function<Graph, GraphWriter>) g -> g.io(IoCore.gryo()).writer().mapper(g.io(IoCore.gryo()).mapper().create()).create()} }); }
/** * {@inheritDoc} */ @Override public GraphSONWriter.Builder writer() { return GraphSONWriter.build().mapper(mapper().create()); }
final GraphSONMapper.Builder builder = GraphSONMapper.build(); detectRegistries().forEach(builder::addRegistry); return GraphSONWriter.build().mapper(builder.create()).create(); } else if (objectOrClass.equals(IO.gryo)){ final GryoMapper.Builder builder = GryoMapper.build();
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(); }
public InputStream getGraphSON(String tenantId) { PipedInputStream in = new PipedInputStream(); new Thread(() -> { try (PipedOutputStream out = new PipedOutputStream(in)) { GraphSONWriter.build().create().writeGraph(out, context.getGraph()); } catch (IOException e) { throw new IllegalStateException("Unable to create the GraphSON dump.", e); } }).start(); return in; }
/** * {@inheritDoc} */ @Override public GraphSONWriter.Builder writer() { return GraphSONWriter.build().mapper(mapper().create()); }
final GraphSONMapper.Builder builder = GraphSONMapper.build(); detectRegistries().forEach(builder::addRegistry); return GraphSONWriter.build().mapper(builder.create()).create(); } else if (objectOrClass.equals(IO.gryo)){ final GryoMapper.Builder builder = GryoMapper.build();
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(); }
@Override public void exportToGson(OutputStream os) throws IOException { GraphSONMapper mapper = getGraph().io(IoCore.graphson()).mapper().create(); GraphSONWriter.Builder builder = GraphSONWriter.build(); builder.mapper(mapper); GraphSONWriter writer = builder.create(); writer.writeGraph(os, getGraph()); }
@Override public void exportToGson(OutputStream os) throws IOException { GraphSONMapper mapper = getGraph().io(IoCore.graphson()).mapper().create(); GraphSONWriter.Builder builder = GraphSONWriter.build(); builder.mapper(mapper); GraphSONWriter writer = builder.create(); writer.writeGraph(os, getGraph()); }