This is an automated email from the ASF dual-hosted git repository.

smiklosovic 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 e27ba0ea34 ninja: revert count output and changed fields in 
SSTableMetadataViewer
e27ba0ea34 is described below

commit e27ba0ea349f19a5e87631f3f49d197f45dded70
Author: Stefan Miklosovic <smikloso...@apache.org>
AuthorDate: Fri Jul 7 14:43:41 2023 +0200

    ninja: revert count output and changed fields in SSTableMetadataViewer
    
    this patch also fixes incorrect visualisation of SSTable min/max local 
deletion time when no
    tombstones are present in a SSTable
    
    patch by Stefan Miklosovic; reviewed by Marcus Eriksson and Brandon 
Williams for CASSANDRA-18639
---
 .../managing/tools/sstable/sstablemetadata.adoc    | 46 ++++++++++++++++------
 .../cassandra/tools/SSTableMetadataViewer.java     | 23 ++---------
 2 files changed, 38 insertions(+), 31 deletions(-)

diff --git 
a/doc/modules/cassandra/pages/managing/tools/sstable/sstablemetadata.adoc 
b/doc/modules/cassandra/pages/managing/tools/sstable/sstablemetadata.adoc
index 202cd3a286..6eab727348 100644
--- a/doc/modules/cassandra/pages/managing/tools/sstable/sstablemetadata.adoc
+++ b/doc/modules/cassandra/pages/managing/tools/sstable/sstablemetadata.adoc
@@ -40,11 +40,11 @@ $ sstablemetadata 
/var/lib/cassandra/data/keyspace1/standard1-f6845640a6cb11e8b6
 SSTable: 
/var/lib/cassandra/data/keyspace1/standard1-f6845640a6cb11e8b6836d2c86545d91/mc-1-big
 Partitioner: org.apache.cassandra.dht.Murmur3Partitioner
 Bloom Filter FP chance: 0.010000
-Minimum timestamp: 06/28/2023 15:15:04 (1687979704767589)
-Maximum timestamp: 06/28/2023 15:15:09 (1687979709601420)
-Duration: Days: 0 Hours: 0 Minutes: 0 Seconds: 4
-SSTable min local deletion time: 08/17/292278994 02:12:55 (9223372036854775807)
-SSTable max local deletion time: 08/17/292278994 02:12:55 (9223372036854775807)
+Minimum timestamp: 07/08/2023 09:11:52 (1688800312685792)
+Maximum timestamp: 07/08/2023 09:12:03 (1688800323542149)
+Duration: Days: 0 Hours: 0 Minutes: 0 Seconds: 10
+SSTable min local deletion time: 07/08/2023 09:11:52 (1688800312)
+SSTable max local deletion time: 07/08/2023 09:12:03 (1688800323)
 Compressor: org.apache.cassandra.io.compress.LZ4Compressor
 Compression ratio: 0.553999337227618
 TTL min: 86400
@@ -263,6 +263,32 @@ $ sstablemetadata --gc_grace_seconds 5000 
/var/lib/cassandra/data/keyspace1/stan
 Estimated droppable tombstones: 0.0
 ....
 
+== Scanning of a table
+
+It is possible to specify `--scan` option to get additional statistics about a 
table which might be time-consuming.
+
+Example
+
+....
+sstablemetadata -s 
/var/lib/cassandra/data/data/ks/tb-dbead8501c9511ee805bb3deafc4499b/nc-1-big-Data.db
+....
+
+This gives you statistics such as:
+
+....
+Size: 120
+Partitions: 2
+Rows: 5
+Tombstones: 0
+Cells: 5
+Widest Partitions:
+  [2] 3
+  [1] 2
+Largest Partitions:
+  [2] 147 (147 B)
+  [1] 98 (98 B)
+....
+
 == Explanation of each value printed above
 
 |===
@@ -279,8 +305,7 @@ timestamp of any entry in this sstable, in epoch 
microseconds
 |Maximum
 timestamp |maximum timestamp of any entry in this sstable, in epoch
 microseconds
-|Duration |Difference between Maximum timestamp
-and Minimum timestamp
+|Duration |Difference between Maximum timestamp and Minimum timestamp
 |SSTable min local deletion time |minimum timestamp of
 deletion date, based on TTL, in epoch seconds 
 |SSTable max local deletion
@@ -302,10 +327,9 @@ sstable, if leveled compaction (LCS) is used
 this sstable was marked as repaired via sstablerepairedset, in epoch
 milliseconds 
 |Replay positions covered |the interval of time and commitlog
-positions related to this sstable 
-|Total Columns Cells |number of cells in the table
-|Total Rows |number of rows in the table
-|Total Partitions |total number of partitions
+positions related to this sstable
+|totalColumnsSet |number of cells in the table
+|totalRows |number of rows in the table
 |Estimated tombstone drop
 times |approximate number of rows that will expire, ordered by epoch
 seconds 
diff --git a/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java 
b/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java
index 2047111cac..2f3e39be8b 100644
--- a/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java
+++ b/src/java/org/apache/cassandra/tools/SSTableMetadataViewer.java
@@ -71,8 +71,6 @@ import static org.apache.cassandra.tools.Util.WHITE;
 import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
 import static 
org.apache.commons.lang3.time.DurationFormatUtils.formatDurationWords;
 
-import org.apache.cassandra.io.sstable.KeyIterator;
-
 /**
  * Shows the contents of sstable metadata
  */
@@ -115,7 +113,7 @@ public class SSTableMetadataViewer
 
     public static String deletion(long time)
     {
-        if (time == 0 || time == Integer.MAX_VALUE)
+        if (time == 0 || time == Long.MAX_VALUE)
         {
             return "no tombstones";
         }
@@ -323,20 +321,6 @@ public class SSTableMetadataViewer
         CompactionMetadata compaction = statsComponent.compactionMetadata();
         SerializationHeader.Component header = 
statsComponent.serializationHeader();
         Class<? extends ICompressor> compressorClass = null;
-
-        TableMetadata metadata = Util.metadataFromSSTable(descriptor);
-        SSTableReader sstable = SSTableReader.openNoValidation(null, 
descriptor, TableMetadataRef.forOfflineTools(metadata));
-        int count = 0;
-        
-        try (KeyIterator iter = sstable.keyIterator())
-        {
-            while (iter.hasNext()) 
-            {
-                iter.next();
-                count += 1;
-            }
-        }
-
         try (CompressionMetadata compression = 
CompressionInfoComponent.loadIfExists(descriptor))
         {
             compressorClass = compression != null ? 
compression.compressor().getClass() : null;
@@ -381,8 +365,8 @@ public class SSTableMetadataViewer
             field("Originating host id", stats.originatingHostId);
             field("Pending repair", stats.pendingRepair);
             field("Replay positions covered", stats.commitLogIntervals);
-            field("Total Column Cells", stats.totalColumnsSet);
-            field("Total Rows", stats.totalRows);
+            field("totalColumnsSet", stats.totalColumnsSet);
+            field("totalRows", stats.totalRows);
             field("Estimated tombstone drop times", "");
 
             TermHistogram estDropped = new 
TermHistogram(stats.estimatedTombstoneDropTime,
@@ -394,7 +378,6 @@ public class SSTableMetadataViewer
                                                          String::valueOf);
             estDropped.printHistogram(out, color, unicode);
             field("Partition Size", "");
-            field("Total Partitions", count);
             TermHistogram rowSize = new 
TermHistogram(stats.estimatedPartitionSize,
                                                       "Size (bytes)",
                                                       offset -> 
String.format("%d %s",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to