public class MerkleTree
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MerkleTree.RowHash
Hash value representing a row, to be used to pass hashes to the MerkleTree.
|
static class |
MerkleTree.TreeRange
The public interface to a range in the tree.
|
static class |
MerkleTree.TreeRangeIterator
Returns the leaf (range) of a given tree in increasing order.
|
Modifier and Type | Field and Description |
---|---|
static byte |
RECOMMENDED_DEPTH |
Constructor and Description |
---|
MerkleTree(IPartitioner partitioner,
Range<Token> range,
int hashdepth,
long maxsize) |
Modifier and Type | Method and Description |
---|---|
static MerkleTree |
deserialize(DataInputPlus in,
boolean offHeapRequested,
int version) |
static MerkleTree |
deserialize(DataInputPlus in,
int version) |
static java.util.List<MerkleTree.TreeRange> |
difference(MerkleTree ltree,
MerkleTree rtree) |
boolean |
equals(java.lang.Object other) |
static int |
estimatedMaxDepthForBytes(IPartitioner partitioner,
long numBytes,
int bytesPerHash)
Estimate the allowable depth while keeping the resulting heap usage of this tree under the provided
number of bytes.
|
MerkleTree.TreeRange |
get(Token t)
For testing purposes.
|
void |
init()
Initializes this tree by splitting it until hashdepth is reached,
or until an additional level of splits would violate maxsize.
|
long |
maxsize() |
void |
maxsize(long maxsize) |
IPartitioner |
partitioner() |
void |
release() |
long |
rowCount() |
void |
serialize(DataOutputPlus out,
int version) |
long |
serializedSize(int version) |
long |
size()
The number of distinct ranges contained in this tree.
|
boolean |
split(Token t)
Splits the range containing the given token, if no tree limits would be
violated.
|
java.lang.String |
toString() |
public static final byte RECOMMENDED_DEPTH
public MerkleTree(IPartitioner partitioner, Range<Token> range, int hashdepth, long maxsize)
partitioner
- The partitioner in use.range
- the range this tree covershashdepth
- The maximum depth of the tree. 100/(2^depth) is the %
of the key space covered by each subrange of a fully populated tree.maxsize
- The maximum number of subranges in the tree.public void init()
public void release()
public IPartitioner partitioner()
public long size()
public long maxsize()
public void maxsize(long maxsize)
public static java.util.List<MerkleTree.TreeRange> difference(MerkleTree ltree, MerkleTree rtree)
ltree
- First tree.rtree
- Second tree.public boolean split(Token t)
public long rowCount()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public void serialize(DataOutputPlus out, int version) throws java.io.IOException
java.io.IOException
public long serializedSize(int version)
public static MerkleTree deserialize(DataInputPlus in, int version) throws java.io.IOException
java.io.IOException
public static MerkleTree deserialize(DataInputPlus in, boolean offHeapRequested, int version) throws java.io.IOException
java.io.IOException
public static int estimatedMaxDepthForBytes(IPartitioner partitioner, long numBytes, int bytesPerHash)
numBytes:
- The number of bytes to fit the tree withinbytesPerHash:
- The number of bytes stored in a leaf node, for example 2 * murmur128 will be 256 bits
or 32 bytespublic MerkleTree.TreeRange get(Token t)
Copyright © 2009- The Apache Software Foundation