Search in sources :

Example 1 with TreeRangeIterator

use of org.apache.cassandra.utils.MerkleTrees.TreeRangeIterator in project cassandra by apache.

the class MerkleTreesTest method testHashRandom.

@Test
public void testHashRandom() {
    int max = 1000000;
    TOKEN_SCALE = new BigInteger("" + max);
    mts = new MerkleTrees(partitioner);
    mts.addMerkleTree(32, fullRange());
    Random random = new Random();
    while (true) {
        if (!mts.split(tok(random.nextInt(max))))
            break;
    }
    // validate the tree
    TreeRangeIterator ranges = mts.invalids();
    for (TreeRange range : ranges) range.addHash(new RowHash(range.right, new byte[0], 0));
    assert mts.hash(new Range<>(tok(-1), tok(-1))) != null : "Could not hash tree " + mts;
}
Also used : RowHash(org.apache.cassandra.utils.MerkleTree.RowHash) TreeRange(org.apache.cassandra.utils.MerkleTree.TreeRange) BigInteger(java.math.BigInteger) TreeRange(org.apache.cassandra.utils.MerkleTree.TreeRange) TreeRangeIterator(org.apache.cassandra.utils.MerkleTrees.TreeRangeIterator) Test(org.junit.Test)

Aggregations

BigInteger (java.math.BigInteger)1 RowHash (org.apache.cassandra.utils.MerkleTree.RowHash)1 TreeRange (org.apache.cassandra.utils.MerkleTree.TreeRange)1 TreeRangeIterator (org.apache.cassandra.utils.MerkleTrees.TreeRangeIterator)1 Test (org.junit.Test)1