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