This is an automated email from the ASF dual-hosted git repository. blerer pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push: new fd5dcc5 MerkleTrees variables renaming tree -> trees. fd5dcc5 is described below commit fd5dcc51cb09041585fa16c24149d0a66e415b54 Author: xiang.wang <xiang.w...@kaiostech.com> AuthorDate: Mon Jul 19 17:32:12 2021 +0400 MerkleTrees variables renaming tree -> trees. Patch by Xiang Wang; reviewed by Aleksei Zotov, Benjamin Lerer and Ekaterina Dimitrova --- .../apache/cassandra/repair/ValidationManager.java | 12 +++---- .../org/apache/cassandra/repair/Validator.java | 22 ++++++------ .../org/apache/cassandra/utils/MerkleTrees.java | 10 +++--- .../apache/cassandra/repair/LocalSyncTaskTest.java | 8 ++--- .../org/apache/cassandra/repair/RepairJobTest.java | 12 +++---- .../org/apache/cassandra/repair/ValidatorTest.java | 16 ++++----- .../repair/asymmetric/DifferenceHolderTest.java | 42 +++++++++++----------- .../cassandra/service/SerializationsTest.java | 14 ++++---- 8 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/java/org/apache/cassandra/repair/ValidationManager.java b/src/java/org/apache/cassandra/repair/ValidationManager.java index 7f3c0df..1b6ef56 100644 --- a/src/java/org/apache/cassandra/repair/ValidationManager.java +++ b/src/java/org/apache/cassandra/repair/ValidationManager.java @@ -49,7 +49,7 @@ public class ValidationManager private static MerkleTrees createMerkleTrees(ValidationPartitionIterator validationIterator, Collection<Range<Token>> ranges, ColumnFamilyStore cfs) { - MerkleTrees tree = new MerkleTrees(cfs.getPartitioner()); + MerkleTrees trees = new MerkleTrees(cfs.getPartitioner()); long allPartitions = validationIterator.estimatedPartitions(); Map<Range<Token>, Long> rangePartitionCounts = validationIterator.getRangePartitionCounts(); @@ -73,15 +73,15 @@ public class ValidationManager : 0; // determine tree depth from number of partitions, capping at max tree depth (CASSANDRA-5263) int depth = numPartitions > 0 ? (int) Math.min(Math.ceil(Math.log(numPartitions) / Math.log(2)), maxDepth) : 0; - tree.addMerkleTree((int) Math.pow(2, depth), range); + trees.addMerkleTree((int) Math.pow(2, depth), range); } if (logger.isDebugEnabled()) { // MT serialize may take time - logger.debug("Created {} merkle trees with merkle trees size {}, {} partitions, {} bytes", tree.ranges().size(), tree.size(), allPartitions, MerkleTrees.serializer.serializedSize(tree, 0)); + logger.debug("Created {} merkle trees with merkle trees size {}, {} partitions, {} bytes", trees.ranges().size(), trees.size(), allPartitions, MerkleTrees.serializer.serializedSize(trees, 0)); } - return tree; + return trees; } private static ValidationPartitionIterator getValidationIterator(TableRepairManager repairManager, Validator validator) throws IOException, NoSuchRepairSessionException @@ -112,11 +112,11 @@ public class ValidationManager long estimatedTotalBytes = 0; try (ValidationPartitionIterator vi = getValidationIterator(cfs.getRepairManager(), validator)) { - MerkleTrees tree = createMerkleTrees(vi, validator.desc.ranges, cfs); + MerkleTrees trees = createMerkleTrees(vi, validator.desc.ranges, cfs); try { // validate the CF as we iterate over it - validator.prepare(cfs, tree); + validator.prepare(cfs, trees); while (vi.hasNext()) { try (UnfilteredRowIterator partition = vi.next()) diff --git a/src/java/org/apache/cassandra/repair/Validator.java b/src/java/org/apache/cassandra/repair/Validator.java index 4e50d60..2fe2703 100644 --- a/src/java/org/apache/cassandra/repair/Validator.java +++ b/src/java/org/apache/cassandra/repair/Validator.java @@ -100,21 +100,21 @@ public class Validator implements Runnable this.evenTreeDistribution = evenTreeDistribution; } - public void prepare(ColumnFamilyStore cfs, MerkleTrees tree) + public void prepare(ColumnFamilyStore cfs, MerkleTrees trees) { - this.trees = tree; + this.trees = trees; - if (!tree.partitioner().preservesOrder() || evenTreeDistribution) + if (!trees.partitioner().preservesOrder() || evenTreeDistribution) { - // You can't beat an even tree distribution for md5 - tree.init(); + // You can't beat even trees distribution for md5 + trees.init(); } else { List<DecoratedKey> keys = new ArrayList<>(); Random random = new Random(); - for (Range<Token> range : tree.ranges()) + for (Range<Token> range : trees.ranges()) { for (DecoratedKey sample : cfs.keySamples(range)) { @@ -124,8 +124,8 @@ public class Validator implements Runnable if (keys.isEmpty()) { - // use an even tree distribution - tree.init(range); + // use even trees distribution + trees.init(range); } else { @@ -134,15 +134,15 @@ public class Validator implements Runnable while (true) { DecoratedKey dk = keys.get(random.nextInt(numKeys)); - if (!tree.split(dk.getToken())) + if (!trees.split(dk.getToken())) break; } keys.clear(); } } } - logger.debug("Prepared AEService trees of size {} for {}", trees.size(), desc); - ranges = tree.rangeIterator(); + logger.debug("Prepared AEService trees of size {} for {}", this.trees.size(), desc); + ranges = trees.rangeIterator(); } /** diff --git a/src/java/org/apache/cassandra/utils/MerkleTrees.java b/src/java/org/apache/cassandra/utils/MerkleTrees.java index 984f84e..15469d3 100644 --- a/src/java/org/apache/cassandra/utils/MerkleTrees.java +++ b/src/java/org/apache/cassandra/utils/MerkleTrees.java @@ -381,15 +381,15 @@ public class MerkleTrees implements Iterable<Map.Entry<Range<Token>, MerkleTree> /** * Get the differences between the two sets of MerkleTrees. * - * @param ltree - * @param rtree + * @param ltrees + * @param rtrees * @return */ - public static List<Range<Token>> difference(MerkleTrees ltree, MerkleTrees rtree) + public static List<Range<Token>> difference(MerkleTrees ltrees, MerkleTrees rtrees) { List<Range<Token>> differences = new ArrayList<>(); - for (MerkleTree tree : ltree.merkleTrees.values()) - differences.addAll(MerkleTree.difference(tree, rtree.getMerkleTree(tree.fullRange))); + for (MerkleTree tree : ltrees.merkleTrees.values()) + differences.addAll(MerkleTree.difference(tree, rtrees.getMerkleTree(tree.fullRange))); return differences; } diff --git a/test/unit/org/apache/cassandra/repair/LocalSyncTaskTest.java b/test/unit/org/apache/cassandra/repair/LocalSyncTaskTest.java index 58e4cc9..68804d0 100644 --- a/test/unit/org/apache/cassandra/repair/LocalSyncTaskTest.java +++ b/test/unit/org/apache/cassandra/repair/LocalSyncTaskTest.java @@ -233,10 +233,10 @@ public class LocalSyncTaskTest extends AbstractRepairTest private MerkleTrees createInitialTree(RepairJobDesc desc, IPartitioner partitioner) { - MerkleTrees tree = new MerkleTrees(partitioner); - tree.addMerkleTrees((int) Math.pow(2, 15), desc.ranges); - tree.init(); - return tree; + MerkleTrees trees = new MerkleTrees(partitioner); + trees.addMerkleTrees((int) Math.pow(2, 15), desc.ranges); + trees.init(); + return trees; } private MerkleTrees createInitialTree(RepairJobDesc desc) diff --git a/test/unit/org/apache/cassandra/repair/RepairJobTest.java b/test/unit/org/apache/cassandra/repair/RepairJobTest.java index 19e06e9..231ebcd 100644 --- a/test/unit/org/apache/cassandra/repair/RepairJobTest.java +++ b/test/unit/org/apache/cassandra/repair/RepairJobTest.java @@ -819,19 +819,19 @@ public class RepairJobTest private MerkleTrees createInitialTree(boolean invalidate) { - MerkleTrees tree = new MerkleTrees(MURMUR3_PARTITIONER); - tree.addMerkleTrees((int) Math.pow(2, 15), FULL_RANGE); - tree.init(); + MerkleTrees trees = new MerkleTrees(MURMUR3_PARTITIONER); + trees.addMerkleTrees((int) Math.pow(2, 15), FULL_RANGE); + trees.init(); if (invalidate) { // change a range in one of the trees Token token = MURMUR3_PARTITIONER.midpoint(FULL_RANGE.get(0).left, FULL_RANGE.get(0).right); - tree.invalidate(token); - tree.get(token).hash("non-empty hash!".getBytes()); + trees.invalidate(token); + trees.get(token).hash("non-empty hash!".getBytes()); } - return tree; + return trees; } private void interceptRepairMessages(Map<InetAddressAndPort, MerkleTrees> mockTrees, diff --git a/test/unit/org/apache/cassandra/repair/ValidatorTest.java b/test/unit/org/apache/cassandra/repair/ValidatorTest.java index cf3411a..5cc0545 100644 --- a/test/unit/org/apache/cassandra/repair/ValidatorTest.java +++ b/test/unit/org/apache/cassandra/repair/ValidatorTest.java @@ -111,21 +111,21 @@ public class ValidatorTest ColumnFamilyStore cfs = Keyspace.open(keyspace).getColumnFamilyStore(columnFamily); Validator validator = new Validator(desc, remote, 0, PreviewKind.NONE); - MerkleTrees tree = new MerkleTrees(partitioner); - tree.addMerkleTrees((int) Math.pow(2, 15), validator.desc.ranges); - validator.prepare(cfs, tree); + MerkleTrees trees = new MerkleTrees(partitioner); + trees.addMerkleTrees((int) Math.pow(2, 15), validator.desc.ranges); + validator.prepare(cfs, trees); - // and confirm that the tree was split - assertTrue(tree.size() > 1); + // and confirm that the trees were split + assertTrue(trees.size() > 1); // add a row Token mid = partitioner.midpoint(range.left, range.right); validator.add(EmptyIterators.unfilteredRow(cfs.metadata(), new BufferDecoratedKey(mid, ByteBufferUtil.bytes("inconceivable!")), false)); validator.complete(); - // confirm that the tree was validated - Token min = tree.partitioner().getMinimumToken(); - assertNotNull(tree.hash(new Range<>(min, min))); + // confirm that the trees were validated + Token min = trees.partitioner().getMinimumToken(); + assertNotNull(trees.hash(new Range<>(min, min))); Message message = outgoingMessageSink.get(TEST_TIMEOUT, TimeUnit.SECONDS); assertEquals(Verb.VALIDATION_RSP, message.verb()); diff --git a/test/unit/org/apache/cassandra/repair/asymmetric/DifferenceHolderTest.java b/test/unit/org/apache/cassandra/repair/asymmetric/DifferenceHolderTest.java index 8ec0177..c37e3d7 100644 --- a/test/unit/org/apache/cassandra/repair/asymmetric/DifferenceHolderTest.java +++ b/test/unit/org/apache/cassandra/repair/asymmetric/DifferenceHolderTest.java @@ -54,13 +54,13 @@ public class DifferenceHolderTest InetAddressAndPort a1 = InetAddressAndPort.getByName("127.0.0.1"); InetAddressAndPort a2 = InetAddressAndPort.getByName("127.0.0.2"); - MerkleTrees mt1 = new MerkleTrees(Murmur3Partitioner.instance); - MerkleTrees mt2 = new MerkleTrees(Murmur3Partitioner.instance); - mt1.init(); - mt2.init(); + MerkleTrees mts1 = new MerkleTrees(Murmur3Partitioner.instance); + MerkleTrees mts2 = new MerkleTrees(Murmur3Partitioner.instance); + mts1.init(); + mts2.init(); - TreeResponse tr1 = new TreeResponse(a1, mt1); - TreeResponse tr2 = new TreeResponse(a2, mt2); + TreeResponse tr1 = new TreeResponse(a1, mts1); + TreeResponse tr2 = new TreeResponse(a2, mts2); DifferenceHolder dh = new DifferenceHolder(Lists.newArrayList(tr1, tr2)); assertTrue(dh.get(a1).get(a2).isEmpty()); @@ -75,35 +75,35 @@ public class DifferenceHolderTest InetAddressAndPort a1 = InetAddressAndPort.getByName("127.0.0.1"); InetAddressAndPort a2 = InetAddressAndPort.getByName("127.0.0.2"); // merkle tree building stolen from MerkleTreesTest: - MerkleTrees mt1 = new MerkleTrees(partitioner); - MerkleTrees mt2 = new MerkleTrees(partitioner); - mt1.addMerkleTree(32, fullRange); - mt2.addMerkleTree(32, fullRange); - mt1.init(); - mt2.init(); + MerkleTrees mts1 = new MerkleTrees(partitioner); + MerkleTrees mts2 = new MerkleTrees(partitioner); + mts1.addMerkleTree(32, fullRange); + mts2.addMerkleTree(32, fullRange); + mts1.init(); + mts2.init(); // add dummy hashes to both trees - for (MerkleTree.TreeRange range : mt1.rangeIterator()) + for (MerkleTree.TreeRange range : mts1.rangeIterator()) range.addAll(new MerkleTreesTest.HIterator(range.right)); - for (MerkleTree.TreeRange range : mt2.rangeIterator()) + for (MerkleTree.TreeRange range : mts2.rangeIterator()) range.addAll(new MerkleTreesTest.HIterator(range.right)); MerkleTree.TreeRange leftmost = null; MerkleTree.TreeRange middle = null; - mt1.maxsize(fullRange, maxsize + 2); // give some room for splitting + mts1.maxsize(fullRange, maxsize + 2); // give some room for splitting // split the leftmost - Iterator<MerkleTree.TreeRange> ranges = mt1.rangeIterator(); + Iterator<MerkleTree.TreeRange> ranges = mts1.rangeIterator(); leftmost = ranges.next(); - mt1.split(leftmost.right); + mts1.split(leftmost.right); // set the hashes for the leaf of the created split - middle = mt1.get(leftmost.right); + middle = mts1.get(leftmost.right); middle.hash(digest("arbitrary!")); - mt1.get(partitioner.midpoint(leftmost.left, leftmost.right)).hash(digest("even more arbitrary!")); + mts1.get(partitioner.midpoint(leftmost.left, leftmost.right)).hash(digest("even more arbitrary!")); - TreeResponse tr1 = new TreeResponse(a1, mt1); - TreeResponse tr2 = new TreeResponse(a2, mt2); + TreeResponse tr1 = new TreeResponse(a1, mts1); + TreeResponse tr2 = new TreeResponse(a2, mts2); DifferenceHolder dh = new DifferenceHolder(Lists.newArrayList(tr1, tr2)); assertTrue(dh.get(a1).get(a2).size() == 1); diff --git a/test/unit/org/apache/cassandra/service/SerializationsTest.java b/test/unit/org/apache/cassandra/service/SerializationsTest.java index f4b3b1c..07a9bab 100644 --- a/test/unit/org/apache/cassandra/service/SerializationsTest.java +++ b/test/unit/org/apache/cassandra/service/SerializationsTest.java @@ -115,20 +115,20 @@ public class SerializationsTest extends AbstractSerializationsTester { IPartitioner p = RandomPartitioner.instance; - MerkleTrees mt = new MerkleTrees(p); + MerkleTrees mts = new MerkleTrees(p); // empty validation - mt.addMerkleTree((int) Math.pow(2, 15), FULL_RANGE); + mts.addMerkleTree((int) Math.pow(2, 15), FULL_RANGE); Validator v0 = new Validator(DESC, FBUtilities.getBroadcastAddressAndPort(), -1, PreviewKind.NONE); - ValidationResponse c0 = new ValidationResponse(DESC, mt); + ValidationResponse c0 = new ValidationResponse(DESC, mts); // validation with a tree - mt = new MerkleTrees(p); - mt.addMerkleTree(Integer.MAX_VALUE, FULL_RANGE); + mts = new MerkleTrees(p); + mts.addMerkleTree(Integer.MAX_VALUE, FULL_RANGE); for (int i = 0; i < 10; i++) - mt.split(p.getRandomToken()); + mts.split(p.getRandomToken()); Validator v1 = new Validator(DESC, FBUtilities.getBroadcastAddressAndPort(), -1, PreviewKind.NONE); - ValidationResponse c1 = new ValidationResponse(DESC, mt); + ValidationResponse c1 = new ValidationResponse(DESC, mts); // validation failed ValidationResponse c3 = new ValidationResponse(DESC); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org