smiklosovic commented on code in PR #4458:
URL: https://github.com/apache/cassandra/pull/4458#discussion_r2517802847
##########
src/java/org/apache/cassandra/db/compression/CompressionDictionaryManager.java:
##########
@@ -244,6 +251,68 @@ public CompositeData getTrainingState()
return dictionaryTrainer.getTrainingState().toCompositeData();
}
+ @Override
+ public TabularData listCompressionDictionaries()
+ {
+ List<LightweightCompressionDictionary> dictionaries =
SystemDistributedKeyspace.retrieveLightweightCompressionDictionaries(keyspaceName,
tableName);
+ TabularDataSupport tableData = new
TabularDataSupport(CompressionDictionaryDetailsTabularData.TABULAR_TYPE);
+
+ if (dictionaries == null)
+ {
+ return tableData;
+ }
+
+ for (LightweightCompressionDictionary dictionary : dictionaries)
+ {
+
tableData.put(CompressionDictionaryDetailsTabularData.fromLightweightCompressionDictionary(dictionary));
+ }
+
+ return tableData;
+ }
+
+ @Override
+ public CompositeData getCompressionDictionary()
+ {
+ CompressionDictionary compressionDictionary =
SystemDistributedKeyspace.retrieveLatestCompressionDictionary(keyspaceName,
tableName);
+ if (compressionDictionary == null)
+ return null;
+
+ return
CompressionDictionaryDetailsTabularData.fromCompressionDictionary(keyspaceName,
tableName, compressionDictionary);
+ }
+
+ @Override
+ public CompositeData getCompressionDictionary(long dictId)
+ {
+ CompressionDictionary compressionDictionary =
SystemDistributedKeyspace.retrieveCompressionDictionary(keyspaceName,
tableName, dictId);
+ if (compressionDictionary == null)
+ return null;
+
+ return
CompressionDictionaryDetailsTabularData.fromCompressionDictionary(keyspaceName,
tableName, compressionDictionary);
+ }
+
+ @Override
+ public synchronized void importCompressionDictionary(CompositeData
compositeData)
+ {
+ CompressionDictionaryDataObject dataObject =
CompressionDictionaryDetailsTabularData.fromCompositeData(compositeData);
+
+ if (!keyspaceName.equals(dataObject.keyspace) ||
!tableName.equals(dataObject.table))
+ throw new IllegalArgumentException(format("Keyspace and table of a
dictionary to import (%s.%s) does not correspond to the keyspace and table this
manager is responsible for (%s.%s)",
+ dataObject.keyspace,
dataObject.table,
+ keyspaceName,
tableName));
+
+ CompressionDictionary.Kind kind =
CompressionDictionary.Kind.valueOf(dataObject.kind);
+ CompressionDictionary.DictId dictId = new
CompressionDictionary.DictId(kind, dataObject.dictId);
+
+ LightweightCompressionDictionary latestCompressionDictionary =
SystemDistributedKeyspace.retrieveLightweightLatestCompressionDictionary(keyspaceName,
tableName);
Review Comment:
What we can do though is to check that _kind_ of the dictionary which is
meant to be imported matches the kind of the dictionary manager. It might
happen that we would try to import `Kind.MY_DICT_ALGORITHM` while manager would
be configured with `Kind.ZSTD` so it would not make any sense to import that.
I think you basically meant this, correct?
--
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]