@@ -14,11 +14,14 @@ public class BlockBasedTableConfig extends TableFormatConfig {
14
14
public BlockBasedTableConfig () {
15
15
noBlockCache_ = false ;
16
16
blockCacheSize_ = 8 * 1024 * 1024 ;
17
- blockSize_ = 4 * 1024 ;
18
- blockSizeDeviation_ =10 ;
19
- blockRestartInterval_ =16 ;
17
+ blockSize_ = 4 * 1024 ;
18
+ blockSizeDeviation_ = 10 ;
19
+ blockRestartInterval_ = 16 ;
20
20
wholeKeyFiltering_ = true ;
21
- bitsPerKey_ = 0 ;
21
+ bitsPerKey_ = 10 ;
22
+ cacheIndexAndFilterBlocks_ = false ;
23
+ hashIndexAllowCollision_ = true ;
24
+ blockCacheCompressedSize_ = 0 ;
22
25
}
23
26
24
27
/**
@@ -71,8 +74,8 @@ public long blockCacheSize() {
71
74
* number means use default settings."
72
75
* @return the reference to the current option.
73
76
*/
74
- public BlockBasedTableConfig setCacheNumShardBits (int numShardBits ) {
75
- numShardBits_ = numShardBits ;
77
+ public BlockBasedTableConfig setCacheNumShardBits (int blockCacheNumShardBits ) {
78
+ blockCacheNumShardBits_ = blockCacheNumShardBits ;
76
79
return this ;
77
80
}
78
81
@@ -84,7 +87,7 @@ public BlockBasedTableConfig setCacheNumShardBits(int numShardBits) {
84
87
* @return the number of shard bits used in the block cache.
85
88
*/
86
89
public int cacheNumShardBits () {
87
- return numShardBits_ ;
90
+ return blockCacheNumShardBits_ ;
88
91
}
89
92
90
93
/**
@@ -186,25 +189,135 @@ public BlockBasedTableConfig setFilterBitsPerKey(int bitsPerKey) {
186
189
bitsPerKey_ = bitsPerKey ;
187
190
return this ;
188
191
}
192
+
193
+ /**
194
+ * Indicating if we'd put index/filter blocks to the block cache.
195
+ If not specified, each "table reader" object will pre-load index/filter
196
+ block during table initialization.
197
+ *
198
+ * @return if index and filter blocks should be put in block cache.
199
+ */
200
+ public boolean cacheIndexAndFilterBlocks () {
201
+ return cacheIndexAndFilterBlocks_ ;
202
+ }
203
+
204
+ /**
205
+ * Indicating if we'd put index/filter blocks to the block cache.
206
+ If not specified, each "table reader" object will pre-load index/filter
207
+ block during table initialization.
208
+ *
209
+ * @param index and filter blocks should be put in block cache.
210
+ * @return the reference to the current config.
211
+ */
212
+ public BlockBasedTableConfig setCacheIndexAndFilterBlocks (
213
+ boolean cacheIndexAndFilterBlocks ) {
214
+ cacheIndexAndFilterBlocks_ = cacheIndexAndFilterBlocks ;
215
+ return this ;
216
+ }
217
+
218
+ /**
219
+ * Influence the behavior when kHashSearch is used.
220
+ if false, stores a precise prefix to block range mapping
221
+ if true, does not store prefix and allows prefix hash collision
222
+ (less memory consumption)
223
+ *
224
+ * @return if hash collisions should be allowed.
225
+ */
226
+ public boolean hashIndexAllowCollision () {
227
+ return hashIndexAllowCollision_ ;
228
+ }
229
+
230
+ /**
231
+ * Influence the behavior when kHashSearch is used.
232
+ if false, stores a precise prefix to block range mapping
233
+ if true, does not store prefix and allows prefix hash collision
234
+ (less memory consumption)
235
+ *
236
+ * @param if hash collisions should be allowed.
237
+ * @return the reference to the current config.
238
+ */
239
+ public BlockBasedTableConfig setHashIndexAllowCollision (
240
+ boolean hashIndexAllowCollision ) {
241
+ hashIndexAllowCollision_ = hashIndexAllowCollision ;
242
+ return this ;
243
+ }
244
+
245
+ /**
246
+ * Size of compressed block cache. If 0, then block_cache_compressed is set
247
+ * to null.
248
+ *
249
+ * @return size of compressed block cache.
250
+ */
251
+ public long blockCacheCompressedSize () {
252
+ return blockCacheCompressedSize_ ;
253
+ }
254
+
255
+ /**
256
+ * Size of compressed block cache. If 0, then block_cache_compressed is set
257
+ * to null.
258
+ *
259
+ * @param size of compressed block cache.
260
+ * @return the reference to the current config.
261
+ */
262
+ public BlockBasedTableConfig setBlockCacheCompressedSize (
263
+ long blockCacheCompressedSize ) {
264
+ blockCacheCompressedSize_ = blockCacheCompressedSize ;
265
+ return this ;
266
+ }
267
+
268
+ /**
269
+ * Controls the number of shards for the block compressed cache.
270
+ * This is applied only if blockCompressedCacheSize is set to non-negative.
271
+ *
272
+ * @return numShardBits the number of shard bits. The resulting
273
+ * number of shards would be 2 ^ numShardBits. Any negative
274
+ * number means use default settings.
275
+ */
276
+ public int blockCacheCompressedNumShardBits () {
277
+ return blockCacheCompressedNumShardBits_ ;
278
+ }
279
+
280
+ /**
281
+ * Controls the number of shards for the block compressed cache.
282
+ * This is applied only if blockCompressedCacheSize is set to non-negative.
283
+ *
284
+ * @param numShardBits the number of shard bits. The resulting
285
+ * number of shards would be 2 ^ numShardBits. Any negative
286
+ * number means use default settings."
287
+ * @return the reference to the current option.
288
+ */
289
+ public BlockBasedTableConfig setBlockCacheCompressedNumShardBits (
290
+ int blockCacheCompressedNumShardBits ) {
291
+ blockCacheCompressedNumShardBits_ = blockCacheCompressedNumShardBits ;
292
+ return this ;
293
+ }
189
294
190
295
@ Override protected long newTableFactoryHandle () {
191
- return newTableFactoryHandle (noBlockCache_ , blockCacheSize_ , numShardBits_ ,
192
- blockSize_ , blockSizeDeviation_ , blockRestartInterval_ ,
193
- wholeKeyFiltering_ , bitsPerKey_ );
296
+ return newTableFactoryHandle (noBlockCache_ , blockCacheSize_ ,
297
+ blockCacheNumShardBits_ , blockSize_ , blockSizeDeviation_ ,
298
+ blockRestartInterval_ , wholeKeyFiltering_ , bitsPerKey_ ,
299
+ cacheIndexAndFilterBlocks_ , hashIndexAllowCollision_ ,
300
+ blockCacheCompressedSize_ , blockCacheCompressedNumShardBits_ );
194
301
}
195
302
196
303
private native long newTableFactoryHandle (
197
- boolean noBlockCache , long blockCacheSize , int numShardbits ,
304
+ boolean noBlockCache , long blockCacheSize , int blockCacheNumShardBits ,
198
305
long blockSize , int blockSizeDeviation , int blockRestartInterval ,
199
- boolean wholeKeyFiltering , int bitsPerKey );
306
+ boolean wholeKeyFiltering , int bitsPerKey ,
307
+ boolean cacheIndexAndFilterBlocks , boolean hashIndexAllowCollision ,
308
+ long blockCacheCompressedSize , int blockCacheCompressedNumShardBits );
200
309
201
310
private boolean noBlockCache_ ;
202
311
private long blockCacheSize_ ;
203
- private int numShardBits_ ;
312
+ private int blockCacheNumShardBits_ ;
204
313
private long shard ;
205
314
private long blockSize_ ;
206
315
private int blockSizeDeviation_ ;
207
316
private int blockRestartInterval_ ;
208
317
private boolean wholeKeyFiltering_ ;
209
318
private int bitsPerKey_ ;
319
+ private boolean cacheIndexAndFilterBlocks_ ;
320
+ private boolean hashIndexAllowCollision_ ;
321
+ private long blockCacheCompressedSize_ ;
322
+ private int blockCacheCompressedNumShardBits_ ;
210
323
}
0 commit comments