Package com.apple.foundationdb.clientlog
Class TupleKeyCountTree
- java.lang.Object
-
- com.apple.foundationdb.clientlog.TupleKeyCountTree
-
@API(EXPERIMENTAL) public class TupleKeyCountTree extends Object
A tree of occurrence counts tuple-encoded keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TupleKeyCountTree.Printer
-
Constructor Summary
Constructors Constructor Description TupleKeyCountTree()
TupleKeyCountTree(TupleKeyCountTree parent, byte[] bytes, Object object)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(byte[] packed)
Add encoded tuple bytes to the tree.void
add(Tuple tuple)
Add the given tuple to the tree.TupleKeyCountTree
addPrefixChild(Object prefix)
Add a non-tuple object to the root of the tree.byte[]
getBytes()
Collection<TupleKeyCountTree>
getChildren()
int
getCount()
Object
getObject()
TupleKeyCountTree
getParent()
boolean
hasObject()
void
hideLessThanFraction(double fraction)
Hide tree nodes that do not have counts at least as great as the given fraction of their parent node.boolean
isVisible()
protected TupleKeyCountTree
newChild(byte[] childBytes, Object object)
protected TupleKeyCountTree
newPrefixChild(byte[] prefixBytes, Object prefix)
protected void
printTree(int depth, int nancestors, TupleKeyCountTree.Printer printer, String collapseSeparator)
void
printTree(TupleKeyCountTree.Printer printer, String collapseSeparator)
Print this tree to the given printer.void
setVisible(boolean visible)
String
toString()
-
-
-
Constructor Detail
-
TupleKeyCountTree
public TupleKeyCountTree()
-
TupleKeyCountTree
public TupleKeyCountTree(@Nullable TupleKeyCountTree parent, @Nonnull byte[] bytes, @Nullable Object object)
-
-
Method Detail
-
getBytes
@Nonnull public byte[] getBytes()
-
hasObject
public boolean hasObject()
-
add
public void add(@Nonnull Tuple tuple)
Add the given tuple to the tree. Each element is added to the next deeper level in the tree, incrementing the count as it goes.- Parameters:
tuple
- the tuple to add
-
add
public void add(@Nonnull byte[] packed)
Add encoded tuple bytes to the tree.- Parameters:
packed
- the packed form of a tuple to be parsed and added to the tree
-
addPrefixChild
@Nonnull public TupleKeyCountTree addPrefixChild(@Nonnull Object prefix)
Add a non-tuple object to the root of the tree.- Parameters:
prefix
- an object for the top level child of the tree- Returns:
- a subtree for the given object
-
newPrefixChild
@Nonnull protected TupleKeyCountTree newPrefixChild(@Nonnull byte[] prefixBytes, @Nonnull Object prefix)
-
newChild
@Nonnull protected TupleKeyCountTree newChild(@Nonnull byte[] childBytes, @Nonnull Object object)
-
getCount
public int getCount()
-
getParent
@Nullable public TupleKeyCountTree getParent()
-
getChildren
@Nonnull public Collection<TupleKeyCountTree> getChildren()
-
isVisible
public boolean isVisible()
-
setVisible
public void setVisible(boolean visible)
-
hideLessThanFraction
public void hideLessThanFraction(double fraction)
Hide tree nodes that do not have counts at least as great as the given fraction of their parent node.- Parameters:
fraction
- the threshold count fraction
-
printTree
public void printTree(@Nonnull TupleKeyCountTree.Printer printer, @Nullable String collapseSeparator)
Print this tree to the given printer.- Parameters:
printer
- the printer to be called for each visible level of the treecollapseSeparator
- a string to be used to separate the printed forms of levels with only a single child
-
printTree
protected void printTree(int depth, int nancestors, @Nonnull TupleKeyCountTree.Printer printer, @Nullable String collapseSeparator)
-
-