Skip to content

Commit

Permalink
Replace deprecated compression options in cql
Browse files Browse the repository at this point in the history
Signed-off-by: toom <[email protected]>
  • Loading branch information
To-om authored and porunov committed Nov 4, 2024
1 parent c92b10e commit a49d8e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/configs/janusgraph-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ CQL storage backend options
| storage.cql.compaction-strategy-options | Compaction strategy options. This list is interpreted as a map. It must have an even number of elements in [key,val,key,val,...] form. | String[] | (no default value) | FIXED |
| storage.cql.compression | Whether the storage backend should use compression when storing the data | Boolean | true | FIXED |
| storage.cql.compression-block-size | The size of the compression blocks in kilobytes | Integer | 64 | FIXED |
| storage.cql.compression-type | The sstable_compression value JanusGraph uses when creating column families. This accepts any value allowed by Cassandra's sstable_compression option. Leave this unset to disable sstable_compression on JanusGraph-created CFs. | String | LZ4Compressor | MASKABLE |
| storage.cql.compression-type | The compression class value JanusGraph uses when creating column families. This accepts any value allowed by Cassandra's compression class option. Leave this unset to disable compression on JanusGraph-created CFs. | String | LZ4Compressor | MASKABLE |
| storage.cql.gc-grace-seconds | The number of seconds before tombstones (deletion markers) are eligible for garbage-collection. | Integer | (no default value) | FIXED |
| storage.cql.heartbeat-interval | The connection heartbeat interval in milliseconds. | Long | (no default value) | MASKABLE |
| storage.cql.heartbeat-timeout | How long the driver waits for the response (in milliseconds) to a heartbeat. | Long | (no default value) | MASKABLE |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ public interface CQLConfigOptions {
ConfigOption<String> CF_COMPRESSION_TYPE = new ConfigOption<>(
CQL_NS,
"compression-type",
"The sstable_compression value JanusGraph uses when creating column families. " +
"This accepts any value allowed by Cassandra's sstable_compression option. " +
"Leave this unset to disable sstable_compression on JanusGraph-created CFs.",
"The compression class value JanusGraph uses when creating column families. " +
"This accepts any value allowed by Cassandra's compression class option. " +
"Leave this unset to disable compression on JanusGraph-created CFs.",
ConfigOption.Type.MASKABLE,
"LZ4Compressor");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.BoundStatementBuilder;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import com.datastax.oss.driver.api.core.metadata.TokenMap;
import com.datastax.oss.driver.api.core.servererrors.QueryValidationException;
Expand Down Expand Up @@ -305,33 +306,51 @@ private boolean shouldInitializeTable() {
.orElse(true);
}

private static int getCassandraMajorVersion(final CqlSession session) {
try {
ResultSet rs = session.execute("SELECT release_version FROM system.local");
Row row = rs.one();
String version = row.getString("release_version");
return Integer.parseInt(version.split("\\.")[0]);
} catch (final Exception e) {
return 0;
}
}

private static void initializeTable(final CqlSession session, final String keyspaceName, final String tableName, final Configuration configuration) {
int cassandraMajorVersion = getCassandraMajorVersion(session);
CreateTableWithOptions createTable = createTable(keyspaceName, tableName)
.ifNotExists()
.withPartitionKey(KEY_COLUMN_NAME, DataTypes.BLOB)
.withClusteringColumn(COLUMN_COLUMN_NAME, DataTypes.BLOB)
.withColumn(VALUE_COLUMN_NAME, DataTypes.BLOB);

createTable = compactionOptions(createTable, configuration);
createTable = compressionOptions(createTable, configuration);
createTable = compressionOptions(createTable, configuration, cassandraMajorVersion);
createTable = gcGraceSeconds(createTable, configuration);
createTable = speculativeRetryOptions(createTable, configuration);

session.execute(createTable.build());
}

private static CreateTableWithOptions compressionOptions(final CreateTableWithOptions createTable,
final Configuration configuration) {
final Configuration configuration,
final int cassandraMajorVersion) {
if (!configuration.get(CF_COMPRESSION)) {
// No compression
return createTable.withNoCompression();
}

String compressionType = configuration.get(CF_COMPRESSION_TYPE);
int chunkLengthInKb = configuration.get(CF_COMPRESSION_BLOCK_SIZE);
Map<String, Object> options;

if (cassandraMajorVersion >= 5)
options = ImmutableMap.of("class", compressionType, "chunk_length_in_kb", chunkLengthInKb);
else
options = ImmutableMap.of("sstable_compression", compressionType, "chunk_length_kb", chunkLengthInKb);

return createTable.withOption("compression",
ImmutableMap.of("sstable_compression", compressionType, "chunk_length_kb", chunkLengthInKb));
return createTable.withOption("compression", options);
}

static CreateTableWithOptions compactionOptions(final CreateTableWithOptions createTable,
Expand Down

1 comment on commit a49d8e0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: a49d8e0 Previous: 213b754 Ratio
org.janusgraph.JanusGraphSpeedBenchmark.basicAddAndDelete 12945.731212782355 ms/op 12994.438964091325 ms/op 1.00
org.janusgraph.GraphCentricQueryBenchmark.getVertices 988.382211398165 ms/op 957.3251909284766 ms/op 1.03
org.janusgraph.MgmtOlapJobBenchmark.runClearIndex 216.72744182681163 ms/op 216.45303196086957 ms/op 1.00
org.janusgraph.MgmtOlapJobBenchmark.runReindex 344.03895541547615 ms/op 342.81005004892853 ms/op 1.00
org.janusgraph.JanusGraphSpeedBenchmark.basicCount 235.32848448841423 ms/op 207.33680618088454 ms/op 1.14
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesAllPropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection 4843.327733048825 ms/op 4953.295327365606 ms/op 0.98
org.janusgraph.CQLMultiQueryBenchmark.getElementsWithUsingEmitRepeatSteps 16938.66138854265 ms/op 16917.057558105356 ms/op 1.00
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithSmallBatch 20126.443474960608 ms/op 18983.13907385985 ms/op 1.06
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.vertexCentricPropertiesFetching 57185.91131443333 ms/op 56527.85002600001 ms/op 1.01
org.janusgraph.CQLMultiQueryDropBenchmark.dropVertices 1552.5429234477497 ms/op 1570.8428983417461 ms/op 0.99
org.janusgraph.CQLMultiQueryBenchmark.getAllElementsTraversedFromOuterVertex 8390.45049206063 ms/op 8433.13502817794 ms/op 0.99
org.janusgraph.CQLMultiQueryBenchmark.getVerticesWithDoubleUnion 366.68960390614257 ms/op 384.2152506805113 ms/op 0.95
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesAllPropertiesWithUnlimitedBatch 4204.197961795231 ms/op 4227.1771161974975 ms/op 0.99
org.janusgraph.CQLMultiQueryBenchmark.getNames 8462.969972231054 ms/op 8339.221853925019 ms/op 1.01
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesThreePropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection 5974.230316933905 ms/op 5604.356576582386 ms/op 1.07
org.janusgraph.CQLMultiQueryBenchmark.getLabels 7075.015628779049 ms/op 7082.884761983721 ms/op 1.00
org.janusgraph.CQLMultiQueryBenchmark.getVerticesFilteredByAndStep 425.3525897743987 ms/op 430.31039337061094 ms/op 0.99
org.janusgraph.CQLMultiQueryBenchmark.getVerticesFromMultiNestedRepeatStepStartingFromSingleVertex 13092.546227868055 ms/op 12459.636105572155 ms/op 1.05
org.janusgraph.CQLMultiQueryBenchmark.getVerticesWithCoalesceUsage 354.83791170606935 ms/op 357.5981502840734 ms/op 0.99
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithAllMultiQuerySlicesUnderMaxRequestsPerConnection 14555.775137459957 ms/op 14793.559446997619 ms/op 0.98
org.janusgraph.CQLMultiQueryBenchmark.getIdToOutVerticesProjection 244.94999881319816 ms/op 245.84974412075837 ms/op 1.00
org.janusgraph.CQLMultiQueryMultiSlicesBenchmark.getValuesMultiplePropertiesWithUnlimitedBatch 15378.848385522451 ms/op 13806.414282860256 ms/op 1.11
org.janusgraph.CQLCompositeIndexInlinePropBenchmark.searchVertices 1541.9238773113736 ms/op 1511.142514571489 ms/op 1.02
org.janusgraph.CQLMultiQueryDropBenchmark.dropVerticesGremlinQuery 1591.2028754896394 ms/op
org.janusgraph.CQLMultiQueryBenchmark.getNeighborNames 8011.044946224037 ms/op 8411.967305495045 ms/op 0.95
org.janusgraph.CQLMultiQueryBenchmark.getElementsWithUsingRepeatUntilSteps 8876.74788022267 ms/op 9104.974810254043 ms/op 0.97
org.janusgraph.CQLMultiQueryBenchmark.getAdjacentVerticesLocalCounts 8345.734081550268 ms/op 8793.398072298722 ms/op 0.95

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.