Class Bytecode
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.Bytecode
-
- All Implemented Interfaces:
Serializable
,Cloneable
public final class Bytecode extends Object implements Cloneable, Serializable
When aTraversalSource
is manipulated and then aTraversal
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 byTranslator
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.
- Author:
- Marko A. Rodriguez (http://markorodriguez.com)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Bytecode.Binding<V>
static class
Bytecode.Instruction
-
Constructor Summary
Constructors Constructor Description Bytecode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSource(String sourceName, Object... arguments)
Add aTraversalSource
instruction to the bytecode.void
addStep(String stepName, Object... arguments)
Add aTraversal
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 theTraversalSource
andTraversal
instructions of this bytecode.List<Bytecode.Instruction>
getSourceInstructions()
Get theTraversalSource
instructions associated with this bytecode.List<Bytecode.Instruction>
getStepInstructions()
Get theTraversal
instructions associated with this bytecode.int
hashCode()
boolean
isEmpty()
String
toString()
-
-
-
Method Detail
-
addSource
public void addSource(String sourceName, Object... arguments)
Add aTraversalSource
instruction to the bytecode.- Parameters:
sourceName
- the traversal source method name (e.g. withSack())arguments
- the traversal source method arguments
-
addStep
public void addStep(String stepName, Object... arguments)
Add aTraversal
instruction to the bytecode.- Parameters:
stepName
- the traversal method name (e.g. out())arguments
- the traversal method arguments
-
getSourceInstructions
public List<Bytecode.Instruction> getSourceInstructions()
Get theTraversalSource
instructions associated with this bytecode.- Returns:
- an iterable of instructions
-
getStepInstructions
public List<Bytecode.Instruction> getStepInstructions()
Get theTraversal
instructions associated with this bytecode.- Returns:
- an iterable of instructions
-
getInstructions
public Iterable<Bytecode.Instruction> getInstructions()
Get both theTraversalSource
andTraversal
instructions of this bytecode. The traversal source instructions are provided prior to the traversal instructions.- Returns:
- an interable of all the instructions in this bytecode
-
getBindings
public Map<String,Object> getBindings()
Get all the bindings (in a nested, recursive manner) from all the arguments of all the instructions of this bytecode.- Returns:
- a map of string variable and object value bindings
-
isEmpty
public boolean isEmpty()
-
-