Package org.apache.solr.search.facet
Class SlotAcc
- java.lang.Object
-
- org.apache.solr.search.facet.SlotAcc
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public abstract class SlotAcc extends Object implements Closeable
Accumulates statistics separated by a slot number. There is a separate statistic per slot. The slot is usually an ordinal into a set of values, e.g. tracking a count frequency per term. Sometimes there doesn't need to be a slot distinction, in which case there is just one nominal slot.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SlotAcc.Resizer
static class
SlotAcc.SlotContext
Incapsulates information about the current slot, for Accumulators that may want additional info during collection.
-
Field Summary
Fields Modifier and Type Field Description protected int
currentDocBase
protected org.apache.lucene.index.LeafReaderContext
currentReaderContext
protected org.apache.solr.search.facet.FacetContext
fcontext
-
Constructor Summary
Constructors Constructor Description SlotAcc(org.apache.solr.search.facet.FacetContext fcontext)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
void
collect(int doc, int slot)
Deprecated.This method exists only for backcompatibility, developers of newSlotAcc
implementations should not implement this method, and should instead overridecollect(int,int,IntFunction)
void
collect(int doc, int slot, IntFunction<SlotAcc.SlotContext> slotContext)
Deprecated.int
collect(DocSet docs, int slot, IntFunction<SlotAcc.SlotContext> slotContext)
Bulk collection of all documents in a slot.abstract int
compare(int slotA, int slotB)
abstract Object
getValue(int slotNum)
abstract void
reset()
Called to reset the acc to a fresh state, ready for reuseprotected void
resetIterators()
Typically called from setNextReader to reset docValue iteratorsabstract void
resize(SlotAcc.Resizer resizer)
void
setNextReader(org.apache.lucene.index.LeafReaderContext readerContext)
NOTE: this currently detects when it is being reused and calls resetIterators by comparing reader ords with previous calls to setNextReader.void
setValues(SimpleOrderedMap<Object> bucket, int slotNum)
-
-
-
Method Detail
-
setNextReader
public void setNextReader(org.apache.lucene.index.LeafReaderContext readerContext) throws IOException
NOTE: this currently detects when it is being reused and calls resetIterators by comparing reader ords with previous calls to setNextReader. For this reason, current users must call setNextReader in segment order. Failure to do so will cause worse performance.- Throws:
IOException
-
collect
@Deprecated public void collect(int doc, int slot) throws IOException
Deprecated.This method exists only for backcompatibility, developers of newSlotAcc
implementations should not implement this method, and should instead overridecollect(int,int,IntFunction)
- Throws:
IOException
-
collect
@Deprecated public void collect(int doc, int slot, IntFunction<SlotAcc.SlotContext> slotContext) throws IOException
Deprecated.All subclasses should override this method, for backcompatability the default implementaion delegates to the (deprecated)collect(int,int)
- Parameters:
doc
- Single Segment docId (relative to the currentLeafReaderContext
to collectslot
- The slot number to collect this document inslotContext
- A callback that can be used for Accumulators that would like additional info about the current slot -- theIntFunction
is only garunteed to be valid for the current slot, and theSlotAcc.SlotContext
returned is only valid for the duration of thecollect()
call.- Throws:
IOException
-
collect
public int collect(DocSet docs, int slot, IntFunction<SlotAcc.SlotContext> slotContext) throws IOException
Bulk collection of all documents in a slot. The default implementation callscollect(int,int,IntFunction)
- Parameters:
docs
- (global) Documents to collectslot
- The slot number to collect these documents inslotContext
- A callback that can be used for Accumulators that would like additional info about the current slot -- theIntFunction
is only garunteed to be valid for the current slot, and theSlotAcc.SlotContext
returned is only valid for the duration of thecollect()
call.- Throws:
IOException
-
compare
public abstract int compare(int slotA, int slotB)
-
getValue
public abstract Object getValue(int slotNum) throws IOException
- Throws:
IOException
-
setValues
public void setValues(SimpleOrderedMap<Object> bucket, int slotNum) throws IOException
- Throws:
IOException
-
reset
public abstract void reset() throws IOException
Called to reset the acc to a fresh state, ready for reuse- Throws:
IOException
-
resetIterators
protected void resetIterators() throws IOException
Typically called from setNextReader to reset docValue iterators- Throws:
IOException
-
resize
public abstract void resize(SlotAcc.Resizer resizer)
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-