2013-10-29 04:34:02 +01:00
|
|
|
// 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.
|
2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2013-10-29 04:34:02 +01:00
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
//
|
|
|
|
// 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.
|
2015-07-20 20:12:02 +02:00
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
|
2013-10-29 04:34:02 +01:00
|
|
|
#include <algorithm>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include "db/db_impl.h"
|
|
|
|
#include "db/filename.h"
|
|
|
|
#include "db/version_set.h"
|
|
|
|
#include "db/write_batch_internal.h"
|
|
|
|
#include "rocksdb/cache.h"
|
|
|
|
#include "rocksdb/compaction_filter.h"
|
2014-01-31 02:18:17 +01:00
|
|
|
#include "rocksdb/db.h"
|
2013-10-29 04:34:02 +01:00
|
|
|
#include "rocksdb/env.h"
|
2014-01-31 02:18:17 +01:00
|
|
|
#include "rocksdb/filter_policy.h"
|
|
|
|
#include "rocksdb/slice_transform.h"
|
|
|
|
#include "rocksdb/table.h"
|
2014-02-08 01:25:38 +01:00
|
|
|
#include "table/meta_blocks.h"
|
2014-07-19 01:58:13 +02:00
|
|
|
#include "table/bloom_block.h"
|
2015-09-11 20:36:33 +02:00
|
|
|
#include "table/table_builder.h"
|
2014-01-28 06:58:46 +01:00
|
|
|
#include "table/plain_table_factory.h"
|
plain table reader: non-mmap mode to keep two recent buffers
Summary: In plain table reader's non-mmap mode, we only keep the most recent read buffer. However, for binary search, it is likely we come back to a location to read. To avoid one pread in such a case, we keep two read buffers. It should cover most of the cases.
Test Plan:
1. run tests
2. check the optimization works through strace when running
./table_reader_bench -mmap_read=false --num_keys2=1 -num_keys1=5000 -table_factory=plain_table --iterator --through_db
Reviewers: anthony, rven, kradhakrishnan, igor, yhchiang, IslamAbdelRahman
Reviewed By: IslamAbdelRahman
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D51171
2015-12-24 02:30:10 +01:00
|
|
|
#include "table/plain_table_key_coding.h"
|
2014-02-08 01:25:38 +01:00
|
|
|
#include "table/plain_table_reader.h"
|
2013-10-29 04:34:02 +01:00
|
|
|
#include "util/hash.h"
|
|
|
|
#include "util/logging.h"
|
|
|
|
#include "util/mutexlock.h"
|
2015-03-20 01:29:37 +01:00
|
|
|
#include "util/string_util.h"
|
2013-10-29 04:34:02 +01:00
|
|
|
#include "util/testharness.h"
|
|
|
|
#include "util/testutil.h"
|
|
|
|
#include "utilities/merge_operators.h"
|
|
|
|
|
|
|
|
using std::unique_ptr;
|
|
|
|
|
|
|
|
namespace rocksdb {
|
plain table reader: non-mmap mode to keep two recent buffers
Summary: In plain table reader's non-mmap mode, we only keep the most recent read buffer. However, for binary search, it is likely we come back to a location to read. To avoid one pread in such a case, we keep two read buffers. It should cover most of the cases.
Test Plan:
1. run tests
2. check the optimization works through strace when running
./table_reader_bench -mmap_read=false --num_keys2=1 -num_keys1=5000 -table_factory=plain_table --iterator --through_db
Reviewers: anthony, rven, kradhakrishnan, igor, yhchiang, IslamAbdelRahman
Reviewed By: IslamAbdelRahman
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D51171
2015-12-24 02:30:10 +01:00
|
|
|
class PlainTableKeyDecoderTest : public testing::Test {};
|
|
|
|
|
|
|
|
TEST_F(PlainTableKeyDecoderTest, ReadNonMmap) {
|
|
|
|
std::string tmp;
|
|
|
|
Random rnd(301);
|
|
|
|
const uint32_t kLength = 2222;
|
|
|
|
Slice contents = test::RandomString(&rnd, kLength, &tmp);
|
|
|
|
test::StringSource* string_source =
|
|
|
|
new test::StringSource(contents, 0, false);
|
|
|
|
|
|
|
|
unique_ptr<RandomAccessFileReader> file_reader(
|
|
|
|
test::GetRandomAccessFileReader(string_source));
|
|
|
|
unique_ptr<PlainTableReaderFileInfo> file_info(new PlainTableReaderFileInfo(
|
|
|
|
std::move(file_reader), EnvOptions(), kLength));
|
|
|
|
|
|
|
|
{
|
|
|
|
PlainTableFileReader reader(file_info.get());
|
|
|
|
|
|
|
|
const uint32_t kReadSize = 77;
|
|
|
|
for (uint32_t pos = 0; pos < kLength; pos += kReadSize) {
|
|
|
|
uint32_t read_size = std::min(kLength - pos, kReadSize);
|
|
|
|
Slice out;
|
|
|
|
ASSERT_TRUE(reader.Read(pos, read_size, &out));
|
|
|
|
ASSERT_EQ(0, out.compare(tmp.substr(pos, read_size)));
|
|
|
|
}
|
|
|
|
|
2016-01-12 01:10:48 +01:00
|
|
|
ASSERT_LT(uint32_t(string_source->total_reads()), kLength / kReadSize / 2);
|
plain table reader: non-mmap mode to keep two recent buffers
Summary: In plain table reader's non-mmap mode, we only keep the most recent read buffer. However, for binary search, it is likely we come back to a location to read. To avoid one pread in such a case, we keep two read buffers. It should cover most of the cases.
Test Plan:
1. run tests
2. check the optimization works through strace when running
./table_reader_bench -mmap_read=false --num_keys2=1 -num_keys1=5000 -table_factory=plain_table --iterator --through_db
Reviewers: anthony, rven, kradhakrishnan, igor, yhchiang, IslamAbdelRahman
Reviewed By: IslamAbdelRahman
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D51171
2015-12-24 02:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::vector<std::pair<uint32_t, uint32_t>>> reads = {
|
|
|
|
{{600, 30}, {590, 30}, {600, 20}, {600, 40}},
|
|
|
|
{{800, 20}, {100, 20}, {500, 20}, {1500, 20}, {100, 20}, {80, 20}},
|
|
|
|
{{1000, 20}, {500, 20}, {1000, 50}},
|
|
|
|
{{1000, 20}, {500, 20}, {500, 20}},
|
|
|
|
{{1000, 20}, {500, 20}, {200, 20}, {500, 20}},
|
|
|
|
{{1000, 20}, {500, 20}, {200, 20}, {1000, 50}},
|
|
|
|
{{600, 500}, {610, 20}, {100, 20}},
|
|
|
|
{{500, 100}, {490, 100}, {550, 50}},
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<int> num_file_reads = {2, 6, 2, 2, 4, 3, 2, 2};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < reads.size(); i++) {
|
|
|
|
string_source->set_total_reads(0);
|
|
|
|
PlainTableFileReader reader(file_info.get());
|
|
|
|
for (auto p : reads[i]) {
|
|
|
|
Slice out;
|
|
|
|
ASSERT_TRUE(reader.Read(p.first, p.second, &out));
|
|
|
|
ASSERT_EQ(0, out.compare(tmp.substr(p.first, p.second)));
|
|
|
|
}
|
|
|
|
ASSERT_EQ(num_file_reads[i], string_source->total_reads());
|
|
|
|
}
|
|
|
|
}
|
2013-10-29 04:34:02 +01:00
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
class PlainTableDBTest : public testing::Test,
|
|
|
|
public testing::WithParamInterface<bool> {
|
2014-01-03 19:53:21 +01:00
|
|
|
protected:
|
|
|
|
private:
|
2013-10-29 04:34:02 +01:00
|
|
|
std::string dbname_;
|
|
|
|
Env* env_;
|
|
|
|
DB* db_;
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
bool mmap_mode_;
|
2013-10-29 04:34:02 +01:00
|
|
|
Options last_options_;
|
|
|
|
|
2014-01-03 19:53:21 +01:00
|
|
|
public:
|
2015-09-17 01:57:43 +02:00
|
|
|
PlainTableDBTest() : env_(Env::Default()) {}
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
~PlainTableDBTest() {
|
|
|
|
delete db_;
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_OK(DestroyDB(dbname_, Options()));
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
void SetUp() override {
|
|
|
|
mmap_mode_ = GetParam();
|
|
|
|
dbname_ = test::TmpDir() + "/plain_table_db_test";
|
|
|
|
EXPECT_OK(DestroyDB(dbname_, Options()));
|
|
|
|
db_ = nullptr;
|
|
|
|
Reopen();
|
|
|
|
}
|
|
|
|
|
2013-10-29 04:34:02 +01:00
|
|
|
// Return the current option configuration.
|
|
|
|
Options CurrentOptions() {
|
|
|
|
Options options;
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 0;
|
|
|
|
plain_table_options.bloom_bits_per_key = 2;
|
|
|
|
plain_table_options.hash_table_ratio = 0.8;
|
|
|
|
plain_table_options.index_sparseness = 3;
|
|
|
|
plain_table_options.huge_page_tlb_size = 0;
|
|
|
|
plain_table_options.encoding_type = kPrefix;
|
|
|
|
plain_table_options.full_scan_mode = false;
|
2014-07-19 01:58:13 +02:00
|
|
|
plain_table_options.store_index_in_file = false;
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
2014-07-19 01:58:13 +02:00
|
|
|
options.memtable_factory.reset(NewHashLinkListRepFactory(4, 0, 3, true));
|
2014-07-18 09:08:38 +02:00
|
|
|
|
2014-03-10 20:56:46 +01:00
|
|
|
options.prefix_extractor.reset(NewFixedPrefixTransform(8));
|
2015-09-17 01:57:43 +02:00
|
|
|
options.allow_mmap_reads = mmap_mode_;
|
2013-10-29 04:34:02 +01:00
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBImpl* dbfull() {
|
|
|
|
return reinterpret_cast<DBImpl*>(db_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reopen(Options* options = nullptr) {
|
|
|
|
ASSERT_OK(TryReopen(options));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Close() {
|
|
|
|
delete db_;
|
|
|
|
db_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyAndReopen(Options* options = nullptr) {
|
|
|
|
//Destroy using last options
|
|
|
|
Destroy(&last_options_);
|
|
|
|
ASSERT_OK(TryReopen(options));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Destroy(Options* options) {
|
|
|
|
delete db_;
|
|
|
|
db_ = nullptr;
|
|
|
|
ASSERT_OK(DestroyDB(dbname_, *options));
|
|
|
|
}
|
|
|
|
|
|
|
|
Status PureReopen(Options* options, DB** db) {
|
|
|
|
return DB::Open(*options, dbname_, db);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status TryReopen(Options* options = nullptr) {
|
|
|
|
delete db_;
|
|
|
|
db_ = nullptr;
|
|
|
|
Options opts;
|
|
|
|
if (options != nullptr) {
|
|
|
|
opts = *options;
|
|
|
|
} else {
|
|
|
|
opts = CurrentOptions();
|
|
|
|
opts.create_if_missing = true;
|
|
|
|
}
|
|
|
|
last_options_ = opts;
|
|
|
|
|
|
|
|
return DB::Open(opts, dbname_, &db_);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status Put(const Slice& k, const Slice& v) {
|
|
|
|
return db_->Put(WriteOptions(), k, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status Delete(const std::string& k) {
|
|
|
|
return db_->Delete(WriteOptions(), k);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Get(const std::string& k, const Snapshot* snapshot = nullptr) {
|
2014-04-25 21:21:34 +02:00
|
|
|
ReadOptions options;
|
2013-10-29 04:34:02 +01:00
|
|
|
options.snapshot = snapshot;
|
|
|
|
std::string result;
|
|
|
|
Status s = db_->Get(options, k, &result);
|
|
|
|
if (s.IsNotFound()) {
|
|
|
|
result = "NOT_FOUND";
|
|
|
|
} else if (!s.ok()) {
|
|
|
|
result = s.ToString();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int NumTableFilesAtLevel(int level) {
|
|
|
|
std::string property;
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(db_->GetProperty(
|
|
|
|
"rocksdb.num-files-at-level" + NumberToString(level), &property));
|
2013-10-29 04:34:02 +01:00
|
|
|
return atoi(property.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return spread of files per level
|
|
|
|
std::string FilesPerLevel() {
|
|
|
|
std::string result;
|
2014-11-11 22:47:22 +01:00
|
|
|
size_t last_non_zero_offset = 0;
|
2013-10-29 04:34:02 +01:00
|
|
|
for (int level = 0; level < db_->NumberLevels(); level++) {
|
|
|
|
int f = NumTableFilesAtLevel(level);
|
|
|
|
char buf[100];
|
|
|
|
snprintf(buf, sizeof(buf), "%s%d", (level ? "," : ""), f);
|
|
|
|
result += buf;
|
|
|
|
if (f > 0) {
|
|
|
|
last_non_zero_offset = result.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result.resize(last_non_zero_offset);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string IterStatus(Iterator* iter) {
|
|
|
|
std::string result;
|
|
|
|
if (iter->Valid()) {
|
|
|
|
result = iter->key().ToString() + "->" + iter->value().ToString();
|
|
|
|
} else {
|
|
|
|
result = "(invalid)";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, Empty) {
|
2014-01-03 19:53:21 +01:00
|
|
|
ASSERT_TRUE(dbfull() != nullptr);
|
2013-10-29 04:34:02 +01:00
|
|
|
ASSERT_EQ("NOT_FOUND", Get("0000000000000foo"));
|
|
|
|
}
|
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
extern const uint64_t kPlainTableMagicNumber;
|
|
|
|
|
2014-02-08 01:25:38 +01:00
|
|
|
class TestPlainTableReader : public PlainTableReader {
|
|
|
|
public:
|
2014-09-05 01:18:36 +02:00
|
|
|
TestPlainTableReader(const EnvOptions& env_options,
|
2014-02-08 01:25:38 +01:00
|
|
|
const InternalKeyComparator& icomparator,
|
2014-06-19 01:36:48 +02:00
|
|
|
EncodingType encoding_type, uint64_t file_size,
|
|
|
|
int bloom_bits_per_key, double hash_table_ratio,
|
|
|
|
size_t index_sparseness,
|
2014-02-08 01:25:38 +01:00
|
|
|
const TableProperties* table_properties,
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
unique_ptr<RandomAccessFileReader>&& file,
|
2014-09-05 01:18:36 +02:00
|
|
|
const ImmutableCFOptions& ioptions,
|
2016-04-07 08:10:32 +02:00
|
|
|
bool* expect_bloom_not_match, bool store_index_in_file,
|
|
|
|
uint32_t column_family_id,
|
|
|
|
const std::string& column_family_name)
|
2014-09-05 01:18:36 +02:00
|
|
|
: PlainTableReader(ioptions, std::move(file), env_options, icomparator,
|
2014-06-19 01:36:48 +02:00
|
|
|
encoding_type, file_size, table_properties),
|
2014-02-08 01:25:38 +01:00
|
|
|
expect_bloom_not_match_(expect_bloom_not_match) {
|
2015-09-17 01:57:43 +02:00
|
|
|
Status s = MmapDataIfNeeded();
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(s.ok());
|
2014-06-19 01:36:48 +02:00
|
|
|
|
|
|
|
s = PopulateIndex(const_cast<TableProperties*>(table_properties),
|
|
|
|
bloom_bits_per_key, hash_table_ratio, index_sparseness,
|
|
|
|
2 * 1024 * 1024);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(s.ok());
|
2014-07-19 01:58:13 +02:00
|
|
|
|
|
|
|
TableProperties* props = const_cast<TableProperties*>(table_properties);
|
2016-04-07 08:10:32 +02:00
|
|
|
EXPECT_EQ(column_family_id, static_cast<uint32_t>(props->column_family_id));
|
|
|
|
EXPECT_EQ(column_family_name, props->column_family_name);
|
2014-07-19 01:58:13 +02:00
|
|
|
if (store_index_in_file) {
|
|
|
|
auto bloom_version_ptr = props->user_collected_properties.find(
|
|
|
|
PlainTablePropertyNames::kBloomVersion);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(bloom_version_ptr != props->user_collected_properties.end());
|
|
|
|
EXPECT_EQ(bloom_version_ptr->second, std::string("1"));
|
2014-09-05 01:18:36 +02:00
|
|
|
if (ioptions.bloom_locality > 0) {
|
2014-07-19 01:58:13 +02:00
|
|
|
auto num_blocks_ptr = props->user_collected_properties.find(
|
|
|
|
PlainTablePropertyNames::kNumBloomBlocks);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(num_blocks_ptr != props->user_collected_properties.end());
|
2014-07-19 01:58:13 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~TestPlainTableReader() {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool MatchBloom(uint32_t hash) const override {
|
|
|
|
bool ret = PlainTableReader::MatchBloom(hash);
|
2014-07-19 01:58:13 +02:00
|
|
|
if (*expect_bloom_not_match_) {
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(!ret);
|
2014-07-19 01:58:13 +02:00
|
|
|
} else {
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(ret);
|
2014-07-19 01:58:13 +02:00
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
bool* expect_bloom_not_match_;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const uint64_t kPlainTableMagicNumber;
|
|
|
|
class TestPlainTableFactory : public PlainTableFactory {
|
|
|
|
public:
|
|
|
|
explicit TestPlainTableFactory(bool* expect_bloom_not_match,
|
2016-04-07 08:10:32 +02:00
|
|
|
const PlainTableOptions& options,
|
|
|
|
uint32_t column_family_id,
|
|
|
|
std::string column_family_name)
|
2014-07-18 09:08:38 +02:00
|
|
|
: PlainTableFactory(options),
|
|
|
|
bloom_bits_per_key_(options.bloom_bits_per_key),
|
|
|
|
hash_table_ratio_(options.hash_table_ratio),
|
|
|
|
index_sparseness_(options.index_sparseness),
|
2014-07-19 01:58:13 +02:00
|
|
|
store_index_in_file_(options.store_index_in_file),
|
2016-04-07 08:10:32 +02:00
|
|
|
expect_bloom_not_match_(expect_bloom_not_match),
|
|
|
|
column_family_id_(column_family_id),
|
|
|
|
column_family_name_(std::move(column_family_name)) {}
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2015-09-11 20:36:33 +02:00
|
|
|
Status NewTableReader(const TableReaderOptions& table_reader_options,
|
Move rate_limiter, write buffering, most perf context instrumentation and most random kill out of Env
Summary: We want to keep Env a think layer for better portability. Less platform dependent codes should be moved out of Env. In this patch, I create a wrapper of file readers and writers, and put rate limiting, write buffering, as well as most perf context instrumentation and random kill out of Env. It will make it easier to maintain multiple Env in the future.
Test Plan: Run all existing unit tests.
Reviewers: anthony, kradhakrishnan, IslamAbdelRahman, yhchiang, igor
Reviewed By: igor
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D42321
2015-07-18 01:16:11 +02:00
|
|
|
unique_ptr<RandomAccessFileReader>&& file,
|
|
|
|
uint64_t file_size,
|
2014-02-08 01:25:38 +01:00
|
|
|
unique_ptr<TableReader>* table) const override {
|
|
|
|
TableProperties* props = nullptr;
|
2015-09-11 20:36:33 +02:00
|
|
|
auto s =
|
|
|
|
ReadTableProperties(file.get(), file_size, kPlainTableMagicNumber,
|
|
|
|
table_reader_options.ioptions.env,
|
|
|
|
table_reader_options.ioptions.info_log, &props);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(s.ok());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
if (store_index_in_file_) {
|
|
|
|
BlockHandle bloom_block_handle;
|
|
|
|
s = FindMetaBlock(file.get(), file_size, kPlainTableMagicNumber,
|
2015-09-11 20:36:33 +02:00
|
|
|
table_reader_options.ioptions.env,
|
|
|
|
BloomBlockBuilder::kBloomBlock, &bloom_block_handle);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(s.ok());
|
2014-07-19 01:58:13 +02:00
|
|
|
|
|
|
|
BlockHandle index_block_handle;
|
2015-09-11 20:36:33 +02:00
|
|
|
s = FindMetaBlock(file.get(), file_size, kPlainTableMagicNumber,
|
|
|
|
table_reader_options.ioptions.env,
|
|
|
|
PlainTableIndexBuilder::kPlainTableIndexBlock,
|
|
|
|
&index_block_handle);
|
rocksdb: Replace ASSERT* with EXPECT* in functions that does not return void value
Summary:
gtest does not use exceptions to fail a unit test by design, and `ASSERT*`s are implemented using `return`. As a consequence we cannot use `ASSERT*` in a function that does not return `void` value ([[ https://code.google.com/p/googletest/wiki/AdvancedGuide#Assertion_Placement | 1]]), and have to fix our existing code. This diff does this in a generic way, with no manual changes.
In order to detect all existing `ASSERT*` that are used in functions that doesn't return void value, I change the code to generate compile errors for such cases.
In `util/testharness.h` I defined `EXPECT*` assertions, the same way as `ASSERT*`, and redefined `ASSERT*` to return `void`. Then executed:
```lang=bash
% USE_CLANG=1 make all -j55 -k 2> build.log
% perl -naF: -e 'print "-- -number=".$F[1]." ".$F[0]."\n" if /: error:/' \
build.log | xargs -L 1 perl -spi -e 's/ASSERT/EXPECT/g if $. == $number'
% make format
```
After that I reverted back change to `ASSERT*` in `util/testharness.h`. But preserved introduced `EXPECT*`, which is the same as `ASSERT*`. This will be deleted once switched to gtest.
This diff is independent and contains manual changes only in `util/testharness.h`.
Test Plan:
Make sure all tests are passing.
```lang=bash
% USE_CLANG=1 make check
```
Reviewers: igor, lgalanis, sdong, yufei.zhu, rven, meyering
Reviewed By: meyering
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D33333
2015-03-17 04:52:32 +01:00
|
|
|
EXPECT_TRUE(s.ok());
|
2014-07-19 01:58:13 +02:00
|
|
|
}
|
|
|
|
|
2014-06-19 01:36:48 +02:00
|
|
|
auto& user_props = props->user_collected_properties;
|
|
|
|
auto encoding_type_prop =
|
|
|
|
user_props.find(PlainTablePropertyNames::kEncodingType);
|
|
|
|
assert(encoding_type_prop != user_props.end());
|
|
|
|
EncodingType encoding_type = static_cast<EncodingType>(
|
|
|
|
DecodeFixed32(encoding_type_prop->second.c_str()));
|
|
|
|
|
2014-02-08 01:25:38 +01:00
|
|
|
std::unique_ptr<PlainTableReader> new_reader(new TestPlainTableReader(
|
2015-09-11 20:36:33 +02:00
|
|
|
table_reader_options.env_options,
|
|
|
|
table_reader_options.internal_comparator, encoding_type, file_size,
|
2014-06-19 01:36:48 +02:00
|
|
|
bloom_bits_per_key_, hash_table_ratio_, index_sparseness_, props,
|
2015-09-11 20:36:33 +02:00
|
|
|
std::move(file), table_reader_options.ioptions, expect_bloom_not_match_,
|
2016-04-07 08:10:32 +02:00
|
|
|
store_index_in_file_, column_family_id_, column_family_name_));
|
2014-02-08 01:25:38 +01:00
|
|
|
|
|
|
|
*table = std::move(new_reader);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int bloom_bits_per_key_;
|
|
|
|
double hash_table_ratio_;
|
|
|
|
size_t index_sparseness_;
|
2014-07-19 01:58:13 +02:00
|
|
|
bool store_index_in_file_;
|
2014-02-08 01:25:38 +01:00
|
|
|
bool* expect_bloom_not_match_;
|
2016-04-07 08:10:32 +02:00
|
|
|
const uint32_t column_family_id_;
|
|
|
|
const std::string column_family_name_;
|
2014-02-08 01:25:38 +01:00
|
|
|
};
|
2013-10-29 04:34:02 +01:00
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, Flush) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024;
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) {
|
2014-06-19 01:36:48 +02:00
|
|
|
for (EncodingType encoding_type : {kPlain, kPrefix}) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) {
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) {
|
2014-07-19 01:58:13 +02:00
|
|
|
for (int store_index_in_file = 0; store_index_in_file <= 1;
|
|
|
|
++store_index_in_file) {
|
|
|
|
if (!bloom_bits && store_index_in_file) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-18 09:08:38 +02:00
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
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
|
|
|
|
if (total_order) {
|
|
|
|
options.prefix_extractor.reset();
|
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 0;
|
|
|
|
plain_table_options.bloom_bits_per_key = bloom_bits;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 2;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
plain_table_options.encoding_type = encoding_type;
|
|
|
|
plain_table_options.full_scan_mode = false;
|
|
|
|
plain_table_options.store_index_in_file = store_index_in_file;
|
|
|
|
|
|
|
|
options.table_factory.reset(
|
|
|
|
NewPlainTableFactory(plain_table_options));
|
|
|
|
} else {
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 0;
|
|
|
|
plain_table_options.bloom_bits_per_key = bloom_bits;
|
|
|
|
plain_table_options.hash_table_ratio = 0.75;
|
|
|
|
plain_table_options.index_sparseness = 16;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
plain_table_options.encoding_type = encoding_type;
|
|
|
|
plain_table_options.full_scan_mode = false;
|
|
|
|
plain_table_options.store_index_in_file = store_index_in_file;
|
|
|
|
|
|
|
|
options.table_factory.reset(
|
|
|
|
NewPlainTableFactory(plain_table_options));
|
|
|
|
}
|
|
|
|
DestroyAndReopen(&options);
|
2014-08-05 20:27:34 +02:00
|
|
|
uint64_t int_num;
|
|
|
|
ASSERT_TRUE(dbfull()->GetIntProperty(
|
|
|
|
"rocksdb.estimate-table-readers-mem", &int_num));
|
|
|
|
ASSERT_EQ(int_num, 0U);
|
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
ASSERT_OK(Put("1000000000000foo", "v1"));
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "v2"));
|
|
|
|
ASSERT_OK(Put("1000000000000foo", "v3"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
2014-08-05 20:27:34 +02:00
|
|
|
ASSERT_TRUE(dbfull()->GetIntProperty(
|
|
|
|
"rocksdb.estimate-table-readers-mem", &int_num));
|
|
|
|
ASSERT_GT(int_num, 0U);
|
|
|
|
|
2014-07-19 01:58:13 +02:00
|
|
|
TablePropertiesCollection ptc;
|
|
|
|
reinterpret_cast<DB*>(dbfull())->GetPropertiesOfAllTables(&ptc);
|
|
|
|
ASSERT_EQ(1U, ptc.size());
|
|
|
|
auto row = ptc.begin();
|
|
|
|
auto tp = row->second;
|
|
|
|
|
|
|
|
if (!store_index_in_file) {
|
|
|
|
ASSERT_EQ(total_order ? "4" : "12",
|
|
|
|
(tp->user_collected_properties)
|
|
|
|
.at("plain_table_hash_table_size"));
|
|
|
|
ASSERT_EQ("0", (tp->user_collected_properties)
|
|
|
|
.at("plain_table_sub_index_size"));
|
|
|
|
} else {
|
|
|
|
ASSERT_EQ("0", (tp->user_collected_properties)
|
|
|
|
.at("plain_table_hash_table_size"));
|
|
|
|
ASSERT_EQ("0", (tp->user_collected_properties)
|
|
|
|
.at("plain_table_sub_index_size"));
|
|
|
|
}
|
|
|
|
ASSERT_EQ("v3", Get("1000000000000foo"));
|
|
|
|
ASSERT_EQ("v2", Get("0000000000000bar"));
|
|
|
|
}
|
2014-05-04 22:55:53 +02:00
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, Flush2) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024;
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) {
|
2014-06-19 01:36:48 +02:00
|
|
|
for (EncodingType encoding_type : {kPlain, kPrefix}) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) {
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) {
|
2014-07-19 01:58:13 +02:00
|
|
|
for (int store_index_in_file = 0; store_index_in_file <= 1;
|
|
|
|
++store_index_in_file) {
|
|
|
|
if (encoding_type == kPrefix && total_order) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!bloom_bits && store_index_in_file) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (total_order && store_index_in_file) {
|
2014-06-19 01:36:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
2014-05-04 22:55:53 +02:00
|
|
|
bool expect_bloom_not_match = false;
|
|
|
|
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
|
2014-07-19 01:58:13 +02:00
|
|
|
PlainTableOptions plain_table_options;
|
2014-05-04 17:37:09 +02:00
|
|
|
if (total_order) {
|
2014-05-04 22:55:53 +02:00
|
|
|
options.prefix_extractor = nullptr;
|
2014-07-18 09:08:38 +02:00
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 2;
|
2014-05-04 22:55:53 +02:00
|
|
|
} else {
|
2014-07-18 09:08:38 +02:00
|
|
|
plain_table_options.hash_table_ratio = 0.75;
|
|
|
|
plain_table_options.index_sparseness = 16;
|
2014-05-04 22:55:53 +02:00
|
|
|
}
|
2014-07-19 01:58:13 +02:00
|
|
|
plain_table_options.user_key_len = kPlainTableVariableLength;
|
|
|
|
plain_table_options.bloom_bits_per_key = bloom_bits;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
plain_table_options.encoding_type = encoding_type;
|
|
|
|
plain_table_options.store_index_in_file = store_index_in_file;
|
|
|
|
options.table_factory.reset(new TestPlainTableFactory(
|
2016-04-07 08:10:32 +02:00
|
|
|
&expect_bloom_not_match, plain_table_options,
|
|
|
|
0 /* column_family_id */, kDefaultColumnFamilyName));
|
2014-07-19 01:58:13 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
DestroyAndReopen(&options);
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "b"));
|
|
|
|
ASSERT_OK(Put("1000000000000foo", "v1"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
|
|
|
ASSERT_OK(Put("1000000000000foo", "v2"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v2", Get("1000000000000foo"));
|
|
|
|
|
|
|
|
ASSERT_OK(Put("0000000000000eee", "v3"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v3", Get("0000000000000eee"));
|
|
|
|
|
|
|
|
ASSERT_OK(Delete("0000000000000bar"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("0000000000000bar"));
|
|
|
|
|
|
|
|
ASSERT_OK(Put("0000000000000eee", "v5"));
|
|
|
|
ASSERT_OK(Put("9000000000000eee", "v5"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v5", Get("0000000000000eee"));
|
|
|
|
|
|
|
|
// Test Bloom Filter
|
|
|
|
if (bloom_bits > 0) {
|
|
|
|
// Neither key nor value should exist.
|
|
|
|
expect_bloom_not_match = true;
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("5_not00000000bar"));
|
|
|
|
// Key doesn't exist any more but prefix exists.
|
|
|
|
if (total_order) {
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("1000000000000not"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("0000000000000not"));
|
|
|
|
}
|
|
|
|
expect_bloom_not_match = false;
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-19 01:58:13 +02:00
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
2014-06-19 01:36:48 +02:00
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, Iterator) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (size_t huge_page_tlb_size = 0; huge_page_tlb_size <= 2 * 1024 * 1024;
|
|
|
|
huge_page_tlb_size += 2 * 1024 * 1024) {
|
2014-06-19 01:36:48 +02:00
|
|
|
for (EncodingType encoding_type : {kPlain, kPrefix}) {
|
2014-05-04 22:55:53 +02:00
|
|
|
for (int bloom_bits = 0; bloom_bits <= 117; bloom_bits += 117) {
|
|
|
|
for (int total_order = 0; total_order <= 1; total_order++) {
|
2014-06-19 01:36:48 +02:00
|
|
|
if (encoding_type == kPrefix && total_order == 1) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-04 22:55:53 +02:00
|
|
|
bool expect_bloom_not_match = false;
|
|
|
|
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
|
|
|
|
if (total_order) {
|
|
|
|
options.prefix_extractor = nullptr;
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = bloom_bits;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 2;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
plain_table_options.encoding_type = encoding_type;
|
|
|
|
|
2014-06-19 01:36:48 +02:00
|
|
|
options.table_factory.reset(new TestPlainTableFactory(
|
2016-04-07 08:10:32 +02:00
|
|
|
&expect_bloom_not_match, plain_table_options,
|
|
|
|
0 /* column_family_id */, kDefaultColumnFamilyName));
|
2014-05-04 22:55:53 +02:00
|
|
|
} else {
|
2014-07-18 09:08:38 +02:00
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = bloom_bits;
|
|
|
|
plain_table_options.hash_table_ratio = 0.75;
|
|
|
|
plain_table_options.index_sparseness = 16;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
plain_table_options.encoding_type = encoding_type;
|
|
|
|
|
2014-06-19 01:36:48 +02:00
|
|
|
options.table_factory.reset(new TestPlainTableFactory(
|
2016-04-07 08:10:32 +02:00
|
|
|
&expect_bloom_not_match, plain_table_options,
|
|
|
|
0 /* column_family_id */, kDefaultColumnFamilyName));
|
2014-05-04 22:55:53 +02:00
|
|
|
}
|
|
|
|
DestroyAndReopen(&options);
|
|
|
|
|
|
|
|
ASSERT_OK(Put("1000000000foo002", "v_2"));
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "random"));
|
|
|
|
ASSERT_OK(Put("1000000000foo001", "v1"));
|
|
|
|
ASSERT_OK(Put("3000000000000bar", "bar_v"));
|
|
|
|
ASSERT_OK(Put("1000000000foo003", "v__3"));
|
|
|
|
ASSERT_OK(Put("1000000000foo004", "v__4"));
|
|
|
|
ASSERT_OK(Put("1000000000foo005", "v__5"));
|
|
|
|
ASSERT_OK(Put("1000000000foo007", "v__7"));
|
|
|
|
ASSERT_OK(Put("1000000000foo008", "v__8"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v1", Get("1000000000foo001"));
|
|
|
|
ASSERT_EQ("v__3", Get("1000000000foo003"));
|
|
|
|
Iterator* iter = dbfull()->NewIterator(ReadOptions());
|
|
|
|
iter->Seek("1000000000foo000");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo001", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v1", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo002", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v_2", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo003", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__3", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo004", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__4", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("3000000000000bar");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("3000000000000bar", iter->key().ToString());
|
|
|
|
ASSERT_EQ("bar_v", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000foo000");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo001", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v1", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000foo005");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo005", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__5", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000foo006");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo007", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__7", iter->value().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000foo008");
|
2014-05-04 17:37:09 +02:00
|
|
|
ASSERT_TRUE(iter->Valid());
|
2014-05-04 22:55:53 +02:00
|
|
|
ASSERT_EQ("1000000000foo008", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__8", iter->value().ToString());
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
if (total_order == 0) {
|
|
|
|
iter->Seek("1000000000foo009");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("3000000000000bar", iter->key().ToString());
|
2014-05-04 17:37:09 +02:00
|
|
|
}
|
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
// Test Bloom Filter
|
|
|
|
if (bloom_bits > 0) {
|
|
|
|
if (!total_order) {
|
|
|
|
// Neither key nor value should exist.
|
|
|
|
expect_bloom_not_match = true;
|
|
|
|
iter->Seek("2not000000000bar");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2not000000000bar"));
|
|
|
|
expect_bloom_not_match = false;
|
|
|
|
} else {
|
|
|
|
expect_bloom_not_match = true;
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2not000000000bar"));
|
|
|
|
expect_bloom_not_match = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
2014-06-19 01:36:48 +02:00
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-10 06:17:14 +02:00
|
|
|
namespace {
|
2014-04-08 01:56:26 +02:00
|
|
|
std::string MakeLongKey(size_t length, char c) {
|
|
|
|
return std::string(length, c);
|
|
|
|
}
|
2014-04-10 06:17:14 +02:00
|
|
|
} // namespace
|
2014-04-08 01:56:26 +02:00
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, IteratorLargeKeys) {
|
2014-04-08 01:56:26 +02:00
|
|
|
Options options = CurrentOptions();
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 0;
|
|
|
|
plain_table_options.bloom_bits_per_key = 0;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
2014-04-08 01:56:26 +02:00
|
|
|
options.create_if_missing = true;
|
|
|
|
options.prefix_extractor.reset();
|
|
|
|
DestroyAndReopen(&options);
|
|
|
|
|
|
|
|
std::string key_list[] = {
|
|
|
|
MakeLongKey(30, '0'),
|
|
|
|
MakeLongKey(16, '1'),
|
|
|
|
MakeLongKey(32, '2'),
|
|
|
|
MakeLongKey(60, '3'),
|
|
|
|
MakeLongKey(90, '4'),
|
|
|
|
MakeLongKey(50, '5'),
|
|
|
|
MakeLongKey(26, '6')
|
|
|
|
};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 7; i++) {
|
2014-11-25 05:44:49 +01:00
|
|
|
ASSERT_OK(Put(key_list[i], ToString(i)));
|
2014-04-08 01:56:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
2014-04-25 21:21:34 +02:00
|
|
|
Iterator* iter = dbfull()->NewIterator(ReadOptions());
|
2014-04-08 01:56:26 +02:00
|
|
|
iter->Seek(key_list[0]);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 7; i++) {
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ(key_list[i], iter->key().ToString());
|
2014-11-25 05:44:49 +01:00
|
|
|
ASSERT_EQ(ToString(i), iter->value().ToString());
|
2014-04-08 01:56:26 +02:00
|
|
|
iter->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
|
|
|
|
2014-06-19 01:36:48 +02:00
|
|
|
namespace {
|
|
|
|
std::string MakeLongKeyWithPrefix(size_t length, char c) {
|
|
|
|
return "00000000" + std::string(length - 8, c);
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, IteratorLargeKeysWithPrefix) {
|
2014-06-19 01:36:48 +02:00
|
|
|
Options options = CurrentOptions();
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = 0;
|
|
|
|
plain_table_options.hash_table_ratio = 0.8;
|
|
|
|
plain_table_options.index_sparseness = 3;
|
|
|
|
plain_table_options.huge_page_tlb_size = 0;
|
|
|
|
plain_table_options.encoding_type = kPrefix;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
2014-06-19 01:36:48 +02:00
|
|
|
options.create_if_missing = true;
|
|
|
|
DestroyAndReopen(&options);
|
|
|
|
|
|
|
|
std::string key_list[] = {
|
|
|
|
MakeLongKeyWithPrefix(30, '0'), MakeLongKeyWithPrefix(16, '1'),
|
|
|
|
MakeLongKeyWithPrefix(32, '2'), MakeLongKeyWithPrefix(60, '3'),
|
|
|
|
MakeLongKeyWithPrefix(90, '4'), MakeLongKeyWithPrefix(50, '5'),
|
|
|
|
MakeLongKeyWithPrefix(26, '6')};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 7; i++) {
|
2014-11-25 05:44:49 +01:00
|
|
|
ASSERT_OK(Put(key_list[i], ToString(i)));
|
2014-06-19 01:36:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
|
|
|
Iterator* iter = dbfull()->NewIterator(ReadOptions());
|
|
|
|
iter->Seek(key_list[0]);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 7; i++) {
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ(key_list[i], iter->key().ToString());
|
2014-11-25 05:44:49 +01:00
|
|
|
ASSERT_EQ(ToString(i), iter->value().ToString());
|
2014-06-19 01:36:48 +02:00
|
|
|
iter->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, IteratorReverseSuffixComparator) {
|
2014-02-08 01:25:38 +01:00
|
|
|
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
|
2014-10-29 21:49:45 +01:00
|
|
|
test::SimpleSuffixReverseComparator comp;
|
2014-02-08 01:25:38 +01:00
|
|
|
options.comparator = ∁
|
|
|
|
DestroyAndReopen(&options);
|
|
|
|
|
2013-10-29 04:34:02 +01:00
|
|
|
ASSERT_OK(Put("1000000000foo002", "v_2"));
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "random"));
|
|
|
|
ASSERT_OK(Put("1000000000foo001", "v1"));
|
|
|
|
ASSERT_OK(Put("3000000000000bar", "bar_v"));
|
|
|
|
ASSERT_OK(Put("1000000000foo003", "v__3"));
|
|
|
|
ASSERT_OK(Put("1000000000foo004", "v__4"));
|
|
|
|
ASSERT_OK(Put("1000000000foo005", "v__5"));
|
|
|
|
ASSERT_OK(Put("1000000000foo007", "v__7"));
|
|
|
|
ASSERT_OK(Put("1000000000foo008", "v__8"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v1", Get("1000000000foo001"));
|
|
|
|
ASSERT_EQ("v__3", Get("1000000000foo003"));
|
2014-04-25 21:21:34 +02:00
|
|
|
Iterator* iter = dbfull()->NewIterator(ReadOptions());
|
2014-02-08 01:25:38 +01:00
|
|
|
iter->Seek("1000000000foo009");
|
2013-10-29 04:34:02 +01:00
|
|
|
ASSERT_TRUE(iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
ASSERT_EQ("1000000000foo008", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__8", iter->value().ToString());
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
ASSERT_EQ("1000000000foo007", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__7", iter->value().ToString());
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
ASSERT_EQ("1000000000foo005", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__5", iter->value().ToString());
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo004", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__4", iter->value().ToString());
|
|
|
|
|
|
|
|
iter->Seek("3000000000000bar");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("3000000000000bar", iter->key().ToString());
|
|
|
|
ASSERT_EQ("bar_v", iter->value().ToString());
|
|
|
|
|
|
|
|
iter->Seek("1000000000foo005");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo005", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__5", iter->value().ToString());
|
|
|
|
|
|
|
|
iter->Seek("1000000000foo006");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
ASSERT_EQ("1000000000foo005", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__5", iter->value().ToString());
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
iter->Seek("1000000000foo008");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("1000000000foo008", iter->key().ToString());
|
|
|
|
ASSERT_EQ("v__8", iter->value().ToString());
|
|
|
|
|
2014-02-08 01:25:38 +01:00
|
|
|
iter->Seek("1000000000foo000");
|
2013-10-29 04:34:02 +01:00
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("3000000000000bar", iter->key().ToString());
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, HashBucketConflict) {
|
2014-05-04 22:55:53 +02:00
|
|
|
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
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = 0;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 2 ^ i;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
DestroyAndReopen(&options);
|
|
|
|
ASSERT_OK(Put("5000000000000fo0", "v1"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo1", "v2"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo2", "v"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo0", "v3"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo1", "v4"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo2", "v"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo3", "v"));
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
dbfull()->TEST_FlushMemTable();
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ASSERT_EQ("v1", Get("5000000000000fo0"));
|
|
|
|
ASSERT_EQ("v2", Get("5000000000000fo1"));
|
|
|
|
ASSERT_EQ("v3", Get("2000000000000fo0"));
|
|
|
|
ASSERT_EQ("v4", Get("2000000000000fo1"));
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ASSERT_EQ("NOT_FOUND", Get("5000000000000bar"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2000000000000bar"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("5000000000000fo8"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2000000000000fo8"));
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ReadOptions ro;
|
|
|
|
Iterator* iter = dbfull()->NewIterator(ro);
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("5000000000000fo0");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo0", iter->key().ToString());
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo1", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("5000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo1", iter->key().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("2000000000000fo0");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo0", iter->key().ToString());
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo1", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("2000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo1", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("2000000000000bar");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo0", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("5000000000000bar");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo0", iter->key().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("2000000000000fo8");
|
|
|
|
ASSERT_TRUE(!iter->Valid() ||
|
|
|
|
options.comparator->Compare(iter->key(), "20000001") > 0);
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("5000000000000fo8");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("3000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("8000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-29 04:34:02 +01:00
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, HashBucketConflictReverseSuffixComparator) {
|
2014-05-04 22:55:53 +02:00
|
|
|
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;
|
2014-10-29 21:49:45 +01:00
|
|
|
test::SimpleSuffixReverseComparator comp;
|
2014-05-04 22:55:53 +02:00
|
|
|
options.comparator = ∁
|
|
|
|
// Set only one bucket to force bucket conflict.
|
|
|
|
// Test index interval for the same prefix to be 1, 2 and 4
|
2014-07-18 09:08:38 +02:00
|
|
|
|
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = 0;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 2 ^ i;
|
|
|
|
plain_table_options.huge_page_tlb_size = huge_page_tlb_size;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
2014-05-04 22:55:53 +02:00
|
|
|
DestroyAndReopen(&options);
|
|
|
|
ASSERT_OK(Put("5000000000000fo0", "v1"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo1", "v2"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo2", "v"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo0", "v3"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo1", "v4"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo2", "v"));
|
|
|
|
ASSERT_OK(Put("2000000000000fo3", "v"));
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
dbfull()->TEST_FlushMemTable();
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ASSERT_EQ("v1", Get("5000000000000fo0"));
|
|
|
|
ASSERT_EQ("v2", Get("5000000000000fo1"));
|
|
|
|
ASSERT_EQ("v3", Get("2000000000000fo0"));
|
|
|
|
ASSERT_EQ("v4", Get("2000000000000fo1"));
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ASSERT_EQ("NOT_FOUND", Get("5000000000000bar"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2000000000000bar"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("5000000000000fo8"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("2000000000000fo8"));
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
ReadOptions ro;
|
|
|
|
Iterator* iter = dbfull()->NewIterator(ro);
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("5000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo1", iter->key().ToString());
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo0", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("5000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo1", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("2000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo1", iter->key().ToString());
|
|
|
|
iter->Next();
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo0", iter->key().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("2000000000000fo1");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo1", iter->key().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("2000000000000var");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("2000000000000fo3", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("5000000000000var");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo2", iter->key().ToString());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
std::string seek_key = "2000000000000bar";
|
|
|
|
iter->Seek(seek_key);
|
|
|
|
ASSERT_TRUE(!iter->Valid() ||
|
|
|
|
options.prefix_extractor->Transform(iter->key()) !=
|
|
|
|
options.prefix_extractor->Transform(seek_key));
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("1000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
2014-04-26 00:45:37 +02:00
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
iter->Seek("3000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
iter->Seek("8000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
delete iter;
|
|
|
|
}
|
2014-02-08 01:25:38 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-29 04:34:02 +01:00
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, NonExistingKeyToNonEmptyBucket) {
|
2014-02-08 01:25:38 +01:00
|
|
|
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
|
2014-07-18 09:08:38 +02:00
|
|
|
PlainTableOptions plain_table_options;
|
|
|
|
plain_table_options.user_key_len = 16;
|
|
|
|
plain_table_options.bloom_bits_per_key = 0;
|
|
|
|
plain_table_options.hash_table_ratio = 0;
|
|
|
|
plain_table_options.index_sparseness = 5;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory(plain_table_options));
|
2014-02-08 01:25:38 +01:00
|
|
|
DestroyAndReopen(&options);
|
|
|
|
ASSERT_OK(Put("5000000000000fo0", "v1"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo1", "v2"));
|
|
|
|
ASSERT_OK(Put("5000000000000fo2", "v3"));
|
2013-10-29 04:34:02 +01:00
|
|
|
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
2014-02-08 01:25:38 +01:00
|
|
|
ASSERT_EQ("v1", Get("5000000000000fo0"));
|
|
|
|
ASSERT_EQ("v2", Get("5000000000000fo1"));
|
|
|
|
ASSERT_EQ("v3", Get("5000000000000fo2"));
|
|
|
|
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("8000000000000bar"));
|
|
|
|
ASSERT_EQ("NOT_FOUND", Get("1000000000000bar"));
|
|
|
|
|
2014-04-25 21:21:34 +02:00
|
|
|
Iterator* iter = dbfull()->NewIterator(ReadOptions());
|
2014-02-08 01:25:38 +01:00
|
|
|
|
|
|
|
iter->Seek("5000000000000bar");
|
|
|
|
ASSERT_TRUE(iter->Valid());
|
|
|
|
ASSERT_EQ("5000000000000fo0", iter->key().ToString());
|
|
|
|
|
|
|
|
iter->Seek("5000000000000fo8");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
iter->Seek("1000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
iter->Seek("8000000000000fo2");
|
|
|
|
ASSERT_TRUE(!iter->Valid());
|
|
|
|
|
|
|
|
delete iter;
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string Key(int i) {
|
|
|
|
char buf[100];
|
|
|
|
snprintf(buf, sizeof(buf), "key_______%06d", i);
|
|
|
|
return std::string(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string RandomString(Random* rnd, int len) {
|
|
|
|
std::string r;
|
|
|
|
test::RandomString(rnd, len, &r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, CompactionTrigger) {
|
2013-10-29 04:34:02 +01:00
|
|
|
Options options = CurrentOptions();
|
2015-08-26 23:19:31 +02:00
|
|
|
options.write_buffer_size = 120 << 10; // 100KB
|
2013-10-29 04:34:02 +01:00
|
|
|
options.num_levels = 3;
|
|
|
|
options.level0_file_num_compaction_trigger = 3;
|
|
|
|
Reopen(&options);
|
|
|
|
|
|
|
|
Random rnd(301);
|
|
|
|
|
|
|
|
for (int num = 0; num < options.level0_file_num_compaction_trigger - 1;
|
|
|
|
num++) {
|
|
|
|
std::vector<std::string> values;
|
2015-08-26 23:19:31 +02:00
|
|
|
// Write 120KB (10 values, each 12K)
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
values.push_back(RandomString(&rnd, 12000));
|
2013-10-29 04:34:02 +01:00
|
|
|
ASSERT_OK(Put(Key(i), values[i]));
|
|
|
|
}
|
2015-08-26 23:19:31 +02:00
|
|
|
ASSERT_OK(Put(Key(999), ""));
|
2013-10-29 04:34:02 +01:00
|
|
|
dbfull()->TEST_WaitForFlushMemTable();
|
|
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), num + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//generate one more file in level-0, and should trigger level-0 compaction
|
|
|
|
std::vector<std::string> values;
|
|
|
|
for (int i = 0; i < 12; i++) {
|
|
|
|
values.push_back(RandomString(&rnd, 10000));
|
|
|
|
ASSERT_OK(Put(Key(i), values[i]));
|
|
|
|
}
|
2015-08-26 23:19:31 +02:00
|
|
|
ASSERT_OK(Put(Key(999), ""));
|
2013-10-29 04:34:02 +01:00
|
|
|
dbfull()->TEST_WaitForCompact();
|
|
|
|
|
|
|
|
ASSERT_EQ(NumTableFilesAtLevel(0), 0);
|
|
|
|
ASSERT_EQ(NumTableFilesAtLevel(1), 1);
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
TEST_P(PlainTableDBTest, AdaptiveTable) {
|
2014-06-17 05:06:18 +02:00
|
|
|
Options options = CurrentOptions();
|
|
|
|
options.create_if_missing = true;
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory());
|
|
|
|
DestroyAndReopen(&options);
|
|
|
|
|
|
|
|
ASSERT_OK(Put("1000000000000foo", "v1"));
|
|
|
|
ASSERT_OK(Put("0000000000000bar", "v2"));
|
|
|
|
ASSERT_OK(Put("1000000000000foo", "v3"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
|
|
|
|
options.create_if_missing = false;
|
|
|
|
std::shared_ptr<TableFactory> dummy_factory;
|
2014-06-18 07:04:37 +02:00
|
|
|
std::shared_ptr<TableFactory> block_based_factory(
|
|
|
|
NewBlockBasedTableFactory());
|
|
|
|
options.table_factory.reset(NewAdaptiveTableFactory(
|
|
|
|
block_based_factory, dummy_factory, dummy_factory));
|
2014-06-17 05:06:18 +02:00
|
|
|
Reopen(&options);
|
|
|
|
ASSERT_EQ("v3", Get("1000000000000foo"));
|
|
|
|
ASSERT_EQ("v2", Get("0000000000000bar"));
|
|
|
|
|
|
|
|
ASSERT_OK(Put("2000000000000foo", "v4"));
|
|
|
|
ASSERT_OK(Put("3000000000000bar", "v5"));
|
|
|
|
dbfull()->TEST_FlushMemTable();
|
|
|
|
ASSERT_EQ("v4", Get("2000000000000foo"));
|
|
|
|
ASSERT_EQ("v5", Get("3000000000000bar"));
|
|
|
|
|
|
|
|
Reopen(&options);
|
|
|
|
ASSERT_EQ("v3", Get("1000000000000foo"));
|
|
|
|
ASSERT_EQ("v2", Get("0000000000000bar"));
|
|
|
|
ASSERT_EQ("v4", Get("2000000000000foo"));
|
|
|
|
ASSERT_EQ("v5", Get("3000000000000bar"));
|
|
|
|
|
|
|
|
options.table_factory.reset(NewBlockBasedTableFactory());
|
|
|
|
Reopen(&options);
|
|
|
|
ASSERT_NE("v3", Get("1000000000000foo"));
|
|
|
|
|
|
|
|
options.table_factory.reset(NewPlainTableFactory());
|
|
|
|
Reopen(&options);
|
|
|
|
ASSERT_NE("v5", Get("3000000000000bar"));
|
|
|
|
}
|
|
|
|
|
2015-09-17 01:57:43 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P(PlainTableDBTest, PlainTableDBTest, ::testing::Bool());
|
|
|
|
|
2013-10-29 04:34:02 +01:00
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
2015-03-17 22:08:00 +01:00
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
2013-10-29 04:34:02 +01:00
|
|
|
}
|
2015-07-20 20:12:02 +02:00
|
|
|
|
|
|
|
#else
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
fprintf(stderr, "SKIPPED as plain table is not supported in ROCKSDB_LITE\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !ROCKSDB_LITE
|