K
- the type of the Map entry keysV
- the type of the Map entry valuespublic class QueryRecorder<K,V> extends Object implements InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>, ExternalizableLite, PortableObject
QueryRecord
object that
contains an estimated or actual cost of the query execution for a given filter.
For example, the following code will print a QueryRecord, containing the estimated query cost and corresponding execution steps.
QueryRecorder agent = new QueryRecorder(RecordType.EXPLAIN); QueryRecord record = (QueryRecord) cache.aggregate(filter, agent); System.out.println(record);
Modifier and Type | Class and Description |
---|---|
static class |
QueryRecorder.RecordType
RecordType enum specifies whether the
QueryRecorder should be
used to produce a QueryRecord object that
contains an estimated or an actual cost of the query execution. |
ALLOW_INCONSISTENCIES, BY_MEMBER, BY_PARTITION, PARALLEL, PRESENT_ONLY, RETAINS_ENTRIES, SERIAL
Constructor and Description |
---|
QueryRecorder()
Default constructor (necessary for the ExternalizableLite interface).
|
QueryRecorder(QueryRecorder.RecordType type)
Construct a QueryRecorder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
Accumulate one entry into the result.
|
boolean |
accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
Accumulate multiple entries into the result.
|
QueryRecord |
aggregate(Set<? extends InvocableMap.Entry<? extends K,? extends V>> setEntries)
Process a set of InvocableMap.Entry objects in order to produce an
aggregated result.
|
int |
characteristics()
A bit mask representing the set of characteristics of this aggregator.
|
boolean |
combine(QueryRecord.PartialResult partialResult)
Merge another partial result into the result.
|
QueryRecord |
finalizeResult()
Return the final result of the aggregation.
|
QueryRecord.PartialResult |
getPartialResult()
Return the partial result of the aggregation.
|
QueryRecorder.RecordType |
getType()
Get the record type for this query recorder.
|
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from
the passed DataInput object.
|
void |
readExternal(PofReader in)
Restore the contents of a user type instance by reading its state using
the specified PofReader object.
|
InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord> |
supply()
Create a new instance of this aggregator.
|
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into
the passed DataOutput object.
|
void |
writeExternal(PofWriter out)
Save the contents of a POF user type instance by writing its state using
the specified PofWriter object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isAllowInconsistencies, isByMember, isByPartition, isParallel, isPresentOnly, isRetainsEntries, isSerial
public QueryRecorder()
public QueryRecorder(QueryRecorder.RecordType type)
type
- the type for this aggregatorpublic QueryRecorder.RecordType getType()
public QueryRecord aggregate(Set<? extends InvocableMap.Entry<? extends K,? extends V>> setEntries)
aggregate
in interface InvocableMap.EntryAggregator<K,V,QueryRecord>
aggregate
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
setEntries
- a Set of read-only InvocableMap.Entry objects to
aggregatepublic InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord> supply()
InvocableMap.StreamingAggregator
supply
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
public boolean accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
InvocableMap.StreamingAggregator
Important note: The default implementation of this method provides necessary logic for aggregation short-circuiting and should rarely (if ever) be overridden by the custom aggregator implementation.
accumulate
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
streamer
- a Streamer
that can be used to iterate over
entries to addtrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedpublic boolean accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
InvocableMap.StreamingAggregator
accumulate
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
entry
- the entry to accumulate into the aggregation resulttrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedpublic boolean combine(QueryRecord.PartialResult partialResult)
InvocableMap.StreamingAggregator
combine
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
partialResult
- the partial result to mergetrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedpublic QueryRecord.PartialResult getPartialResult()
InvocableMap.StreamingAggregator
getPartialResult
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
public QueryRecord finalizeResult()
InvocableMap.StreamingAggregator
finalizeResult
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
public int characteristics()
InvocableMap.StreamingAggregator
Be default, characteristics are a combination of InvocableMap.StreamingAggregator.PARALLEL
and InvocableMap.StreamingAggregator.RETAINS_ENTRIES
, which is sub-optimal and should be
overridden by the aggregator implementation if the aggregator does not
need to retain entries (which is often the case).
characteristics
in interface InvocableMap.StreamingAggregator<K,V,QueryRecord.PartialResult,QueryRecord>
InvocableMap.StreamingAggregator.PARALLEL
,
InvocableMap.StreamingAggregator.SERIAL
,
InvocableMap.StreamingAggregator.BY_MEMBER
,
InvocableMap.StreamingAggregator.BY_PARTITION
,
InvocableMap.StreamingAggregator.RETAINS_ENTRIES
,
InvocableMap.StreamingAggregator.PRESENT_ONLY
public void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this objectIOException
- if an I/O exception occursNotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object toIOException
- if an I/O exception occurspublic void readExternal(PofReader in) throws IOException
readExternal
in interface PortableObject
in
- the PofReader from which to read the object's stateIOException
- if an I/O error occurspublic void writeExternal(PofWriter out) throws IOException
writeExternal
in interface PortableObject
out
- the PofWriter to which to write the object's stateIOException
- if an I/O error occurs