|
|
|
@ -185,7 +185,7 @@ class TestPlainTableReader : public PlainTableReader { |
|
|
|
|
const Options& options, bool* expect_bloom_not_match) |
|
|
|
|
: PlainTableReader(options, std::move(file), storage_options, icomparator, |
|
|
|
|
file_size, bloom_bits_per_key, hash_table_ratio, |
|
|
|
|
index_sparseness, table_properties), |
|
|
|
|
index_sparseness, table_properties, 2 * 1024 * 1024), |
|
|
|
|
expect_bloom_not_match_(expect_bloom_not_match) { |
|
|
|
|
Status s = PopulateIndex(const_cast<TableProperties*>(table_properties)); |
|
|
|
|
ASSERT_TRUE(s.ok()); |
|
|
|
@ -206,13 +206,12 @@ extern const uint64_t kPlainTableMagicNumber; |
|
|
|
|
class TestPlainTableFactory : public PlainTableFactory { |
|
|
|
|
public: |
|
|
|
|
explicit TestPlainTableFactory(bool* expect_bloom_not_match, |
|
|
|
|
uint32_t user_key_len = |
|
|
|
|
kPlainTableVariableLength, |
|
|
|
|
int bloom_bits_per_key = 0, |
|
|
|
|
double hash_table_ratio = 0.75, |
|
|
|
|
size_t index_sparseness = 16) |
|
|
|
|
uint32_t user_key_len, int bloom_bits_per_key, |
|
|
|
|
double hash_table_ratio, |
|
|
|
|
size_t index_sparseness, |
|
|
|
|
size_t huge_page_tlb_size) |
|
|
|
|
: PlainTableFactory(user_key_len, user_key_len, hash_table_ratio, |
|
|
|
|
hash_table_ratio), |
|
|
|
|
index_sparseness, huge_page_tlb_size), |
|
|
|
|
bloom_bits_per_key_(bloom_bits_per_key), |
|
|
|
|
hash_table_ratio_(hash_table_ratio), |
|
|
|
|
index_sparseness_(index_sparseness), |
|
|
|
@ -244,6 +243,8 @@ class TestPlainTableFactory : public PlainTableFactory { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, Flush) { |
|
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024; |
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) { |
|
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) { |
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) { |
|
|
|
|
Options options = CurrentOptions(); |
|
|
|
@ -251,10 +252,11 @@ TEST(PlainTableDBTest, Flush) { |
|
|
|
|
// Set only one bucket to force bucket conflict.
|
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
|
|
|
|
if (total_order) { |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
NewTotalOrderPlainTableFactory(16, bloom_bits, 2)); |
|
|
|
|
options.table_factory.reset(NewTotalOrderPlainTableFactory( |
|
|
|
|
16, bloom_bits, 2, huge_page_tlb_size)); |
|
|
|
|
} else { |
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(16, bloom_bits)); |
|
|
|
|
options.table_factory.reset(NewPlainTableFactory( |
|
|
|
|
16, bloom_bits, 0.75, 16, huge_page_tlb_size)); |
|
|
|
|
} |
|
|
|
|
DestroyAndReopen(&options); |
|
|
|
|
|
|
|
|
@ -268,20 +270,21 @@ TEST(PlainTableDBTest, Flush) { |
|
|
|
|
ASSERT_EQ(1U, ptc.size()); |
|
|
|
|
auto row = ptc.begin(); |
|
|
|
|
auto tp = row->second; |
|
|
|
|
ASSERT_EQ( |
|
|
|
|
total_order ? "4" : "12", |
|
|
|
|
(tp->user_collected_properties).at("plain_table_hash_table_size")); |
|
|
|
|
ASSERT_EQ( |
|
|
|
|
total_order ? "9" : "0", |
|
|
|
|
(tp->user_collected_properties).at("plain_table_sub_index_size")); |
|
|
|
|
ASSERT_EQ(total_order ? "4" : "12", (tp->user_collected_properties).at( |
|
|
|
|
"plain_table_hash_table_size")); |
|
|
|
|
ASSERT_EQ(total_order ? "9" : "0", (tp->user_collected_properties).at( |
|
|
|
|
"plain_table_sub_index_size")); |
|
|
|
|
|
|
|
|
|
ASSERT_EQ("v3", Get("1000000000000foo")); |
|
|
|
|
ASSERT_EQ("v2", Get("0000000000000bar")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, Flush2) { |
|
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024; |
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) { |
|
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) { |
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) { |
|
|
|
|
bool expect_bloom_not_match = false; |
|
|
|
@ -291,11 +294,13 @@ TEST(PlainTableDBTest, Flush2) { |
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
|
|
|
|
if (total_order) { |
|
|
|
|
options.prefix_extractor = nullptr; |
|
|
|
|
options.table_factory.reset(new TestPlainTableFactory( |
|
|
|
|
&expect_bloom_not_match, 16, bloom_bits, 0, 2)); |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits, |
|
|
|
|
0, 2, huge_page_tlb_size)); |
|
|
|
|
} else { |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits)); |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits, |
|
|
|
|
0.75, 16, huge_page_tlb_size)); |
|
|
|
|
} |
|
|
|
|
DestroyAndReopen(&options); |
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "b")); |
|
|
|
@ -334,9 +339,12 @@ TEST(PlainTableDBTest, Flush2) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, Iterator) { |
|
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024; |
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) { |
|
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) { |
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) { |
|
|
|
|
bool expect_bloom_not_match = false; |
|
|
|
@ -346,11 +354,13 @@ TEST(PlainTableDBTest, Iterator) { |
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
|
|
|
|
if (total_order) { |
|
|
|
|
options.prefix_extractor = nullptr; |
|
|
|
|
options.table_factory.reset(new TestPlainTableFactory( |
|
|
|
|
&expect_bloom_not_match, 16, bloom_bits, 0, 2)); |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits, |
|
|
|
|
0, 2, huge_page_tlb_size)); |
|
|
|
|
} else { |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits)); |
|
|
|
|
new TestPlainTableFactory(&expect_bloom_not_match, 16, bloom_bits, |
|
|
|
|
0.75, 16, huge_page_tlb_size)); |
|
|
|
|
} |
|
|
|
|
DestroyAndReopen(&options); |
|
|
|
|
|
|
|
|
@ -437,6 +447,7 @@ TEST(PlainTableDBTest, Iterator) { |
|
|
|
|
delete iter; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
@ -581,12 +592,15 @@ TEST(PlainTableDBTest, IteratorReverseSuffixComparator) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, HashBucketConflict) { |
|
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024; |
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) { |
|
|
|
|
for (unsigned char i = 1; i <= 3; i++) { |
|
|
|
|
Options options = CurrentOptions(); |
|
|
|
|
options.create_if_missing = true; |
|
|
|
|
// Set only one bucket to force bucket conflict.
|
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
|
|
|
|
options.table_factory.reset(NewTotalOrderPlainTableFactory(16, 0, 2 ^ i)); |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
NewTotalOrderPlainTableFactory(16, 0, 2 ^ i, huge_page_tlb_size)); |
|
|
|
|
DestroyAndReopen(&options); |
|
|
|
|
ASSERT_OK(Put("5000000000000fo0", "v1")); |
|
|
|
|
ASSERT_OK(Put("5000000000000fo1", "v2")); |
|
|
|
@ -659,9 +673,12 @@ TEST(PlainTableDBTest, HashBucketConflict) { |
|
|
|
|
|
|
|
|
|
delete iter; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, HashBucketConflictReverseSuffixComparator) { |
|
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024; |
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) { |
|
|
|
|
for (unsigned char i = 1; i <= 3; i++) { |
|
|
|
|
Options options = CurrentOptions(); |
|
|
|
|
options.create_if_missing = true; |
|
|
|
@ -669,7 +686,8 @@ TEST(PlainTableDBTest, HashBucketConflictReverseSuffixComparator) { |
|
|
|
|
options.comparator = ∁ |
|
|
|
|
// Set only one bucket to force bucket conflict.
|
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
|
|
|
|
options.table_factory.reset(NewTotalOrderPlainTableFactory(16, 0, 2 ^ i)); |
|
|
|
|
options.table_factory.reset( |
|
|
|
|
NewTotalOrderPlainTableFactory(16, 0, 2 ^ i, huge_page_tlb_size)); |
|
|
|
|
DestroyAndReopen(&options); |
|
|
|
|
ASSERT_OK(Put("5000000000000fo0", "v1")); |
|
|
|
|
ASSERT_OK(Put("5000000000000fo1", "v2")); |
|
|
|
@ -741,6 +759,7 @@ TEST(PlainTableDBTest, HashBucketConflictReverseSuffixComparator) { |
|
|
|
|
|
|
|
|
|
delete iter; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(PlainTableDBTest, NonExistingKeyToNonEmptyBucket) { |
|
|
|
|