skoppu22 commented on code in PR #206:
URL: 
https://github.com/apache/cassandra-analytics/pull/206#discussion_r3775858385


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/data/backup/BackupReader.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cassandra.spark.data.backup;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.LongConsumer;
+
+import com.google.common.collect.RangeMap;
+import org.jetbrains.annotations.NotNull;
+
+import org.apache.cassandra.analytics.stats.Stats;
+import org.apache.cassandra.spark.data.FileType;
+import org.apache.cassandra.spark.data.ReplicationFactor;
+import org.apache.cassandra.spark.data.S3ClientConfig;
+import org.apache.cassandra.spark.data.SSTableKey;
+import org.apache.cassandra.spark.data.partitioner.CassandraInstance;
+import org.apache.cassandra.spark.data.partitioner.Partitioner;
+import org.apache.cassandra.spark.utils.streaming.StreamConsumer;
+
+/**
+ * Pluggable backup-reader API. Implementations encapsulate the 
format-specific knowledge for a
+ * given backup implementation. Concrete factories are registered with {@link 
BackupReaderRegistry} on the
+ * driver and selected via the {@code backupReaderType} option; the data layer 
programs strictly
+ * against this interface.
+ *
+ * <p>Implementations are {@link Serializable} so the data layer can ship a 
configured reader to
+ * executors inside the Spark task closure, and {@link AutoCloseable} so the 
data layer can
+ * release reader-local resources on shutdown.
+ */
+public interface BackupReader extends Serializable, AutoCloseable
+{
+    /**
+     * Populates the reader's per-(cluster, keyspace, table) cache by walking 
the backup manifest.
+     *
+     * @param clusterName logical cluster identity (UUID or human-readable 
name)
+     * @param keyspace    Cassandra keyspace
+     * @param table       Cassandra table
+     * @param datacenter  datacenter to read from
+     */
+    void initializeSSTableInfoCache(String clusterName, String keyspace, 
String table, String datacenter)
+        throws IllegalArgumentException;
+
+    /**
+     * Lists Cassandra instances present in the backup for the given dataset 
slice.
+     *
+     * @param clusterName logical cluster identity
+     * @param keyspace    Cassandra keyspace
+     * @param table       Cassandra table
+     * @param datacenter  datacenter to read from
+     * @return Cassandra instances contributing to this slice
+     */
+    List<CassandraInstance> instances(String clusterName, String keyspace, 
String table, String datacenter);
+
+    /**
+     * Discovers SSTables across all nodes for the given dataset slice.
+     *
+     * @param clusterName logical cluster identity
+     * @param keyspace    Cassandra keyspace
+     * @param table       Cassandra table
+     * @param datacenter  datacenter to read from
+     * @return map of SSTable key to per-file-type sizes
+     */
+    Map<SSTableKey, Map<FileType, Long>> sstables(String clusterName, String 
keyspace, String table, String datacenter);
+
+    /**
+     * Discovers SSTables for a single node.
+     *
+     * @param clusterName logical cluster identity
+     * @param keyspace    Cassandra keyspace
+     * @param table       Cassandra table
+     * @param datacenter  datacenter to read from
+     * @param nodeId      node identifier whose SSTables to enumerate
+     * @return map of SSTable key to per-file-type sizes for the given node
+     */
+    Map<SSTableKey, Map<FileType, Long>> sstables(String clusterName,
+                                                  String keyspace,
+                                                  String table,
+                                                  String datacenter,
+                                                  String nodeId);
+
+    /**
+     * Buffered ranged GET; completes with the full {@code [start, end]} byte 
range.
+     *
+     * @param clusterName logical cluster identity
+     * @param datacenter  datacenter to read from
+     * @param token       Cassandra token (used for path resolution by some 
implementations)
+     * @param sstableKey  identifies the SSTable
+     * @param fileType    which SSTable component to read
+     * @param start       inclusive byte offset
+     * @param end         inclusive byte offset
+     * @param stats       per-task stats sink for S3 operation metrics
+     * @return future completing with the read bytes
+     */
+    CompletableFuture<byte[]> readAsync(String clusterName,

Review Comment:
   There is no sharable Decrypter interface. It would be helpful to have a 
BackupDecryptor interface so organizations can implement BackupDecryptor only 
to tune policies while sharing other parts of the logic.
   
   readAsync ─► decryptor.decryptRange(...)
   getAsync  ─► decryptor.decryptRange(...)
   



-- 
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