public final class Bytecode extends Object implements Cloneable, Serializable
TraversalSource
is manipulated and then a Traversal
is spawned and mutated, a language
agnostic representation of those mutations is recorded in a bytecode instance. Bytecode is simply a list
of ordered instructions where an instruction is a string operator and a (flattened) array of arguments.
Bytecode is used by Translator
instances which are able to translate a traversal in one language to another
by analyzing the bytecode as opposed to the Java traversal object representation on heap.
Bytecode can be serialized between environments and machines by way of a GraphSON representation. Thus, Gremlin-Python can create bytecode in Python and ship it to Gremlin-Java for evaluation in Java.
Modifier and Type | Class and Description |
---|---|
static class |
Bytecode.Binding<V> |
static class |
Bytecode.Instruction |
Constructor and Description |
---|
Bytecode() |
Modifier and Type | Method and Description |
---|---|
void |
addSource(String sourceName,
Object... arguments)
Add a
TraversalSource instruction to the bytecode. |
void |
addStep(String stepName,
Object... arguments)
Add a
Traversal instruction to the bytecode. |
Bytecode |
clone() |
boolean |
equals(Object o) |
Map<String,Object> |
getBindings()
Get all the bindings (in a nested, recursive manner) from all the arguments of all the instructions of this bytecode.
|
Iterable<Bytecode.Instruction> |
getInstructions()
Get both the
TraversalSource and Traversal instructions of this bytecode. |
List<Bytecode.Instruction> |
getSourceInstructions()
Get the
TraversalSource instructions associated with this bytecode. |
List<Bytecode.Instruction> |
getStepInstructions()
Get the
Traversal instructions associated with this bytecode. |
int |
hashCode() |
String |
toString() |
public void addSource(String sourceName, Object... arguments)
TraversalSource
instruction to the bytecode.sourceName
- the traversal source method name (e.g. withSack())arguments
- the traversal source method argumentspublic void addStep(String stepName, Object... arguments)
Traversal
instruction to the bytecode.stepName
- the traversal method name (e.g. out())arguments
- the traversal method argumentspublic List<Bytecode.Instruction> getSourceInstructions()
TraversalSource
instructions associated with this bytecode.public List<Bytecode.Instruction> getStepInstructions()
Traversal
instructions associated with this bytecode.public Iterable<Bytecode.Instruction> getInstructions()
TraversalSource
and Traversal
instructions of this bytecode.
The traversal source instructions are provided prior to the traversal instructions.public Map<String,Object> getBindings()
Copyright © 2013–2021 Apache Software Foundation. All rights reserved.