Class GValueManager
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.process.traversal.GValueManager
-
- All Implemented Interfaces:
Serializable,Cloneable
public final class GValueManager extends Object implements Serializable, Cloneable
TheGValueManagerclass is responsible for managing the state ofGValueinstances and their associations with `Step` objects in a traversal. This class ensures that `GValue` instances are properly extracted and stored in a registry, allowing for dynamic query optimizations and state management during traversal execution.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GValueManager()Creates a new empty GValueManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GValueManagerclone()Creates a deep copy of this GValueManager with cloned GValue instances.Set<GValue<?>>getGValues()Gets the set ofGValueobjects used in this traversal.Set<GValue<?>>getPinnedGValues()Gets the set of pinned GValues used in this traversal.Set<String>getPinnedVariableNames()Gets the set of variable names used in this traversal which have been pinned to specific values.Set<String>getUnpinnedVariableNames()Gets the set of variable names used in this traversal which have not been pinned to specific values.Set<String>getVariableNames()Gets the set of variable names used in this traversal.booleanhasUnpinnedVariables()Determines whether the manager has unpinned GValues.booleanhasVariables()Determines whether the manager has step registrations.voidmergeInto(GValueManager other)Merges the internal registries of the currentGValueManagerinto anotherGValueManager.voidpinGValues(Collection<GValue<?>> gValues)Pin a collection ofGValueinstances from the internal registry.voidpinGValues(Set<String> names)Pin a collection ofGValueby name from the internal registry.booleanpinVariable(String name)Pins any GValue with the provided name.voidregister(Collection<GValue<?>> gValues)Registers a collection of GValues in the internal registry.voidregister(GValue<?> gValue)Registers a GValue in the internal registry if it represents a variable.voidupdateVariable(String name, Object value)Updates the value of a registered variable.
-
-
-
Method Detail
-
mergeInto
public void mergeInto(GValueManager other)
Merges the internal registries of the currentGValueManagerinto anotherGValueManager. Transfers the state of thegValueRegistryandstepRegistryfrom the current instance to the specified target instance.- Parameters:
other- the targetGValueManagerinto which the current instance's registries will be merged
-
getVariableNames
public Set<String> getVariableNames()
Gets the set of variable names used in this traversal.
-
getUnpinnedVariableNames
public Set<String> getUnpinnedVariableNames()
Gets the set of variable names used in this traversal which have not been pinned to specific values.
-
getPinnedVariableNames
public Set<String> getPinnedVariableNames()
Gets the set of variable names used in this traversal which have been pinned to specific values.
-
getGValues
public Set<GValue<?>> getGValues()
Gets the set ofGValueobjects used in this traversal.
-
getPinnedGValues
public Set<GValue<?>> getPinnedGValues()
Gets the set of pinned GValues used in this traversal.
-
hasVariables
public boolean hasVariables()
Determines whether the manager has step registrations.
-
hasUnpinnedVariables
public boolean hasUnpinnedVariables()
Determines whether the manager has unpinned GValues.
-
pinVariable
public boolean pinVariable(String name)
Pins any GValue with the provided name. This should be called anytime an optimization alters the Traversal based on the current value of a GValue. This indicates that the resulting traversal is only valid for the current value of this GValue, and is not generalizable to any parameter value.- Parameters:
name- the name of the GValue to be pinned- Returns:
- true if name was previously unpinned, false otherwise.
- Throws:
IllegalArgumentException- if no GValue of the given name is registered
-
clone
public GValueManager clone()
Creates a deep copy of this GValueManager with cloned GValue instances.
-
pinGValues
public void pinGValues(Collection<GValue<?>> gValues)
-
register
public void register(GValue<?> gValue)
Registers a GValue in the internal registry if it represents a variable. Non-variables are not registered.- Parameters:
gValue- the GValue to register- Throws:
IllegalArgumentException- if a different GValue with the same name is already registered
-
register
public void register(Collection<GValue<?>> gValues)
Registers a collection of GValues in the internal registry. Non-variables are not registered.- Parameters:
gValues- the collection of GValues to register
-
updateVariable
public void updateVariable(String name, Object value)
Updates the value of a registered variable.- Parameters:
name- the name of the variable to updatevalue- the new value for the variable- Throws:
IllegalArgumentException- if the variable is not registered or is already pinned
-
-