19
19
20
20
import static com .datastax .oss .driver .api .querybuilder .SchemaBuilder .RowsPerPartition ;
21
21
22
+ import com .datastax .oss .driver .api .core .config .DriverConfigLoader ;
22
23
import com .datastax .oss .driver .api .querybuilder .SchemaBuilder ;
23
24
import com .datastax .oss .driver .api .querybuilder .schema .compaction .CompactionStrategy ;
24
25
import com .datastax .oss .driver .shaded .guava .common .collect .ImmutableMap ;
@@ -97,22 +98,32 @@ default SelfT withCompaction(@NonNull CompactionStrategy<?> compactionStrategy)
97
98
}
98
99
99
100
/**
100
- * Configures compression using the LZ4 algorithm with the given chunk length and crc check
101
- * chance.
102
- *
103
- * @see #withCompression(String, int, double)
101
+ * @deprecated This method only exists for backward compatibility. Use {@link
102
+ * RelationOptions#withLZ4Compression(chunkLengthKB)} instead.
104
103
*/
104
+ @ Deprecated
105
105
@ NonNull
106
106
@ CheckReturnValue
107
107
default SelfT withLZ4Compression (int chunkLengthKB , double crcCheckChance ) {
108
108
return withCompression ("LZ4Compressor" , chunkLengthKB , crcCheckChance );
109
109
}
110
110
111
+ /**
112
+ * Configures compression using the LZ4 algorithm with the given chunk length.
113
+ *
114
+ * @see #withCompression(String, int)
115
+ */
116
+ @ NonNull
117
+ @ CheckReturnValue
118
+ default SelfT withLZ4Compression (int chunkLengthKB ) {
119
+ return withCompression ("LZ4Compressor" , chunkLengthKB );
120
+ }
121
+
111
122
/**
112
123
* Configures compression using the LZ4 algorithm using the default configuration (64kb
113
- * chunk_length, and 1.0 crc_check_chance ).
124
+ * chunk_length).
114
125
*
115
- * @see #withCompression(String, int, double )
126
+ * @see #withCompression(String, int)
116
127
*/
117
128
@ NonNull
118
129
@ CheckReturnValue
@@ -121,22 +132,55 @@ default SelfT withLZ4Compression() {
121
132
}
122
133
123
134
/**
124
- * Configures compression using the Snappy algorithm with the given chunk length and crc check
125
- * chance.
135
+ * Configures compression using the Zstd algorithm with the given chunk length.
136
+ *
137
+ * @see #withCompression(String, int)
138
+ */
139
+ @ NonNull
140
+ @ CheckReturnValue
141
+ default SelfT withZstdCompression (int chunkLengthKB ) {
142
+ return withCompression ("org.apache.cassandra.io.compress.ZstdCompressor" , chunkLengthKB );
143
+ }
144
+
145
+ /**
146
+ * Configures compression using the Zstd algorithm using the default configuration (64kb
147
+ * chunk_length).
126
148
*
127
- * @see #withCompression(String, int, double)
149
+ * @see #withCompression(String, int)
150
+ */
151
+ @ NonNull
152
+ @ CheckReturnValue
153
+ default SelfT withZstdCompression () {
154
+ return withCompression ("org.apache.cassandra.io.compress.ZstdCompressor" );
155
+ }
156
+
157
+ /**
158
+ * @deprecated This method only exists for backward compatibility. Use {@link
159
+ * RelationOptions#withSnappyCompression(chunkLengthKB)} instead.
128
160
*/
161
+ @ Deprecated
129
162
@ NonNull
130
163
@ CheckReturnValue
131
164
default SelfT withSnappyCompression (int chunkLengthKB , double crcCheckChance ) {
132
165
return withCompression ("SnappyCompressor" , chunkLengthKB , crcCheckChance );
133
166
}
134
167
168
+ /**
169
+ * Configures compression using the Snappy algorithm with the given chunk length.
170
+ *
171
+ * @see #withCompression(String, int)
172
+ */
173
+ @ NonNull
174
+ @ CheckReturnValue
175
+ default SelfT withSnappyCompression (int chunkLengthKB ) {
176
+ return withCompression ("SnappyCompressor" , chunkLengthKB );
177
+ }
178
+
135
179
/**
136
180
* Configures compression using the Snappy algorithm using the default configuration (64kb
137
- * chunk_length, and 1.0 crc_check_chance ).
181
+ * chunk_length).
138
182
*
139
- * @see #withCompression(String, int, double )
183
+ * @see #withCompression(String, int)
140
184
*/
141
185
@ NonNull
142
186
@ CheckReturnValue
@@ -145,22 +189,32 @@ default SelfT withSnappyCompression() {
145
189
}
146
190
147
191
/**
148
- * Configures compression using the Deflate algorithm with the given chunk length and crc check
149
- * chance.
150
- *
151
- * @see #withCompression(String, int, double)
192
+ * @deprecated This method only exists for backward compatibility. Use {@link
193
+ * RelationOptions#withDeflateCompression(chunkLengthKB)} instead.
152
194
*/
195
+ @ Deprecated
153
196
@ NonNull
154
197
@ CheckReturnValue
155
198
default SelfT withDeflateCompression (int chunkLengthKB , double crcCheckChance ) {
156
199
return withCompression ("DeflateCompressor" , chunkLengthKB , crcCheckChance );
157
200
}
158
201
202
+ /**
203
+ * Configures compression using the Deflate algorithm with the given chunk length.
204
+ *
205
+ * @see #withCompression(String, int)
206
+ */
207
+ @ NonNull
208
+ @ CheckReturnValue
209
+ default SelfT withDeflateCompression (int chunkLengthKB ) {
210
+ return withCompression ("DeflateCompressor" , chunkLengthKB );
211
+ }
212
+
159
213
/**
160
214
* Configures compression using the Deflate algorithm using the default configuration (64kb
161
215
* chunk_length, and 1.0 crc_check_chance).
162
216
*
163
- * @see #withCompression(String, int, double )
217
+ * @see #withCompression(String, int)
164
218
*/
165
219
@ NonNull
166
220
@ CheckReturnValue
@@ -170,13 +224,13 @@ default SelfT withDeflateCompression() {
170
224
171
225
/**
172
226
* Configures compression using the given algorithm using the default configuration (64kb
173
- * chunk_length, and 1.0 crc_check_chance ).
227
+ * chunk_length).
174
228
*
175
229
* <p>Unless specifying a custom compression algorithm implementation, it is recommended to use
176
230
* {@link #withLZ4Compression()}, {@link #withSnappyCompression()}, or {@link
177
231
* #withDeflateCompression()}.
178
232
*
179
- * @see #withCompression(String, int, double )
233
+ * @see #withCompression(String, int)
180
234
*/
181
235
@ NonNull
182
236
@ CheckReturnValue
@@ -185,27 +239,43 @@ default SelfT withCompression(@NonNull String compressionAlgorithmName) {
185
239
}
186
240
187
241
/**
188
- * Configures compression using the given algorithm, chunk length and crc check chance .
242
+ * Configures compression using the given algorithm, chunk length.
189
243
*
190
244
* <p>Unless specifying a custom compression algorithm implementation, it is recommended to use
191
245
* {@link #withLZ4Compression()}, {@link #withSnappyCompression()}, or {@link
192
246
* #withDeflateCompression()}.
193
247
*
194
248
* @param compressionAlgorithmName The class name of the compression algorithm.
195
249
* @param chunkLengthKB The chunk length in KB of compression blocks. Defaults to 64.
196
- * @param crcCheckChance The probability (0.0 to 1.0) that checksum will be checked on each read.
197
- * Defaults to 1.0.
198
250
*/
199
251
@ NonNull
200
252
@ CheckReturnValue
253
+ default SelfT withCompression (
254
+ @ NonNull String compressionAlgorithmName , int chunkLengthKB ) {
255
+ return withOption (
256
+ "compression" ,
257
+ ImmutableMap .of (
258
+ "class" ,
259
+ compressionAlgorithmName ,
260
+ "chunk_length_in_kb" ,
261
+ chunkLengthKB ));
262
+ }
263
+
264
+ /**
265
+ * @deprecated This method only exists for backward compatibility. Use {@link
266
+ * RelationOptions#withCompression(compressionAlgorithmName, chunkLengthKB)} instead.
267
+ */
268
+ @ NonNull
269
+ @ CheckReturnValue
270
+ @ Deprecated
201
271
default SelfT withCompression (
202
272
@ NonNull String compressionAlgorithmName , int chunkLengthKB , double crcCheckChance ) {
203
273
return withOption (
204
274
"compression" ,
205
275
ImmutableMap .of (
206
276
"class" ,
207
277
compressionAlgorithmName ,
208
- "chunk_length_in_kb " ,
278
+ "chunk_length_kb " ,
209
279
chunkLengthKB ,
210
280
"crc_check_chance" ,
211
281
crcCheckChance ));
0 commit comments