skoppu22 commented on code in PR #169:
URL:
https://github.com/apache/cassandra-analytics/pull/169#discussion_r2988875487
##########
cassandra-analytics-common/src/main/java/org/apache/cassandra/bridge/CassandraVersion.java:
##########
@@ -68,36 +97,126 @@ public String jarBaseName()
return jarBaseName;
}
- private static final String sstableFormat;
+ /**
+ * Get the set of SSTable formats supported by this Cassandra version.
+ *
+ * @return Set of supported SSTable format strings
+ */
+ public Set<String> sstableFormats()
+ {
+ return sstableFormats;
+ }
+
+ /**
+ * Get the ordered list of native SSTable version strings for this
Cassandra version.
+ * The order matches the definition in the enum and represents version
progression.
+ * For example, in FOURZERO: ["big-na", "big-nb"], big-nb is considered
newer/higher.
+ *
+ * @return Ordered list of native SSTable version strings
+ */
+ public List<String> getNativeSStableVersions()
+ {
+ return nativeSStableVersions;
+ }
+
+ /**
+ * Get the index/position of an SSTable version within this Cassandra
version's native versions.
+ * This can be used for version comparison while sorting sstable versions
from oldest to latest order.
+ *
+ * @param sstableVersion The SSTable version string to find
+ * @return Index of the version (0-based), or -1 if not found
+ */
+ public int getSSTableVersionIndex(String sstableVersion)
+ {
+ return nativeSStableVersions.indexOf(sstableVersion);
+ }
+
+ /**
+ * Get the set of SSTable version strings that this Cassandra version can
read.
+ * This includes:
+ * - Native versions for this Cassandra version
+ * - All SSTable versions from the previous major version (including all
minor versions)
+ * For example, Cassandra 5.0 can read:
+ * - 5.0 native versions (big-oa, bti-da)
+ * - 4.0 versions (big-na, big-nb)
+ * - 4.1 versions (if any)
+ * But NOT 3.0 versions
+ *
+ * @return Set of full SSTable version strings that can be read
+ */
+ public Set<String> getSupportedSStableVersionsForRead()
+ {
+ Set<String> readableVersions = new
HashSet<>(this.nativeSStableVersions);
+
+ int previousMajor = getPreviousMajorVersion();
+
+ // Add all SSTable versions from the previous major version and its
minors
+ // E.g., C* 5.0 (version 50) can read C* 4.0 (40) and C* 4.1 (41)
SSTables, but not C* 3.x (30)
+ for (CassandraVersion version : CassandraVersion.values())
+ {
+ // Include versions from the previous major version family (e.g.,
40-49 for C* 5.0)
+ if (version.versionNumber() >= previousMajor &&
version.versionNumber() < this.number)
+ {
+ readableVersions.addAll(version.nativeSStableVersions);
+ }
+ }
+
+ return Collections.unmodifiableSet(readableVersions);
+ }
+
+ /**
+ * Get the previous major version number for this Cassandra version.
+ * Calculates dynamically using: (majorVersion - 1) * 10
+ * For example:
+ * - C5.0 (50) returns 40 (C4.x)
+ * - C4.1 (41) returns 30 (C3.x)
+ * - C4.0 (40) returns 30 (C3.x)
+ * - C3.0 (30) returns 20 (C2.x - which doesn't exist)
+ * - C10.0 (100) returns 90 (C9.x)
+ *
+ * @return previous major version number
+ */
+ @VisibleForTesting
+ int getPreviousMajorVersion()
+ {
+ // Get major version: 50 -> 5, 41 -> 4, 40 -> 4, 30 -> 3
+ int majorVersion = this.number / 10;
+
+ // Calculate previous major version: (majorVersion - 1) * 10
+ // E.g., 5 -> 40, 4 -> 30, 3 -> 20
+ return (majorVersion - 1) * 10;
Review Comment:
C* 5.0 supports can read C* 4.0, 4.1, 4.2 ...
C* 4.x can read C* 3.0, 3.1, ..
We cannot add all minor versions and won't be able to keep up with C*
release cycle if we do so. Also this PR goal is to make C* analytics
independent of C* version numbers. Hence dynamically calculating this makes
analytics independent of C* releases.
--
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]