Fix compression options

This commit is contained in:
Andrea Cavalli 2024-09-26 18:29:21 +02:00
parent 215ba242fd
commit b8b4b3c320
2 changed files with 17 additions and 13 deletions

View File

@ -150,6 +150,17 @@ public class RocksDBLoader {
if (columnOptions.levels().length > 0) { if (columnOptions.levels().length > 0) {
columnFamilyOptions.setNumLevels(columnOptions.levels().length); columnFamilyOptions.setNumLevels(columnOptions.levels().length);
List<CompressionType> compressionPerLevel = new ArrayList<>();
for (ColumnLevelConfig columnLevelConfig : columnOptions.levels()) {
CompressionType compression = columnLevelConfig.compression();
compressionPerLevel.add(compression);
}
if (compressionPerLevel.size() != columnOptions.levels().length) {
throw it.cavallium.rockserver.core.common.RocksDBException.of(RocksDBErrorType.CONFIG_ERROR, "Database column levels and compression per level count is different! %s != %s".formatted(compressionPerLevel.size(), columnOptions.levels().length));
}
columnFamilyOptions.setCompressionPerLevel(compressionPerLevel);
var firstLevelOptions = getRocksLevelOptions(columnOptions.levels()[0], refs); var firstLevelOptions = getRocksLevelOptions(columnOptions.levels()[0], refs);
columnFamilyOptions.setCompressionType(firstLevelOptions.compressionType); columnFamilyOptions.setCompressionType(firstLevelOptions.compressionType);
columnFamilyOptions.setCompressionOptions(firstLevelOptions.compressionOptions); columnFamilyOptions.setCompressionOptions(firstLevelOptions.compressionOptions);
@ -158,13 +169,6 @@ public class RocksDBLoader {
.levels()[columnOptions.levels().length - 1], refs); .levels()[columnOptions.levels().length - 1], refs);
columnFamilyOptions.setBottommostCompressionType(lastLevelOptions.compressionType); columnFamilyOptions.setBottommostCompressionType(lastLevelOptions.compressionType);
columnFamilyOptions.setBottommostCompressionOptions(lastLevelOptions.compressionOptions); columnFamilyOptions.setBottommostCompressionOptions(lastLevelOptions.compressionOptions);
List<CompressionType> compressionPerLevel = new ArrayList<>();
for (ColumnLevelConfig columnLevelConfig : columnOptions.levels()) {
CompressionType compression = columnLevelConfig.compression();
compressionPerLevel.add(compression);
}
columnFamilyOptions.setCompressionPerLevel(compressionPerLevel);
} else { } else {
columnFamilyOptions.setNumLevels(7); columnFamilyOptions.setNumLevels(7);
List<CompressionType> compressionTypes = new ArrayList<>(7); List<CompressionType> compressionTypes = new ArrayList<>(7);

View File

@ -49,16 +49,16 @@ public record SSTWriter(RocksDB db, it.cavallium.rockserver.core.impl.ColumnInst
.setParanoidFileChecks(false); .setParanoidFileChecks(false);
if (columnConifg != null) { if (columnConifg != null) {
options options
.setCompressionType(columnConifg.compressionType())
.setCompressionOptions(columnConifg.compressionOptions())
.setBottommostCompressionType(columnConifg.bottommostCompressionType())
.setBottommostCompressionOptions(columnConifg.bottommostCompressionOptions())
.setCompressionPerLevel(columnConifg.compressionPerLevel())
.setNumLevels(columnConifg.numLevels()) .setNumLevels(columnConifg.numLevels())
.setTableFormatConfig(columnConifg.tableFormatConfig()) .setTableFormatConfig(columnConifg.tableFormatConfig())
.setTargetFileSizeBase(columnConifg.targetFileSizeBase()) .setTargetFileSizeBase(columnConifg.targetFileSizeBase())
.setTargetFileSizeMultiplier(columnConifg.targetFileSizeMultiplier()) .setTargetFileSizeMultiplier(columnConifg.targetFileSizeMultiplier())
.setMaxOpenFiles(-1); .setMaxOpenFiles(-1)
.setCompressionPerLevel(columnConifg.compressionPerLevel())
.setCompressionType(columnConifg.compressionType())
.setCompressionOptions(columnConifg.compressionOptions())
.setBottommostCompressionType(columnConifg.bottommostCompressionType())
.setBottommostCompressionOptions(columnConifg.bottommostCompressionOptions());
if (columnConifg.memTableConfig() != null) { if (columnConifg.memTableConfig() != null) {
options.setMemTableConfig(columnConifg.memTableConfig()); options.setMemTableConfig(columnConifg.memTableConfig());
} else { } else {