Class QueryImpl

  • All Implemented Interfaces:
    Query

    public class QueryImpl
    extends Object
    implements Query
    Represents a parsed query.
    • Method Detail

      • init

        public void init()
        Description copied from interface: Query
        Initialize the query. This will 'wire' selectors into constraints, and collect bind variable names. It will also simplify expressions if possible, but will not prepare the query.
        Specified by:
        init in interface Query
      • setLimit

        public void setLimit​(long limit)
        Specified by:
        setLimit in interface Query
      • setOffset

        public void setOffset​(long offset)
        Specified by:
        setOffset in interface Query
      • setExplain

        public void setExplain​(boolean explain)
        Specified by:
        setExplain in interface Query
      • setMeasure

        public void setMeasure​(boolean measure)
        Specified by:
        setMeasure in interface Query
      • setDistinct

        public void setDistinct​(boolean distinct)
      • isSortedByIndex

        public boolean isSortedByIndex()
        Description copied from interface: Query
        Returns whether the results will be sorted by index. The query must already be prepared.
        Specified by:
        isSortedByIndex in interface Query
        Returns:
        if sorted by index
      • getPlan

        public String getPlan()
        Description copied from interface: Query
        Get the query plan. The query must already be prepared.
        Specified by:
        getPlan in interface Query
        Returns:
        the query plan
      • getIndexCostInfo

        public String getIndexCostInfo()
        Description copied from interface: Query
        Get the index cost as a JSON string. The query must already be prepared.
        Specified by:
        getIndexCostInfo in interface Query
        Returns:
        the index cost
      • getEstimatedCost

        public double getEstimatedCost()
        Description copied from interface: Query
        Get the estimated cost.
        Specified by:
        getEstimatedCost in interface Query
        Returns:
        the estimated cost
      • prepare

        public void prepare()
        Description copied from interface: Query
        Prepare the query. The cost is estimated and the execution plan is decided here.
        Specified by:
        prepare in interface Query
      • getBindVariableValue

        public PropertyValue getBindVariableValue​(String bindVariableName)
      • setTraversalEnabled

        public void setTraversalEnabled​(boolean traversalEnabled)
        Specified by:
        setTraversalEnabled in interface Query
      • setQueryOptions

        public void setQueryOptions​(QueryOptions options)
        Description copied from interface: Query
        Set the query option to be used for this query.
        Specified by:
        setQueryOptions in interface Query
        Parameters:
        options - the options
      • isPotentiallySlow

        public boolean isPotentiallySlow()
        Description copied from interface: Query
        Whether the query is potentially slow. Only supported for prepared queries.
        Specified by:
        isPotentiallySlow in interface Query
        Returns:
        true if traversal is the only option
      • verifyNotPotentiallySlow

        public void verifyNotPotentiallySlow()
        Description copied from interface: Query
        Verify the query is not potentially slow. Only supported for prepared queries.
        Specified by:
        verifyNotPotentiallySlow in interface Query
      • getOakPath

        public String getOakPath​(String path)
        Validate the path is syntactically correct, and convert it to an Oak internal path (including namespace remapping if needed).
        Parameters:
        path - the path
        Returns:
        the the converted path
      • getSize

        public long getSize()
        Description copied from interface: Query
        Get the size if known.
        Specified by:
        getSize in interface Query
        Returns:
        the size, or -1 if unknown
      • getSize

        public long getSize​(Result.SizePrecision precision,
                            long max)
        Description copied from interface: Query
        Get the size if known.
        Specified by:
        getSize in interface Query
        Parameters:
        precision - the required precision
        max - the maximum nodes read (for an exact size)
        Returns:
        the size, or -1 if unknown
      • getStatement

        public String getStatement()
        Specified by:
        getStatement in interface Query
        Returns:
        the original statement as it was used to construct the object. If not provided the toString() will be used instead.
      • setInternal

        public void setInternal​(boolean isInternal)
        Specified by:
        setInternal in interface Query
      • saturatedAdd

        public static long saturatedAdd​(long x,
                                        long y)
        Add two values, but don't let it overflow or underflow.
        Parameters:
        x - the first value
        y - the second value
        Returns:
        the sum, or Long.MIN_VALUE for underflow, or Long.MAX_VALUE for overflow
      • buildAlternativeQuery

        public Query buildAlternativeQuery()
        Description copied from interface: Query
        Try to convert the query to an alternative form, specially a "union". To avoid any potential error due to state variables perform the conversion before the Query.init().
        Specified by:
        buildAlternativeQuery in interface Query
        Returns:
        this if no conversions are possible or a new instance of a Query. Cannot return null.
      • copyOf

        public Query copyOf()
        Description copied from interface: Query

        returns a clone of the current object. Will throw an exception in case it's invoked in a non appropriate moment. For example the default QueryImpl cannot be cloned once the Query.init() has been executed.

        May return null if not implemented.

        Specified by:
        copyOf in interface Query
        Returns:
        a clone of self
      • isInit

        public boolean isInit()
        Specified by:
        isInit in interface Query
        Returns:
        true if the query has been already initialised. false otherwise.
      • isInternal

        public boolean isInternal()
        Specified by:
        isInternal in interface Query
        Returns:
        true if the current query is internal. false otherwise.
      • containsUnfilteredFullTextCondition

        public boolean containsUnfilteredFullTextCondition()
        Description copied from interface: Query
        Whether the condition contains a fulltext condition that can not be applied to the filter, for example because it is part of an "or" condition of the form "where a=1 or contains(., 'x')".
        Specified by:
        containsUnfilteredFullTextCondition in interface Query
        Returns:
        true if yes