Repository: cassandra Updated Branches: refs/heads/trunk ef37df4e4 -> ce7f5cc33
Fix EstimatedHistogram creation in nodetool tablehistograms patch by yukim; reviewed by Paulo Motta for CASSANDRA-10859 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ce7f5cc3 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ce7f5cc3 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ce7f5cc3 Branch: refs/heads/trunk Commit: ce7f5cc332a3f5f8c49a4bc22dbb33bddb813a3d Parents: ef37df4 Author: Yuki Morishita <yu...@apache.org> Authored: Wed Dec 16 16:54:40 2015 -0600 Committer: Yuki Morishita <yu...@apache.org> Committed: Fri Dec 18 16:50:43 2015 -0600 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../tools/nodetool/TableHistograms.java | 10 ++++------ .../cassandra/utils/EstimatedHistogram.java | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce7f5cc3/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 6bbded8..e8fbc0d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.2 + * Fix EstimatedHistogram creation in nodetool tablehistograms (CASSANDRA-10859) * Establish bootstrap stream sessions sequentially (CASSANDRA-6992) * Sort compactionhistory output by timestamp (CASSANDRA-10464) * More efficient BTree removal (CASSANDRA-9991) http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce7f5cc3/src/java/org/apache/cassandra/tools/nodetool/TableHistograms.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/tools/nodetool/TableHistograms.java b/src/java/org/apache/cassandra/tools/nodetool/TableHistograms.java index f3f9b8a..8f4ffa6 100644 --- a/src/java/org/apache/cassandra/tools/nodetool/TableHistograms.java +++ b/src/java/org/apache/cassandra/tools/nodetool/TableHistograms.java @@ -79,14 +79,12 @@ public class TableHistograms extends NodeToolCmd } else { - long[] partitionSizeBucketOffsets = new EstimatedHistogram(estimatedPartitionSize.length).getBucketOffsets(); - long[] columnCountBucketOffsets = new EstimatedHistogram(estimatedColumnCount.length).getBucketOffsets(); - EstimatedHistogram partitionSizeHist = new EstimatedHistogram(partitionSizeBucketOffsets, estimatedPartitionSize); - EstimatedHistogram columnCountHist = new EstimatedHistogram(columnCountBucketOffsets, estimatedColumnCount); + EstimatedHistogram partitionSizeHist = new EstimatedHistogram(estimatedPartitionSize); + EstimatedHistogram columnCountHist = new EstimatedHistogram(estimatedColumnCount); if (partitionSizeHist.isOverflowed()) { - System.err.println(String.format("Row sizes are larger than %s, unable to calculate percentiles", partitionSizeBucketOffsets[partitionSizeBucketOffsets.length - 1])); + System.err.println(String.format("Row sizes are larger than %s, unable to calculate percentiles", partitionSizeHist.getLargestBucketOffset())); for (int i = 0; i < offsetPercentiles.length; i++) estimatedRowSizePercentiles[i] = Double.NaN; } @@ -98,7 +96,7 @@ public class TableHistograms extends NodeToolCmd if (columnCountHist.isOverflowed()) { - System.err.println(String.format("Column counts are larger than %s, unable to calculate percentiles", columnCountBucketOffsets[columnCountBucketOffsets.length - 1])); + System.err.println(String.format("Column counts are larger than %s, unable to calculate percentiles", columnCountHist.getLargestBucketOffset())); for (int i = 0; i < estimatedColumnCountPercentiles.length; i++) estimatedColumnCountPercentiles[i] = Double.NaN; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce7f5cc3/src/java/org/apache/cassandra/utils/EstimatedHistogram.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/utils/EstimatedHistogram.java b/src/java/org/apache/cassandra/utils/EstimatedHistogram.java index 0249980..aa141f7 100644 --- a/src/java/org/apache/cassandra/utils/EstimatedHistogram.java +++ b/src/java/org/apache/cassandra/utils/EstimatedHistogram.java @@ -65,6 +65,18 @@ public class EstimatedHistogram buckets = new AtomicLongArray(bucketOffsets.length + 1); } + /** + * Create EstimatedHistogram from only bucket data. + * + * @param bucketData bucket data + */ + public EstimatedHistogram(long[] bucketData) + { + assert bucketData != null && bucketData.length > 0 : "Bucket data must be an array of size more than 0"; + bucketOffsets = newOffsets(bucketData.length - 1, false); + buckets = new AtomicLongArray(bucketData); + } + public EstimatedHistogram(long[] offsets, long[] bucketData) { assert bucketData.length == offsets.length +1; @@ -242,6 +254,14 @@ public class EstimatedHistogram } /** + * @return the largest bucket offset + */ + public long getLargestBucketOffset() + { + return bucketOffsets[bucketOffsets.length - 1]; + } + + /** * @return true if this histogram has overflowed -- that is, a value larger than our largest bucket could bound was added */ public boolean isOverflowed()