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
The GValueManager class is responsible for managing the state of GValue instances 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:
  • Constructor Details

    • GValueManager

      public GValueManager()
      Creates a new empty GValueManager.
  • Method Details

    • mergeInto

      public void mergeInto(GValueManager other)
      Merges the internal registries of the current GValueManager into another GValueManager. Transfers the state of the gValueRegistry and stepRegistry from the current instance to the specified target instance.
      Parameters:
      other - the target GValueManager into 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 of GValue objects 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.
      Overrides:
      clone in class Object
      Returns:
      a new GValueManager instance with cloned state
    • pinGValues

      public void pinGValues(Set<String> names)
      Pin a collection of GValue by name from the internal registry. Iteratively processes each GValue name to pin it to its current value.
    • pinGValues

      public void pinGValues(Collection<GValue<?>> gValues)
      Pin a collection of GValue instances from the internal registry. Iteratively processes each GValue to pin it to its current value.
    • 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 update
      value - the new value for the variable
      Throws:
      IllegalArgumentException - if the variable is not registered or is already pinned