Search in sources :

Example 1 with TypeSerializerRegistry

use of org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry in project janusgraph by JanusGraph.

the class RelationIdentifierGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("relationIdentifierProvider")
public void readValueAndWriteValueShouldBeSymmetric(final RelationIdentifier relationIdentifier) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(RelationIdentifier.class, new RelationIdentifierGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(relationIdentifier, buffer, nullable);
        final RelationIdentifier actual = reader.readValue(buffer, RelationIdentifier.class, nullable);
        assertEquals(actual.toString(), relationIdentifier.toString());
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) RelationIdentifier(org.janusgraph.graphdb.relations.RelationIdentifier) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with TypeSerializerRegistry

use of org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry in project janusgraph by JanusGraph.

the class JanusGraphPGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("janusGraphPProvider")
public void readValueAndWriteValueShouldBeSymmetric(final JanusGraphP predicate) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(JanusGraphP.class, new JanusGraphPBinarySerializer()).addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(predicate, buffer, nullable);
        final JanusGraphP actual = reader.readValue(buffer, JanusGraphP.class, nullable);
        assertEquals(actual.toString(), predicate.toString());
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) Geoshape(org.janusgraph.core.attribute.Geoshape) JanusGraphP(org.janusgraph.graphdb.tinkerpop.io.JanusGraphP) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with TypeSerializerRegistry

use of org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry in project janusgraph by JanusGraph.

the class GeoshapeGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("geoshapeProvider")
public void readValueAndWriteValueShouldBeSymmetric(Geoshape geoshape) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(geoshape, buffer, nullable);
        final Geoshape actual = reader.readValue(buffer, Geoshape.class, nullable);
        assertEquals(actual, geoshape);
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) Geoshape(org.janusgraph.core.attribute.Geoshape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

Buffer (org.apache.tinkerpop.gremlin.structure.io.Buffer)3 GraphBinaryReader (org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader)3 GraphBinaryWriter (org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter)3 TypeSerializerRegistry (org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Geoshape (org.janusgraph.core.attribute.Geoshape)2 RelationIdentifier (org.janusgraph.graphdb.relations.RelationIdentifier)1 JanusGraphP (org.janusgraph.graphdb.tinkerpop.io.JanusGraphP)1