@Override public final void configure(final Map<String, Object> config, final Map<String, Graph> graphs) { final GryoMapper.Builder builder = GryoMapper.build().version(GryoVersion.V3_0); addIoRegistries(config, builder); addClassResolverSupplier(config, builder); addCustomClasses(config, builder); this.serializeToString = Boolean.parseBoolean(config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString()); this.bufferSize = Integer.parseInt(config.getOrDefault(TOKEN_BUFFER_SIZE, "4096").toString()); this.gryoMapper = configureBuilder(builder, config, graphs).create(); }
@Override public final void configure(final Map<String, Object> config, final Map<String, Graph> graphs) { final GryoMapper.Builder builder = GryoMapper.build().version(GryoVersion.V1_0); addIoRegistries(config, builder); addClassResolverSupplier(config, builder); addCustomClasses(config, builder); this.serializeToString = Boolean.parseBoolean(config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString()); this.bufferSize = Integer.parseInt(config.getOrDefault(TOKEN_BUFFER_SIZE, "4096").toString()); this.gryoMapper = configureBuilder(builder, config, graphs).create(); }
final GryoMapper.Builder builder = GryoMapper.build(); detectRegistries().forEach(builder::addRegistry); return GryoReader.build().mapper(builder.create()).create(); } else if (objectOrClass.equals(IO.graphml)) return GraphMLReader.build().create();
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that the instance created by the supplied * builder will be overridden by {@link #configure} if it is called. */ public GryoMessageSerializerV3d0(final GryoMapper.Builder kryo) { super(kryo.version(GryoVersion.V3_0).create()); }
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that the instance created by the supplied * builder will be overridden by {@link #configure} if it is called. */ public GryoLiteMessageSerializerV1d0(final GryoMapper.Builder kryo) { super(overrideWithLite(kryo).create()); }
for (TypeRegistration<?> tr : GryoMapper.build().version(GryoVersion.V1_0).create().getTypeRegistrations()) {
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()} }); }
@Override public void initialize(final InputSplit genericSplit, final TaskAttemptContext context) throws IOException { final FileSplit split = (FileSplit) genericSplit; final Configuration configuration = context.getConfiguration(); if (configuration.get(Constants.GREMLIN_HADOOP_GRAPH_FILTER, null) != null) this.graphFilter = VertexProgramHelper.deserialize(ConfUtil.makeApacheConfiguration(configuration), Constants.GREMLIN_HADOOP_GRAPH_FILTER); this.gryoReader = GryoReader.build().mapper( GryoMapper.build().addRegistries(IoRegistryHelper.createRegistries(ConfUtil.makeApacheConfiguration(configuration))).create()).create(); long start = split.getStart(); final Path file = split.getPath(); if (null != new CompressionCodecFactory(configuration).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(configuration).open(split.getPath()); this.splitLength = split.getLength(); if (this.splitLength > 0) this.splitLength -= (seekToHeader(this.inputStream, start) - start); }
/** * Create the {@code GryoPool} from this builder. * * @return the new pool */ public GryoPool create() { final GryoMapper.Builder mapper = GryoMapper.build().version(version); final GryoPool gryoPool = new GryoPool(); if (null != this.ioRegistries) this.ioRegistries.forEach(mapper::addRegistry); if (null != this.gryoMapperConsumer) this.gryoMapperConsumer.accept(mapper); gryoPool.createPool(this.poolSize, this.type, mapper.create()); return gryoPool; } }
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that the instance created by the supplied * builder will be overridden by {@link #configure} if it is called. */ public GryoLiteMessageSerializerV1d0(final GryoMapper.Builder kryo) { super(overrideWithLite(kryo).create()); }
/** * {@inheritDoc} */ @Override public GryoReader.Builder reader() { return GryoReader.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(); }
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that the instance created by the supplied * builder will be overridden by {@link #configure} if it is called. */ public GryoMessageSerializerV1d0(final GryoMapper.Builder kryo) { super(kryo.version(GryoVersion.V1_0).create()); }
/** * {@inheritDoc} */ @Override public GryoWriter.Builder writer() { return GryoWriter.build().mapper(mapper().create()); }
/** * Creates an instance with a standard {@link GryoMapper} instance. */ public GryoMessageSerializerV1d0() { super(GryoMapper.build().version(GryoVersion.V1_0).create()); }
/** * Creates an instance with a standard {@link GryoMapper} instance. */ public GryoMessageSerializerV3d0() { super(GryoMapper.build().version(GryoVersion.V3_0).create()); }
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that the instance created by the supplied * builder will be overridden by {@link #configure} if it is called. */ public GryoMessageSerializerV3d0(final GryoMapper.Builder kryo) { super(kryo.version(GryoVersion.V3_0).create()); }
/** * Creates an instance with a standard {@link GryoMapper} instance. Note that this instance * will be overridden by {@link #configure} is called. */ public GryoLiteMessageSerializerV1d0() { super(overrideWithLite(GryoMapper.build()).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()} }); }