java.lang.Object
com.carrotsearch.hppc.PlaModel
- All Implemented Interfaces:
Accountable
Optimal Piecewise Linear Approximation Model for
KType keys.
Learns a mapping that returns a position for a KType key which is at most epsilon
away from the correct one in a sorted list of keys. It is optimal and piecewise because it learns
the minimum number of epsilon-approximate segments.
The PLA-model consists of a sequence segments. A segment s is a triple (key,slope,intercept) that indexes a range of keys through the function fs(k) = k × slope + intercept, which provides an epsilon-approximation of the position of the key k.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceConsumer notified when a new segment is built by thePlaModel. -
Constructor Summary
ConstructorsConstructorDescriptionPlaModel(int epsilon) Creates an optimal PLA-model with the provided epsilon precision. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKey(double key, int index, PlaModel.SegmentConsumer segmentConsumer) Adds a key to this PLA-model.voidfinish(PlaModel.SegmentConsumer segmentConsumer) Finishes the PLA-model construction.longAllocated memory estimationlongBytes that is actually been usedvoidsetEpsilon(int epsilon) Sets epsilon precision which must be greater than or equal to 0.
-
Constructor Details
-
PlaModel
public PlaModel(int epsilon) Creates an optimal PLA-model with the provided epsilon precision.- Parameters:
epsilon- must be greater than or equal to 0.
-
-
Method Details
-
setEpsilon
public void setEpsilon(int epsilon) Sets epsilon precision which must be greater than or equal to 0. -
addKey
Adds a key to this PLA-model. The keys must be provided in a strictly increasing sequence. That is, the key must be greater than the previous key.- Parameters:
index- The index of the key in the sorted key list.segmentConsumer- The consumer to call when a new segment is built in the PLA-model.
-
finish
Finishes the PLA-model construction. Declares that no additional keys will be added. Builds the last segment and calls the providedPlaModel.SegmentConsumer. -
ramBytesAllocated
public long ramBytesAllocated()Description copied from interface:AccountableAllocated memory estimation- Specified by:
ramBytesAllocatedin interfaceAccountable- Returns:
- Ram allocated in bytes
-
ramBytesUsed
public long ramBytesUsed()Description copied from interface:AccountableBytes that is actually been used- Specified by:
ramBytesUsedin interfaceAccountable- Returns:
- Ram used in bytes
-