Search in sources :

Example 1 with SerializationException

use of org.apache.tinkerpop.gremlin.driver.ser.SerializationException in project janusgraph by JanusGraph.

the class JanusGraphIoRegistryTest method testTinkerPopPredicatesAsGryo.

/**
 * This is necessary since we replace the default TinkerPop PSerializer
 *
 * @throws Exception
 */
@Test
public void testTinkerPopPredicatesAsGryo() throws SerializationException {
    // Don't change this trivially. At the time of this writing (TinkerPop
    // 3.2.3), this is how many P predicate methods were defined. If this
    // fails, then JanusGraphPSerializer needs to be updated to add/remove
    // any TinkerPop predicates!
    assertEquals(15, Stream.of(P.class.getDeclaredMethods()).filter(m -> Modifier.isStatic(m.getModifiers())).filter(p -> {
        log.debug("Predicate: {}", p);
        return !p.isSynthetic();
    }).count());
    Graph graph = EmptyGraph.instance();
    GraphTraversalSource g = graph.traversal();
    // TinkerPop Predicates
    GraphTraversal[] traversals = { g.V().has("age", within(5000)), g.V().has("age", without(5000)), g.V().has("age", within(5000, 45)), g.V().has("age", inside(45, 5000)), g.V().and(has("age", between(45, 5000)), has("name", within("pluto"))), g.V().or(has("age", between(45, 5000)), has("name", within("pluto", "neptune"))) };
    serializationTest(traversals);
}
Also used : P(org.apache.tinkerpop.gremlin.process.traversal.P) UnpooledByteBufAllocator(io.netty.buffer.UnpooledByteBufAllocator) Bytecode(org.apache.tinkerpop.gremlin.process.traversal.Bytecode) Output(org.apache.tinkerpop.shaded.kryo.io.Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) Graph(org.apache.tinkerpop.gremlin.structure.Graph) Tokens(org.apache.tinkerpop.gremlin.driver.Tokens) LoggerFactory(org.slf4j.LoggerFactory) P.between(org.apache.tinkerpop.gremlin.process.traversal.P.between) Builder(org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper.Builder) Geoshape(org.janusgraph.core.attribute.Geoshape) RequestMessage(org.apache.tinkerpop.gremlin.driver.message.RequestMessage) Kryo(org.apache.tinkerpop.shaded.kryo.Kryo) MessageSerializer(org.apache.tinkerpop.gremlin.driver.MessageSerializer) SerializationException(org.apache.tinkerpop.gremlin.driver.ser.SerializationException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteBuf(io.netty.buffer.ByteBuf) P.without(org.apache.tinkerpop.gremlin.process.traversal.P.without) P(org.apache.tinkerpop.gremlin.process.traversal.P) Geo(org.janusgraph.core.attribute.Geo) Logger(org.slf4j.Logger) org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has) GryoMapper(org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper) P.inside(org.apache.tinkerpop.gremlin.process.traversal.P.inside) Test(org.junit.Test) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Input(org.apache.tinkerpop.shaded.kryo.io.Input) Stream(java.util.stream.Stream) EmptyGraph(org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph) Text(org.janusgraph.core.attribute.Text) Modifier(java.lang.reflect.Modifier) GryoMessageSerializerV1d0(org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0) P.within(org.apache.tinkerpop.gremlin.process.traversal.P.within) Assert.assertEquals(org.junit.Assert.assertEquals) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Graph(org.apache.tinkerpop.gremlin.structure.Graph) EmptyGraph(org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufAllocator (io.netty.buffer.ByteBufAllocator)1 UnpooledByteBufAllocator (io.netty.buffer.UnpooledByteBufAllocator)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Modifier (java.lang.reflect.Modifier)1 Stream (java.util.stream.Stream)1 MessageSerializer (org.apache.tinkerpop.gremlin.driver.MessageSerializer)1 Tokens (org.apache.tinkerpop.gremlin.driver.Tokens)1 RequestMessage (org.apache.tinkerpop.gremlin.driver.message.RequestMessage)1 GryoMessageSerializerV1d0 (org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0)1 SerializationException (org.apache.tinkerpop.gremlin.driver.ser.SerializationException)1 Bytecode (org.apache.tinkerpop.gremlin.process.traversal.Bytecode)1 P (org.apache.tinkerpop.gremlin.process.traversal.P)1 P.between (org.apache.tinkerpop.gremlin.process.traversal.P.between)1 P.inside (org.apache.tinkerpop.gremlin.process.traversal.P.inside)1 P.within (org.apache.tinkerpop.gremlin.process.traversal.P.within)1 P.without (org.apache.tinkerpop.gremlin.process.traversal.P.without)1 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)1 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)1