Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.Bytecode#Binding
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.Bytecode#Binding .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Bytecode.Binding deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String k = null; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); k = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new Bytecode.Binding<>(k, v); }
Example 2
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Bytecode.Binding deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String k = null; Object v = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { if (jsonParser.getCurrentName().equals(GraphSONTokens.KEY)) { jsonParser.nextToken(); k = jsonParser.getText(); } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) { jsonParser.nextToken(); v = deserializationContext.readValue(jsonParser, Object.class); } } return new Bytecode.Binding<>(k, v); }
Example 3
Source File: AbstractTypedCompatibilityTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldReadWriteBinding() throws Exception { final String resourceName = "binding"; assumeCompatibility(resourceName); final Bytecode.Binding resource = findModelEntryObject(resourceName); final Bytecode.Binding fromStatic = read(getCompatibility().readFromResource(resourceName), Bytecode.Binding.class); final Bytecode.Binding recycled = read(write(fromStatic, Bytecode.Binding.class), Bytecode.Binding.class); assertNotSame(fromStatic, recycled); assertEquals(fromStatic, recycled); assertEquals(resource, fromStatic); assertEquals(resource, recycled); }
Example 4
Source File: GraphSONMapperEmbeddedTypeTest.java From tinkerpop with Apache License 2.0 | 5 votes |
@Test public void shouldHandleBytecodeBinding() throws Exception { assumeThat(version, either(startsWith("v2")).or(startsWith("v3"))); final Bytecode.Binding<String> o = new Bytecode.Binding<>("test", "testing"); assertEquals(o, serializeDeserialize(mapper, o, Bytecode.Binding.class)); }
Example 5
Source File: BytecodeHelper.java From tinkerpop with Apache License 2.0 | 5 votes |
public static void removeBindings(final Bytecode bytecode) { for (final Bytecode.Instruction instruction : bytecode.getInstructions()) { final Object[] arguments = instruction.getArguments(); for (int i = 0; i < arguments.length; i++) { if (arguments[i] instanceof Bytecode.Binding) arguments[i] = ((Bytecode.Binding) arguments[i]).value(); else if (arguments[i] instanceof Bytecode) removeBindings((Bytecode) arguments[i]); } } }
Example 6
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Bytecode.Binding binding, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.KEY, binding.variable()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, binding.value()); jsonGenerator.writeEndObject(); }
Example 7
Source File: TypeSerializerFailureTests.java From tinkerpop with Apache License 2.0 | 5 votes |
@Parameterized.Parameters(name = "Value={0}") public static Collection input() { final Bytecode.Binding b = new Bytecode.Binding(null, "b"); final ReferenceVertex vertex = new ReferenceVertex("a vertex", null); final Bytecode bytecode = new Bytecode(); bytecode.addStep(null); final BulkSet<Object> bulkSet = new BulkSet<>(); bulkSet.add(vertex, 1L); final MutableMetrics metrics = new MutableMetrics("a metric", null); final Tree<Vertex> tree = new Tree<>(); tree.put(vertex, null); // Provide instances that are malformed for serialization to fail return Arrays.asList( b, vertex, Collections.singletonMap("one", b), bulkSet, bytecode, Collections.singletonList(vertex), new ReferenceEdge("an edge", null, vertex, vertex), Lambda.supplier(null), metrics, new DefaultTraversalMetrics(1L, Collections.singletonList(metrics)), new DefaultRemoteTraverser<>(new Object(), 1L), tree, new ReferenceVertexProperty<>("a prop", null, "value"), new InvalidPath() ); }
Example 8
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public void serialize(final Bytecode.Binding binding, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(GraphSONTokens.KEY, binding.variable()); jsonGenerator.writeObjectField(GraphSONTokens.VALUE, binding.value()); jsonGenerator.writeEndObject(); }
Example 9
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 4 votes |
public BindingJacksonSerializer() { super(Bytecode.Binding.class); }
Example 10
Source File: BindingSerializer.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override protected void writeValue(final Bytecode.Binding value, final Buffer buffer, final GraphBinaryWriter context) throws IOException { context.writeValue(value.variable(), buffer, false); context.write(value.value(), buffer); }
Example 11
Source File: BindingSerializer.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override protected Bytecode.Binding readValue(final Buffer buffer, final GraphBinaryReader context) throws IOException { final String k = context.readValue(buffer, String.class, false); return new Bytecode.Binding<>(k, context.read(buffer)); }
Example 12
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 4 votes |
public BindingJacksonDeserializer() { super(Bytecode.Binding.class); }
Example 13
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 4 votes |
public BindingJacksonDeserializer() { super(Bytecode.Binding.class); }
Example 14
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 4 votes |
public BindingJacksonSerializer() { super(Bytecode.Binding.class); }
Example 15
Source File: GryoSerializersV3d0.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public <I extends InputShim> Bytecode.Binding read(final KryoShim<I, ?> kryo, final I input, final Class<Bytecode.Binding> clazz) { final String var = input.readString(); final Object val = kryo.readClassAndObject(input); return new Bytecode.Binding(var, val); }
Example 16
Source File: GryoSerializersV3d0.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Bytecode.Binding binding) { output.writeString(binding.variable()); kryo.writeClassAndObject(output, binding.value()); }
Example 17
Source File: GryoSerializersV1d0.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public <I extends InputShim> Bytecode.Binding read(final KryoShim<I, ?> kryo, final I input, final Class<Bytecode.Binding> clazz) { final String var = input.readString(); final Object val = kryo.readClassAndObject(input); return new Bytecode.Binding(var, val); }
Example 18
Source File: GryoSerializersV1d0.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Bytecode.Binding binding) { output.writeString(binding.variable()); kryo.writeClassAndObject(output, binding.value()); }