Class ResultSetIntersection<O>
- java.lang.Object
-
- com.googlecode.cqengine.resultset.ResultSet<O>
-
- com.googlecode.cqengine.resultset.connective.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
-
-
Constructor Summary
Constructors Constructor Description ResultSetIntersection(Iterable<ResultSet<O>> resultSets, Query<O> query, QueryOptions queryOptions)
ResultSetIntersection(Iterable<ResultSet<O>> resultSets, Query<O> query, QueryOptions queryOptions, boolean indexMergeStrategyEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes all of the underlyingResultSet
s.boolean
contains(O object)
Returns true if the given object is contained in all underlying ResultSets.int
getMergeCost()
Returns the merge cost from the underlyingResultSet
with the lowest merge cost.Query<O>
getQuery()
Returns the query for which this ResultSet provides results.QueryOptions
getQueryOptions()
Returns the query options associated with the query.int
getRetrievalCost()
Returns the retrieval cost from the underlyingResultSet
which has the lowest merge cost.Iterator<O>
iterator()
boolean
matches(O object)
Similar to theResultSet.contains(Object)
method, but checks for logical containment in the ResultSet as opposed to physical containment in the ResultSet.int
size()
Returns the number of objects which would be returned by thisResultSet
if iterated.-
Methods inherited from class com.googlecode.cqengine.resultset.ResultSet
isEmpty, isNotEmpty, spliterator, stream, uniqueResult
-
-
-
-
Method Detail
-
contains
public boolean contains(O object)
Returns true if the given object is contained in all underlying ResultSets.
-
matches
public boolean matches(O object)
Description copied from class:ResultSet
Similar to theResultSet.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 theResultSet.contains(Object)
method to make the determination. This method will perform better thanResultSet.contains(Object)
in cases where querying indexes is more expensive than querying attributes, which is usually the case.
-
size
public int size()
Description copied from class:ResultSet
Returns the number of objects which would be returned by thisResultSet
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 simpleOr
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.
-
getRetrievalCost
public int getRetrievalCost()
Returns the retrieval cost from the underlyingResultSet
which has the lowest merge cost.- Specified by:
getRetrievalCost
in classResultSet<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 underlyingResultSet
with the lowest merge cost.- Specified by:
getMergeCost
in classResultSet<O>
- Returns:
- the merge cost from the underlying
ResultSet
with the lowest merge cost
-
close
public void close()
Closes all of the underlyingResultSet
s.
-
getQuery
public Query<O> getQuery()
Description copied from class:ResultSet
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 classResultSet<O>
- Returns:
- The query options associated with the query.
-
-