Class QueryImpl

  • All Implemented Interfaces:
    Query

    public class QueryImpl
    extends java.lang.Object
    implements Query
    Represents a parsed query.
    • Field Detail

      • TOO_MANY_UNION

        public static final java.lang.UnsupportedOperationException TOO_MANY_UNION
      • MAX_UNION

        public static final int MAX_UNION
    • 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
      • getLimit

        public java.util.Optional<java.lang.Long> getLimit()
        Specified by:
        getLimit in interface Query
      • getOffset

        public java.util.Optional<java.lang.Long> getOffset()
        Specified by:
        getOffset 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 java.lang.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 java.lang.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
      • getSelectorIndex

        public int getSelectorIndex​(java.lang.String selectorName)
        Specified by:
        getSelectorIndex in interface Query
      • getColumnIndex

        public int getColumnIndex​(java.lang.String columnName)
        Specified by:
        getColumnIndex in interface Query
      • getBindVariableValue

        public PropertyValue getBindVariableValue​(java.lang.String bindVariableName)
      • getSelectorNames

        public java.lang.String[] getSelectorNames()
        Specified by:
        getSelectorNames in interface Query
      • getBindVariableNames

        public java.util.List<java.lang.String> getBindVariableNames()
        Specified by:
        getBindVariableNames in interface Query
      • 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
      • getTree

        public Tree getTree​(java.lang.String path)
        Specified by:
        getTree in interface Query
      • getOakPath

        public java.lang.String getOakPath​(java.lang.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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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 java.lang.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