Class Bytecode
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.Bytecode
-
- All Implemented Interfaces:
Serializable,Cloneable
public class Bytecode extends Object implements Cloneable, Serializable
When aTraversalSourceis manipulated and then aTraversalis 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 byTranslatorinstances 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 classBytecode.Binding<V>static classBytecode.Instruction
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSource(String sourceName, Object... arguments)Add aTraversalSourceinstruction to the bytecode.voidaddStep(String stepName, Object... arguments)Add aTraversalinstruction to the bytecode.Bytecodeclone()booleanequals(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 theTraversalSourceandTraversalinstructions of this bytecode.List<Bytecode.Instruction>getSourceInstructions()Get theTraversalSourceinstructions associated with this bytecode.List<Bytecode.Instruction>getStepInstructions()Get theTraversalinstructions associated with this bytecode.inthashCode()booleanisEmpty()StringtoString()
-
-
-
Method Detail
-
addSource
public void addSource(String sourceName, Object... arguments)
Add aTraversalSourceinstruction 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 aTraversalinstruction to the bytecode.- Parameters:
stepName- the traversal method name (e.g. out())arguments- the traversal method arguments
-
getSourceInstructions
public List<Bytecode.Instruction> getSourceInstructions()
Get theTraversalSourceinstructions associated with this bytecode.- Returns:
- an iterable of instructions
-
getStepInstructions
public List<Bytecode.Instruction> getStepInstructions()
Get theTraversalinstructions associated with this bytecode.- Returns:
- an iterable of instructions
-
getInstructions
public Iterable<Bytecode.Instruction> getInstructions()
Get both theTraversalSourceandTraversalinstructions 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()
-
-