smiklosovic commented on code in PR #3374:
URL: https://github.com/apache/cassandra/pull/3374#discussion_r1876881667


##########
src/java/org/apache/cassandra/service/snapshot/TableSnapshot.java:
##########
@@ -287,66 +473,79 @@ protected static String buildSnapshotId(String 
keyspaceName, String tableName, U
         return String.format("%s:%s:%s:%s", keyspaceName, tableName, tableId, 
tag);
     }
 
-    public static class SnapshotTrueSizeCalculator extends 
DirectorySizeCalculator
+    public static Set<Descriptor> getSnapshotDescriptors(String keyspace, 
String table, String tag)
     {
-        /**
-         * Snapshots are composed of hard-linked sstables. The true snapshot 
size should only include
-         * snapshot files which do not contain a corresponding "live" sstable 
file.
-         */
-        @Override
-        public boolean isAcceptable(Path snapshotFilePath)
+        try
         {
-            return !getLiveFileFromSnapshotFile(snapshotFilePath).exists();
-        }
-    }
+            Refs<SSTableReader> snapshotSSTableReaders = 
getSnapshotSSTableReaders(keyspace, table, tag);
 
-    /**
-     * Returns the corresponding live file for a given snapshot file.
-     *
-     * Example:
-     *  - Base table:
-     *    - Snapshot file: 
~/.ccm/test/node1/data0/test_ks/tbl-e03faca0813211eca100c705ea09b5ef/snapshots/1643481737850/me-1-big-Data.db
-     *    - Live file: 
~/.ccm/test/node1/data0/test_ks/tbl-e03faca0813211eca100c705ea09b5ef/me-1-big-Data.db
-     *  - Secondary index:
-     *    - Snapshot file: 
~/.ccm/test/node1/data0/test_ks/tbl-e03faca0813211eca100c705ea09b5ef/snapshots/1643481737850/.tbl_val_idx/me-1-big-Summary.db
-     *    - Live file: 
~/.ccm/test/node1/data0/test_ks/tbl-e03faca0813211eca100c705ea09b5ef/.tbl_val_idx/me-1-big-Summary.db
-     *
-     */
-    static File getLiveFileFromSnapshotFile(Path snapshotFilePath)
-    {
-        // Snapshot directory structure format is 
{data_dir}/snapshots/{snapshot_name}/{snapshot_file}
-        Path liveDir = snapshotFilePath.getParent().getParent().getParent();
-        if (Directories.isSecondaryIndexFolder(snapshotFilePath.getParent()))
+            Set<Descriptor> descriptors = new HashSet<>();
+            for (SSTableReader ssTableReader : snapshotSSTableReaders)
+            {
+                descriptors.add(ssTableReader.descriptor);
+            }
+
+            return descriptors;
+        }
+        catch (IOException e)
         {
-            // Snapshot file structure format is 
{data_dir}/snapshots/{snapshot_name}/.{index}/{sstable-component}.db
-            liveDir = File.getPath(liveDir.getParent().toString(), 
snapshotFilePath.getParent().getFileName().toString());
+            throw Throwables.unchecked(e);
         }
-        return new File(liveDir.toString(), 
snapshotFilePath.getFileName().toString());
     }
 
-    public static Predicate<TableSnapshot> shouldClearSnapshot(String tag, 
long olderThanTimestamp)
+    public static Refs<SSTableReader> getSnapshotSSTableReaders(String 
keyspace, String table, String tag) throws IOException

Review Comment:
   will be done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to