Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.Bytecode#addStep()
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.Bytecode#addStep() .
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: ByteCodeSerializer.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override protected Bytecode readValue(final Buffer buffer, final GraphBinaryReader context) throws IOException { final Bytecode result = new Bytecode(); final int stepsLength = buffer.readInt(); for (int i = 0; i < stepsLength; i++) { result.addStep(context.readValue(buffer, String.class, false), getInstructionArguments(buffer, context)); } final int sourcesLength = buffer.readInt(); for (int i = 0; i < sourcesLength; i++) { result.addSource(context.readValue(buffer, String.class, false), getInstructionArguments(buffer, context)); } return result; }
Example 2
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 3
Source File: TraversalSerializersV2d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }
Example 4
Source File: TraversalSerializersV3d0.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Bytecode deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException { final Bytecode bytecode = new Bytecode(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { final String current = jsonParser.getCurrentName(); if (current.equals(GraphSONTokens.SOURCE) || current.equals(GraphSONTokens.STEP)) { jsonParser.nextToken(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // there should be a list now and the first item in the list is always string and is the step name // skip the start array jsonParser.nextToken(); final String stepName = jsonParser.getText(); // iterate through the rest of the list for arguments until it gets to the end final List<Object> arguments = new ArrayList<>(); while (jsonParser.nextToken() != JsonToken.END_ARRAY) { // we don't know the types here, so let the deserializer figure that business out arguments.add(deserializationContext.readValue(jsonParser, Object.class)); } // if it's not a "source" then it must be a "step" if (current.equals(GraphSONTokens.SOURCE)) bytecode.addSource(stepName, arguments.toArray()); else bytecode.addStep(stepName, arguments.toArray()); } } } return bytecode; }