@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()} }); }
public ToyModule() { super("toy"); addSerializer(ToyPoint.class, new ToyPoint.ToyPointJacksonSerializer()); addDeserializer(ToyPoint.class, new ToyPoint.ToyPointJacksonDeSerializer()); addSerializer(ToyTriangle.class, new ToyTriangle.ToyTriangleJacksonSerializer()); addDeserializer(ToyTriangle.class, new ToyTriangle.ToyTriangleJacksonDeSerializer()); }
public synchronized static void initialize(final Configuration configuration) { if (!INITIALIZED) { INITIALIZED = true; GRYO_POOL = GryoPool.build(). poolSize(configuration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE, 256)). version(GryoVersion.valueOf(configuration.getString(GryoPool.CONFIG_IO_GRYO_VERSION, GryoPool.CONFIG_IO_GRYO_POOL_VERSION_DEFAULT.name()))). ioRegistries(configuration.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())). initializeMapper(m -> m.registrationRequired(false)). create(); } }
/** * {@inheritDoc} */ @Override public void writeGraph(final String file) throws IOException { try (final OutputStream out = new FileOutputStream(file)) { writer().create().writeGraph(out, graph); } }
/** * 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()); }
@Test public void testGeoShapeSerializationReadWriteAsGryo() throws Exception { GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); graph.io(IoCore.gryo()).writeGraph("/tmp/test.kryo"); clearGraph(config); open(config); graph.io(IoCore.gryo()).readGraph("/tmp/test.kryo"); TitanIndexTest.assertGraphOfTheGods(graph); } }
private ToyIoRegistry() { super.register(GryoIo.class, ToyPoint.class, new ToyPoint.ToyPointSerializer()); super.register(GryoIo.class, ToyTriangle.class, new ToyTriangle.ToyTriangleSerializer()); super.register(GraphSONIo.class, null, new ToyModule()); }
private GryoMapper(final Builder builder) { this.typeRegistrations = builder.typeRegistrations; this.version = builder.version; validate(); this.registrationRequired = builder.registrationRequired; this.referenceTracking = builder.referenceTracking; this.classResolver = null == builder.classResolver ? version.getClassResolverMaker() : builder.classResolver; }
/** * {@inheritDoc} */ @Override public void writeVertex(final OutputStream outputStream, final Vertex v) throws IOException { writeVertex(outputStream, v, null); }
/** * Creates a basic Gryo-based {@link org.apache.tinkerpop.gremlin.structure.io.Io.Builder}. */ public static Io.Builder<GryoIo> gryo() { return GryoIo.build(); }
/** * Register a custom class to serialize with a custom serializer as returned from a {@link Function}. Note * that calling this method for a class that is already registered will override that registration. */ public Builder addCustom(final Class clazz, final Function<Kryo, Serializer> functionOfKryo) { addOrOverrideRegistration(clazz, id -> GryoTypeReg.of(clazz, id, functionOfKryo)); return this; }
/** * The version of Gryo to use in the mapper. Defaults to 1.0. Calls to this method will reset values specified * to {@link #addCustom(Class, Function)} and related overloads. */ public Builder version(final GryoVersion version) { this.version = version; this.typeRegistrations = version.cloneRegistrations(); return this; }
/** * 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()); }
/** * Register custom classes to serializes with gryo using default serialization. Note that calling this method * for a class that is already registered will override that registration. */ public Builder addCustom(final Class... custom) { if (custom != null && custom.length > 0) { for (Class c : custom) { addOrOverrideRegistration(c, id -> GryoTypeReg.of(c, id)); } } return this; }