public class KeyHistogram extends Object
Accumulate and hold information about the distribution of Key
objects
in a Persistit Tree
. This class is used by the
Exchange.computeHistogram(Key, Key, int, int, KeyFilter, int)
method
to accumulate and return the result of scanning all the keys at a fixed depth
within a Tree.
The result is represented by a List of
KeyHistogram.KeyCount
objects, each
representing a key and a count. The count represents the number of smaller
keys in the tree level. With this information client applications can
estimate the number of elements between any two keys in the Tree.
Application code can specify a
keyDepth
at which sibling keys
are grouped together. For example, suppose a Tree contains keys such as
{"BLUE",1} {"BLUE",2} {"BLUE",3} {"RED",1} {"RED",2}If
keyDepth=2
the resulting histogram will have 5 buckets, each
with a count value of 1. But if keyDepth=1
the
result will have two buckets, one each for "BLUE" and "RED". Specifying
keyDepth=0
turns off aggregation by partial key depth.
During the aggregation process the Exchange.computeHistogram(com.persistit.Key, com.persistit.Key, int, int, com.persistit.KeyFilter, int)
method
invokes the addKeyCopy(com.persistit.Key)
method for each Key it traverses. Each key is
analyzed to determine whether the first keyDepth
segments are
the same as the previously added Key. If so then the previous count is
incremented; otherwise a new KeyCount entry is added to the sample list.
Modifier and Type | Class and Description |
---|---|
static class |
KeyHistogram.KeyCount
Element in a
KeyHistogram that denotes the estimated number
of keys in a histogram bucket. |
Constructor and Description |
---|
KeyHistogram(Tree tree,
Key start,
Key end,
int sampleSize,
int keyDepth,
int treeDepth) |
Modifier and Type | Method and Description |
---|---|
Key |
getEndKey() |
int |
getKeyCount() |
int |
getKeyDepth() |
long |
getPageBytesInUse() |
long |
getPageBytesTotal() |
int |
getPageCount() |
int |
getRequestedSampleSize() |
List<KeyHistogram.KeyCount> |
getSamples() |
int |
getSampleSize() |
Key |
getStartKey() |
Tree |
getTree() |
int |
getTreeDepth() |
public Tree getTree()
public Key getStartKey()
public Key getEndKey()
public int getKeyCount()
public int getRequestedSampleSize()
public int getSampleSize()
public List<KeyHistogram.KeyCount> getSamples()
public int getTreeDepth()
public int getKeyDepth()
public int getPageCount()
public long getPageBytesTotal()
public long getPageBytesInUse()
Copyright © 2025 Open Identity Platform Community. All rights reserved.