@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
private void createPool(final int poolSize, final Type type, final GryoMapper gryoMapper) { this.mapper = gryoMapper; if (type.equals(Type.READER) || type.equals(Type.READER_WRITER)) { gryoReaders = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { gryoReaders.add(GryoReader.build().mapper(gryoMapper).create()); } } if (type.equals(Type.WRITER) || type.equals(Type.READER_WRITER)) { gryoWriters = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { gryoWriters.add(GryoWriter.build().mapper(gryoMapper).create()); } } kryos = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { kryos.add(gryoMapper.createMapper()); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
public GryoRecordWriter(final DataOutputStream outputStream, final Configuration configuration) { this.outputStream = outputStream; this.hasEdges = configuration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_WRITER_HAS_EDGES, true); this.gryoWriter = GryoWriter.build().mapper( GryoMapper.build().addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(configuration))).create()).create(); }
public GryoWriter takeWriter() { final GryoWriter writer = this.gryoWriters.poll(); return null == writer ? GryoWriter.build().mapper(mapper).create() : writer; }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
/** * {@inheritDoc} */ @Override public GryoWriter.Builder writer() { return GryoWriter.build().mapper(mapper().create()); }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
final GryoMapper.Builder builder = GryoMapper.build(); detectRegistries().forEach(builder::addRegistry); return GryoWriter.build().mapper(builder.create()).create(); }else if (objectOrClass.equals(IO.graphml)) return GraphMLWriter.build().create();
@Parameterized.Parameters(name = "{0}") public static Iterable<Object[]> data() { final SimpleModule moduleV1d0 = new SimpleModule(); moduleV1d0.addSerializer(CustomId.class, new CustomId.CustomIdJacksonSerializerV1d0()); final SimpleModule moduleV2d0 = new CustomId.CustomIdTinkerPopJacksonModuleV2d0(); final SimpleModule modulev3d0 = new CustomId.CustomIdTinkerPopJacksonModuleV3d0(); return Arrays.asList(new Object[][]{ {"graphson-v1-embedded", true, (Function<Graph, GraphReader>) g -> g.io(GraphSONIo.build(GraphSONVersion.V1_0)).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().addCustomModule(moduleV1d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create(), (Function<Graph, GraphWriter>) g -> g.io(GraphSONIo.build(GraphSONVersion.V1_0)).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V1_0)).mapper().addCustomModule(moduleV1d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create()}, {"graphson-v2-embedded", true, (Function<Graph, GraphReader>) g -> g.io(GraphSONIo.build(GraphSONVersion.V2_0)).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().addCustomModule(moduleV2d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create(), (Function<Graph, GraphWriter>) g -> g.io(GraphSONIo.build(GraphSONVersion.V2_0)).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().addCustomModule(moduleV2d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create()}, {"graphson-v3", true, (Function<Graph, GraphReader>) g -> g.io(GraphSONIo.build(GraphSONVersion.V3_0)).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(modulev3d0).create()).create(), (Function<Graph, GraphWriter>) g -> g.io(GraphSONIo.build(GraphSONVersion.V3_0)).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(modulev3d0).create()).create()}, {"gryo-v1", true, (Function<Graph, GraphReader>) g -> g.io(GryoIo.build(GryoVersion.V1_0)).reader().mapper(g.io(GryoIo.build(GryoVersion.V1_0)).mapper().version(GryoVersion.V1_0).addCustom(CustomId.class).create()).create(), (Function<Graph, GraphWriter>) g -> g.io(GryoIo.build(GryoVersion.V1_0)).writer().mapper(g.io(GryoIo.build(GryoVersion.V1_0)).mapper().version(GryoVersion.V1_0).addCustom(CustomId.class).create()).create()}, {"gryo-v3", true, (Function<Graph, GraphReader>) g -> g.io(GryoIo.build(GryoVersion.V3_0)).reader().mapper(g.io(GryoIo.build(GryoVersion.V3_0)).mapper().version(GryoVersion.V3_0).addCustom(CustomId.class).create()).create(), (Function<Graph, GraphWriter>) g -> g.io(GryoIo.build(GryoVersion.V3_0)).writer().mapper(g.io(GryoIo.build(GryoVersion.V3_0)).mapper().version(GryoVersion.V3_0).addCustom(CustomId.class).create()).create()} }); }
private void createPool(final int poolSize, final Type type, final GryoMapper gryoMapper) { this.mapper = gryoMapper; if (type.equals(Type.READER) || type.equals(Type.READER_WRITER)) { gryoReaders = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { gryoReaders.add(GryoReader.build().mapper(gryoMapper).create()); } } if (type.equals(Type.WRITER) || type.equals(Type.READER_WRITER)) { gryoWriters = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { gryoWriters.add(GryoWriter.build().mapper(gryoMapper).create()); } } kryos = new LinkedBlockingQueue<>(poolSize); for (int i = 0; i < poolSize; i++) { kryos.add(gryoMapper.createMapper()); } }
public GryoWriter takeWriter() { final GryoWriter writer = this.gryoWriters.poll(); return null == writer ? GryoWriter.build().mapper(mapper).create() : writer; }
/** * {@inheritDoc} */ @Override public GryoWriter.Builder writer() { return GryoWriter.build().mapper(mapper().create()); }
public GryoRecordWriter(final DataOutputStream outputStream, final Configuration configuration) { this.outputStream = outputStream; this.hasEdges = configuration.getBoolean(Constants.GREMLIN_HADOOP_GRAPH_WRITER_HAS_EDGES, true); this.gryoWriter = GryoWriter.build().mapper( GryoMapper.build().addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(configuration))).create()).create(); }
@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()} }); }