mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' into columnfamilies
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <string>
|
||||
@@ -25,6 +28,7 @@
|
||||
#include "rocksdb/slice_transform.h"
|
||||
#include "rocksdb/memtablerep.h"
|
||||
#include "table/block.h"
|
||||
#include "table/meta_blocks.h"
|
||||
#include "table/block_based_table_builder.h"
|
||||
#include "table/block_based_table_factory.h"
|
||||
#include "table/block_based_table_reader.h"
|
||||
@@ -946,10 +950,7 @@ TEST(BlockBasedTableTest, BasicBlockBasedTableProperties) {
|
||||
block_builder.Add(item.first, item.second);
|
||||
}
|
||||
Slice content = block_builder.Finish();
|
||||
ASSERT_EQ(
|
||||
content.size() + kBlockTrailerSize,
|
||||
props.data_size
|
||||
);
|
||||
ASSERT_EQ(content.size() + kBlockTrailerSize, props.data_size);
|
||||
}
|
||||
|
||||
TEST(BlockBasedTableTest, FilterPolicyNameProperties) {
|
||||
@@ -958,9 +959,7 @@ TEST(BlockBasedTableTest, FilterPolicyNameProperties) {
|
||||
std::vector<std::string> keys;
|
||||
KVMap kvmap;
|
||||
Options options;
|
||||
std::unique_ptr<const FilterPolicy> filter_policy(
|
||||
NewBloomFilterPolicy(10)
|
||||
);
|
||||
std::unique_ptr<const FilterPolicy> filter_policy(NewBloomFilterPolicy(10));
|
||||
options.filter_policy = filter_policy.get();
|
||||
|
||||
c.Finish(options, GetPlainInternalComparator(options.comparator), &keys,
|
||||
@@ -1032,10 +1031,8 @@ TEST(BlockBasedTableTest, NumBlockStat) {
|
||||
KVMap kvmap;
|
||||
c.Finish(options, GetPlainInternalComparator(options.comparator), &ks,
|
||||
&kvmap);
|
||||
ASSERT_EQ(
|
||||
kvmap.size(),
|
||||
c.table_reader()->GetTableProperties().num_data_blocks
|
||||
);
|
||||
ASSERT_EQ(kvmap.size(),
|
||||
c.table_reader()->GetTableProperties().num_data_blocks);
|
||||
}
|
||||
|
||||
class BlockCacheProperties {
|
||||
@@ -1050,32 +1047,26 @@ class BlockCacheProperties {
|
||||
}
|
||||
|
||||
// Check if the fetched props matches the expected ones.
|
||||
void AssertEqual(
|
||||
long index_block_cache_miss,
|
||||
long index_block_cache_hit,
|
||||
long data_block_cache_miss,
|
||||
long data_block_cache_hit) const {
|
||||
void AssertEqual(int64_t index_block_cache_miss,
|
||||
int64_t index_block_cache_hit, int64_t data_block_cache_miss,
|
||||
int64_t data_block_cache_hit) const {
|
||||
ASSERT_EQ(index_block_cache_miss, this->index_block_cache_miss);
|
||||
ASSERT_EQ(index_block_cache_hit, this->index_block_cache_hit);
|
||||
ASSERT_EQ(data_block_cache_miss, this->data_block_cache_miss);
|
||||
ASSERT_EQ(data_block_cache_hit, this->data_block_cache_hit);
|
||||
ASSERT_EQ(
|
||||
index_block_cache_miss + data_block_cache_miss,
|
||||
this->block_cache_miss
|
||||
);
|
||||
ASSERT_EQ(
|
||||
index_block_cache_hit + data_block_cache_hit,
|
||||
this->block_cache_hit
|
||||
);
|
||||
ASSERT_EQ(index_block_cache_miss + data_block_cache_miss,
|
||||
this->block_cache_miss);
|
||||
ASSERT_EQ(index_block_cache_hit + data_block_cache_hit,
|
||||
this->block_cache_hit);
|
||||
}
|
||||
|
||||
private:
|
||||
long block_cache_miss = 0;
|
||||
long block_cache_hit = 0;
|
||||
long index_block_cache_miss = 0;
|
||||
long index_block_cache_hit = 0;
|
||||
long data_block_cache_miss = 0;
|
||||
long data_block_cache_hit = 0;
|
||||
int64_t block_cache_miss = 0;
|
||||
int64_t block_cache_hit = 0;
|
||||
int64_t index_block_cache_miss = 0;
|
||||
int64_t index_block_cache_hit = 0;
|
||||
int64_t data_block_cache_miss = 0;
|
||||
int64_t data_block_cache_hit = 0;
|
||||
};
|
||||
|
||||
TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
@@ -1105,12 +1096,8 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
{
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
// index will be added to block cache.
|
||||
props.AssertEqual(
|
||||
1, // index block miss
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
props.AssertEqual(1, // index block miss
|
||||
0, 0, 0);
|
||||
}
|
||||
|
||||
// Only index block will be accessed
|
||||
@@ -1120,24 +1107,16 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
// NOTE: to help better highlight the "detla" of each ticker, I use
|
||||
// <last_value> + <added_value> to indicate the increment of changed
|
||||
// value; other numbers remain the same.
|
||||
props.AssertEqual(
|
||||
1,
|
||||
0 + 1, // index block hit
|
||||
0,
|
||||
0
|
||||
);
|
||||
props.AssertEqual(1, 0 + 1, // index block hit
|
||||
0, 0);
|
||||
}
|
||||
|
||||
// Only data block will be accessed
|
||||
{
|
||||
iter->SeekToFirst();
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
props.AssertEqual(
|
||||
1,
|
||||
1,
|
||||
0 + 1, // data block miss
|
||||
0
|
||||
);
|
||||
props.AssertEqual(1, 1, 0 + 1, // data block miss
|
||||
0);
|
||||
}
|
||||
|
||||
// Data block will be in cache
|
||||
@@ -1145,12 +1124,8 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
iter.reset(c.NewIterator());
|
||||
iter->SeekToFirst();
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
props.AssertEqual(
|
||||
1,
|
||||
1 + 1, // index block hit
|
||||
1,
|
||||
0 + 1 // data block hit
|
||||
);
|
||||
props.AssertEqual(1, 1 + 1, /* index block hit */
|
||||
1, 0 + 1 /* data block hit */);
|
||||
}
|
||||
// release the iterator so that the block cache can reset correctly.
|
||||
iter.reset();
|
||||
@@ -1176,12 +1151,8 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
c.Reopen(options);
|
||||
{
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
props.AssertEqual(
|
||||
1, // index block miss
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
props.AssertEqual(1, // index block miss
|
||||
0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1191,12 +1162,9 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
// is only 1, index block will be purged after data block is inserted.
|
||||
iter.reset(c.NewIterator());
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
props.AssertEqual(
|
||||
1 + 1, // index block miss
|
||||
0,
|
||||
0, // data block miss
|
||||
0
|
||||
);
|
||||
props.AssertEqual(1 + 1, // index block miss
|
||||
0, 0, // data block miss
|
||||
0);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1204,12 +1172,8 @@ TEST(BlockBasedTableTest, BlockCacheTest) {
|
||||
// block's cache miss.
|
||||
iter->SeekToFirst();
|
||||
BlockCacheProperties props(options.statistics.get());
|
||||
props.AssertEqual(
|
||||
2,
|
||||
0,
|
||||
0 + 1, // data block miss
|
||||
0
|
||||
);
|
||||
props.AssertEqual(2, 0, 0 + 1, // data block miss
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1316,7 +1280,6 @@ TEST(GeneralTableTest, ApproximateOffsetOfPlain) {
|
||||
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k06"), 510000, 511000));
|
||||
ASSERT_TRUE(Between(c.ApproximateOffsetOf("k07"), 510000, 511000));
|
||||
ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 610000, 612000));
|
||||
|
||||
}
|
||||
|
||||
static void DoCompressionTest(CompressionType comp) {
|
||||
@@ -1360,11 +1323,9 @@ TEST(GeneralTableTest, ApproximateOffsetOfCompressed) {
|
||||
valid++;
|
||||
}
|
||||
|
||||
for(int i =0; i < valid; i++)
|
||||
{
|
||||
for (int i = 0; i < valid; i++) {
|
||||
DoCompressionTest(compression_state[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(Harness, Randomized) {
|
||||
@@ -1375,8 +1336,8 @@ TEST(Harness, Randomized) {
|
||||
for (int num_entries = 0; num_entries < 2000;
|
||||
num_entries += (num_entries < 50 ? 1 : 200)) {
|
||||
if ((num_entries % 10) == 0) {
|
||||
fprintf(stderr, "case %d of %d: num_entries = %d\n",
|
||||
(i + 1), int(args.size()), num_entries);
|
||||
fprintf(stderr, "case %d of %d: num_entries = %d\n", (i + 1),
|
||||
static_cast<int>(args.size()), num_entries);
|
||||
}
|
||||
for (int e = 0; e < num_entries; e++) {
|
||||
std::string v;
|
||||
|
||||
Reference in New Issue
Block a user