skoppu22 commented on code in PR #220:
URL:
https://github.com/apache/cassandra-analytics/pull/220#discussion_r3530502877
##########
cassandra-analytics-common/src/main/java/org/apache/cassandra/spark/common/SSTables.java:
##########
@@ -22,14 +22,52 @@
import java.nio.file.Path;
import org.apache.cassandra.bridge.SSTableDescriptor;
+import org.apache.cassandra.spark.data.FileType;
public final class SSTables
{
+ /**
+ * Suffix identifying the primary SSTable data component, e.g. "-Data.db".
+ * The leading '-' is significant: it excludes SAI per-index components
such as
+ * "...+TermsData.db" that also end with "Data.db".
+ */
+ private static final String DATA_COMPONENT_SUFFIX = "-" +
FileType.DATA.getFileSuffix();
+
+ /**
+ * Glob matching primary SSTable data components, e.g. "*-Data.db".
+ * Suitable for {@link java.nio.file.Files#newDirectoryStream(Path,
String)}.
+ */
+ public static final String DATA_COMPONENT_GLOB = "*" +
DATA_COMPONENT_SUFFIX;
+
private SSTables()
{
throw new IllegalStateException(getClass() + " is static utility class
and shall not be instantiated");
}
+ /**
+ * Determine whether the given file name is a primary SSTable data
component ("<descriptor>-Data.db").
+ * The leading '-' check excludes SAI per-index components such as
"...+TermsData.db" which also end with "Data.db".
+ *
+ * @param fileName file name (not a full path)
+ * @return true if the name is a primary data component
+ */
+ public static boolean isDataComponent(String fileName)
+ {
+ return fileName.endsWith(DATA_COMPONENT_SUFFIX);
+ }
+
+ /**
+ * Determine whether the given path is a primary SSTable data component
("<descriptor>-Data.db").
+ *
+ * @param path file path
+ * @return true if the path's file name is a primary data component
+ * @see #isDataComponent(String)
+ */
+ public static boolean isDataComponent(Path path)
+ {
+ return isDataComponent(path.getFileName().toString());
Review Comment:
Ideally shouldn't happen for sstable files, but added null check for extra
safety
##########
cassandra-analytics-common/src/main/java/org/apache/cassandra/spark/utils/CqlUtils.java:
##########
@@ -59,6 +60,9 @@ public final class CqlUtils
private static final Pattern ESCAPED_DOUBLE_BACKSLASH =
Pattern.compile("\\\\");
private static final Pattern COMPACTION_STRATEGY_PATTERN =
Pattern.compile("compaction\\s*=\\s*\\{\\s*'class'\\s*:\\s*'([^']+)'");
+ private static final Pattern MULTI_WHITESPACE_PATTERN =
Pattern.compile("\\s+");
+ private static final Pattern SAI_USING_PATTERN = Pattern.compile("USING
'[^']*STORAGEATTACHEDINDEX'");
Review Comment:
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]