23
23
#include " rocksdb/env.h"
24
24
#include " rocksdb/table.h"
25
25
#include " rocksdb/perf_context.h"
26
+ #include " rocksdb/plain_table_factory.h"
26
27
#include " util/hash.h"
27
28
#include " util/logging.h"
28
29
#include " util/mutexlock.h"
@@ -244,6 +245,8 @@ class DBTest {
244
245
// Sequence of option configurations to try
245
246
enum OptionConfig {
246
247
kDefault ,
248
+ kPlainTableFirstBytePrefix ,
249
+ kPlainTableAllBytesPrefix ,
247
250
kVectorRep ,
248
251
kMergePut ,
249
252
kFilter ,
@@ -275,7 +278,8 @@ class DBTest {
275
278
kNoSkip = 0 ,
276
279
kSkipDeletesFilterFirst = 1 ,
277
280
kSkipUniversalCompaction = 2 ,
278
- kSkipMergePut = 4
281
+ kSkipMergePut = 4 ,
282
+ kSkipPlainTable = 8
279
283
};
280
284
281
285
DBTest () : option_config_(kDefault ),
@@ -297,20 +301,27 @@ class DBTest {
297
301
// Switch to a fresh database with the next option configuration to
298
302
// test. Return false if there are no more configurations to test.
299
303
bool ChangeOptions (int skip_mask = kNoSkip ) {
300
- option_config_++;
301
-
302
304
// skip some options
303
- if (skip_mask & kSkipDeletesFilterFirst &&
304
- option_config_ == kDeletesFilterFirst ) {
305
- option_config_++;
306
- }
307
- if (skip_mask & kSkipUniversalCompaction &&
308
- option_config_ == kUniversalCompaction ) {
309
- option_config_++;
310
- }
311
- if (skip_mask & kSkipMergePut && option_config_ == kMergePut ) {
312
- option_config_++;
305
+ for (option_config_++; option_config_ < kEnd ; option_config_++) {
306
+ if ((skip_mask & kSkipDeletesFilterFirst ) &&
307
+ option_config_ == kDeletesFilterFirst ) {
308
+ continue ;
309
+ }
310
+ if ((skip_mask & kSkipUniversalCompaction ) &&
311
+ option_config_ == kUniversalCompaction ) {
312
+ continue ;
313
+ }
314
+ if ((skip_mask & kSkipMergePut ) && option_config_ == kMergePut ) {
315
+ continue ;
316
+ }
317
+ if ((skip_mask & kSkipPlainTable )
318
+ && (option_config_ == kPlainTableAllBytesPrefix
319
+ || option_config_ == kPlainTableFirstBytePrefix )) {
320
+ continue ;
321
+ }
322
+ break ;
313
323
}
324
+
314
325
if (option_config_ >= kEnd ) {
315
326
Destroy (&last_options_);
316
327
return false ;
@@ -343,6 +354,18 @@ class DBTest {
343
354
options.memtable_factory .reset (
344
355
NewHashSkipListRepFactory (NewFixedPrefixTransform (1 )));
345
356
break ;
357
+ case kPlainTableFirstBytePrefix :
358
+ options.table_factory .reset (new PlainTableFactory ());
359
+ options.prefix_extractor = NewFixedPrefixTransform (1 );
360
+ options.allow_mmap_reads = true ;
361
+ options.max_sequential_skip_in_iterations = 999999 ;
362
+ break ;
363
+ case kPlainTableAllBytesPrefix :
364
+ options.table_factory .reset (new PlainTableFactory ());
365
+ options.prefix_extractor = NewNoopTransform ();
366
+ options.allow_mmap_reads = true ;
367
+ options.max_sequential_skip_in_iterations = 999999 ;
368
+ break ;
346
369
case kMergePut :
347
370
options.merge_operator = MergeOperators::CreatePutOperator ();
348
371
break ;
@@ -1009,7 +1032,10 @@ TEST(DBTest, KeyMayExist) {
1009
1032
options.statistics .get ()->getTickerCount (BLOCK_CACHE_ADD));
1010
1033
1011
1034
delete options.filter_policy ;
1012
- } while (ChangeOptions ());
1035
+
1036
+ // KeyMayExist function only checks data in block caches, which is not used
1037
+ // by plain table format.
1038
+ } while (ChangeOptions (kSkipPlainTable ));
1013
1039
}
1014
1040
1015
1041
TEST (DBTest, NonBlockingIteration) {
@@ -1073,7 +1099,9 @@ TEST(DBTest, NonBlockingIteration) {
1073
1099
options.statistics .get ()->getTickerCount (BLOCK_CACHE_ADD));
1074
1100
delete iter;
1075
1101
1076
- } while (ChangeOptions ());
1102
+ // This test verifies block cache behaviors, which is not used by plain
1103
+ // table format.
1104
+ } while (ChangeOptions (kSkipPlainTable ));
1077
1105
}
1078
1106
1079
1107
// A delete is skipped for key if KeyMayExist(key) returns False
@@ -2932,7 +2960,8 @@ TEST(DBTest, ApproximateSizes) {
2932
2960
ASSERT_EQ (NumTableFilesAtLevel (0 ), 0 );
2933
2961
ASSERT_GT (NumTableFilesAtLevel (1 ), 0 );
2934
2962
}
2935
- } while (ChangeOptions (kSkipUniversalCompaction ));
2963
+ // ApproximateOffsetOf() is not yet implemented in plain table format.
2964
+ } while (ChangeOptions (kSkipUniversalCompaction | kSkipPlainTable ));
2936
2965
}
2937
2966
2938
2967
TEST (DBTest, ApproximateSizes_MixOfSmallAndLarge) {
@@ -2970,7 +2999,8 @@ TEST(DBTest, ApproximateSizes_MixOfSmallAndLarge) {
2970
2999
2971
3000
dbfull ()->TEST_CompactRange (0 , nullptr , nullptr );
2972
3001
}
2973
- } while (ChangeOptions ());
3002
+ // ApproximateOffsetOf() is not yet implemented in plain table format.
3003
+ } while (ChangeOptions (kSkipPlainTable ));
2974
3004
}
2975
3005
2976
3006
TEST (DBTest, IteratorPinsRef) {
@@ -3054,7 +3084,9 @@ TEST(DBTest, HiddenValuesAreRemoved) {
3054
3084
ASSERT_EQ (AllEntriesFor (" foo" ), " [ tiny ]" );
3055
3085
3056
3086
ASSERT_TRUE (Between (Size (" " , " pastfoo" ), 0 , 1000 ));
3057
- } while (ChangeOptions (kSkipUniversalCompaction ));
3087
+ // ApproximateOffsetOf() is not yet implemented in plain table format,
3088
+ // which is used by Size().
3089
+ } while (ChangeOptions (kSkipUniversalCompaction | kSkipPlainTable ));
3058
3090
}
3059
3091
3060
3092
TEST (DBTest, CompactBetweenSnapshots) {
@@ -4626,7 +4658,8 @@ TEST(DBTest, Randomized) {
4626
4658
// TODO(sanjay): Test Get() works
4627
4659
int p = rnd.Uniform (100 );
4628
4660
int minimum = 0 ;
4629
- if (option_config_ == kHashSkipList ) {
4661
+ if (option_config_ == kHashSkipList ||
4662
+ option_config_ == kPlainTableFirstBytePrefix ) {
4630
4663
minimum = 1 ;
4631
4664
}
4632
4665
if (p < 45 ) { // Put
0 commit comments