public class QueryResult extends Object implements Result<QueryResult>, Iterable<QueryResultRow>
rows
.
There are two modes of the result construction, the selection of the mode is
controlled by the orderAndLimitExpected
parameter:
orderAndLimitExpected
is true
, this indicates that
the call to the orderAndLimit(com.hazelcast.query.PagingPredicate, java.util.Map.Entry<java.lang.Integer, java.util.Map.Entry>)
method is expected on behalf of the
paging predicate
involved in the query. In this case,
the intermediate result is represented as a collection of queryable entries
to allow the comparison of the items using
the comparator of the paging predicate. After the call to completeConstruction(java.util.Collection<java.lang.Integer>)
, all the queryable entries are converted to rows
and the result is ready to be provided to the client.
orderAndLimitExpected
is false
, this indicates that
no calls to the orderAndLimit(com.hazelcast.query.PagingPredicate, java.util.Map.Entry<java.lang.Integer, java.util.Map.Entry>)
method are expected. In this case, the
intermediate result is represented directly as a collection of rows
and no further conversion is performed.
Constructor and Description |
---|
QueryResult()
Constructs an empty result for the purposes of deserialization.
|
QueryResult(IterationType iterationType,
Projection projection,
SerializationService serializationService,
long resultLimit,
boolean orderAndLimitExpected)
Constructs an empty result.
|
Modifier and Type | Method and Description |
---|---|
void |
add(QueryableEntry entry)
Adds the given entry to this result.
|
void |
addRow(QueryResultRow row)
Adds the given row into this result.
|
void |
combine(QueryResult result)
Combines the given result with this result modifying this result.
|
void |
completeConstruction(Collection<Integer> partitionIds)
Completes the construction of this result.
|
QueryResult |
createSubResult()
Creates a new empty sub result of the same type as this result.
|
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
Collection<Integer> |
getPartitionIds()
Returns partition IDs associated with this result or
null if this
result is an empty/failure result. |
List<QueryResultRow> |
getRows() |
boolean |
isEmpty() |
Iterator<QueryResultRow> |
iterator() |
void |
onCombineFinished()
Invoked when the result combining phase is finished.
|
void |
orderAndLimit(PagingPredicate pagingPredicate,
Map.Entry<Integer,Map.Entry> nearestAnchorEntry)
Performs the order-and-limit operation on this result for the given
paging predicate.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
void |
setPartitionIds(Collection<Integer> partitionIds)
Sets the partition IDs of this result.
|
int |
size() |
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public QueryResult()
public QueryResult(IterationType iterationType, Projection projection, SerializationService serializationService, long resultLimit, boolean orderAndLimitExpected)
iterationType
- the iteration type of the query for which
this result is constructed for.projection
- the projection of the query for which this
result is constructed for.serializationService
- the serialization service associated with
the query for which this result is
constructed for.resultLimit
- the upper limit on the number of items that
can be added
to this result.orderAndLimitExpected
- the flag to signal that the call to the
orderAndLimit(com.hazelcast.query.PagingPredicate, java.util.Map.Entry<java.lang.Integer, java.util.Map.Entry>)
method is expected,
see the class javadoc for more details.public Iterator<QueryResultRow> iterator()
iterator
in interface Iterable<QueryResultRow>
public int size()
public boolean isEmpty()
true
if this result is empty, false
otherwise.public void addRow(QueryResultRow row)
row
- the row to add.public void add(QueryableEntry entry)
add
in interface Result<QueryResult>
entry
- the entry to add.QueryResultSizeExceededException
- if the size of this result
exceeds the result size limit.public QueryResult createSubResult()
Result
This method is used by the query execution engine while constructing the partial sub results. These sub results are combined with this result during the final stage of the result construction.
createSubResult
in interface Result<QueryResult>
public void orderAndLimit(PagingPredicate pagingPredicate, Map.Entry<Integer,Map.Entry> nearestAnchorEntry)
Result
orderAndLimit
in interface Result<QueryResult>
pagingPredicate
- the paging predicate to perform the operation
for.nearestAnchorEntry
- the anchor entry of the paging predicate.public void completeConstruction(Collection<Integer> partitionIds)
Result
Implementations may release intermediary resources associated with the construction in this method. No further modifications of the result are expected after this method invocation except combining the result with other results.
completeConstruction
in interface Result<QueryResult>
partitionIds
- the partition IDs to associate this result with.Result.combine(Result)
public Collection<Integer> getPartitionIds()
Result
null
if this
result is an empty/failure result.getPartitionIds
in interface Result<QueryResult>
public void combine(QueryResult result)
Result
combine
in interface Result<QueryResult>
result
- the result to combine with.Result.onCombineFinished()
public void onCombineFinished()
Result
Implementations may release intermediary resources associated with
the combining. No further calls to Result.combine(T)
are expected after
this method invocation.
onCombineFinished
in interface Result<QueryResult>
Result.combine(Result)
public void setPartitionIds(Collection<Integer> partitionIds)
Result
setPartitionIds
in interface Result<QueryResult>
partitionIds
- the partition IDs to set.public List<QueryResultRow> getRows()
public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2022 Hazelcast, Inc.. All Rights Reserved.