Class ResultSetIntersection<O>

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Iterable<O>

    public class ResultSetIntersection<O>
    extends ResultSet<O>
    A ResultSet which provides a view onto the intersection of other ResultSets.
    Author:
    Niall Gallagher
    • Method Detail

      • contains

        public boolean contains​(O object)
        Returns true if the given object is contained in all underlying ResultSets.
        Specified by:
        contains in class ResultSet<O>
        Parameters:
        object - An object to check if contained
        Returns:
        true if the given object is contained in all underlying ResultSets, false if it is not contained in one or more ResultSets or if there are no underlying result sets
      • matches

        public boolean matches​(O object)
        Description copied from class: ResultSet
        Similar to the ResultSet.contains(Object) method, but checks for logical containment in the ResultSet as opposed to physical containment in the ResultSet. Determines if the given object would be contained in the ResultSet, by testing if the given object matches the query for which this ResultSet was generated, instead of actually checking if the object is contained in appropriate indexes.

        This method will typically make the determination by evaluating the query on the given object on-the-fly without accessing indexes, however in some cases this method might delegate to the ResultSet.contains(Object) method to make the determination.

        This method will perform better than ResultSet.contains(Object) in cases where querying indexes is more expensive than querying attributes, which is usually the case.

        Specified by:
        matches in class ResultSet<O>
        Parameters:
        object - The object to check for logical containment in this ResultSet
        Returns:
        True if this ResultSet logically contains the given object, false if it does not
      • size

        public int size()
        Description copied from class: ResultSet
        Returns the number of objects which would be returned by this ResultSet if iterated.

        Note that the cost of calling this method depends on the query for which it was constructed.

        For simple queries where a single query is supplied and a matching index exists, or where several such simple queries are supplied and are connected using a simple Or query, calculating the size via this method will be cheaper than iterating through the ResultSet and counting the number of objects individually.

        For more complex queries, where intersections must be performed or where no suitable indexes exist, calling this method can be non-trivial, but it will always be at least as cheap as iterating through the ResultSet and counting the number of objects individually.

        Specified by:
        size in class ResultSet<O>
        Returns:
        The number of objects which would be returned by this ResultSet if iterated
      • getRetrievalCost

        public int getRetrievalCost()
        Returns the retrieval cost from the underlying ResultSet which has the lowest merge cost.
        Specified by:
        getRetrievalCost in class ResultSet<O>
        Returns:
        the retrieval cost from the underlying ResultSet which has the lowest merge cost
      • getMergeCost

        public int getMergeCost()
        Returns the merge cost from the underlying ResultSet with the lowest merge cost.
        Specified by:
        getMergeCost in class ResultSet<O>
        Returns:
        the merge cost from the underlying ResultSet with the lowest merge cost
      • getQuery

        public Query<O> getQuery()
        Description copied from class: ResultSet
        Returns the query for which this ResultSet provides results.
        Specified by:
        getQuery in class ResultSet<O>
        Returns:
        The query for which this ResultSet provides results.
      • getQueryOptions

        public QueryOptions getQueryOptions()
        Description copied from class: ResultSet
        Returns the query options associated with the query.
        Specified by:
        getQueryOptions in class ResultSet<O>
        Returns:
        The query options associated with the query.