Fix the valgrind issues

main
Kai Liu 11 years ago
parent 774ed89c24
commit 5e7d5629c7
  1. 20
      db/db_test.cc
  2. 16
      db/plain_table_db_test.cc
  3. 6
      table/table_test.cc

@ -240,6 +240,8 @@ class SpecialEnv : public EnvWrapper {
class DBTest {
private:
const FilterPolicy* filter_policy_;
static std::unique_ptr<const SliceTransform> prefix_1_transform;
static std::unique_ptr<const SliceTransform> noop_transform;
protected:
// Sequence of option configurations to try
@ -356,13 +358,13 @@ class DBTest {
break;
case kPlainTableFirstBytePrefix:
options.table_factory.reset(new PlainTableFactory());
options.prefix_extractor = NewFixedPrefixTransform(1);
options.prefix_extractor = prefix_1_transform.get();
options.allow_mmap_reads = true;
options.max_sequential_skip_in_iterations = 999999;
break;
case kPlainTableAllBytesPrefix:
options.table_factory.reset(new PlainTableFactory());
options.prefix_extractor = NewNoopTransform();
options.prefix_extractor = noop_transform.get();
options.allow_mmap_reads = true;
options.max_sequential_skip_in_iterations = 999999;
break;
@ -694,6 +696,10 @@ class DBTest {
delete iter;
}
};
std::unique_ptr<const SliceTransform> DBTest::prefix_1_transform(
NewFixedPrefixTransform(1));
std::unique_ptr<const SliceTransform> DBTest::noop_transform(
NewNoopTransform());
static std::string Key(int i) {
char buf[100];
@ -4694,20 +4700,22 @@ TEST(DBTest, PrefixScan) {
snprintf(buf, sizeof(buf), "03______:");
prefix = Slice(buf, 8);
key = Slice(buf, 9);
auto prefix_extractor = NewFixedPrefixTransform(8);
// db configs
env_->count_random_reads_ = true;
Options options = CurrentOptions();
options.env = env_;
options.no_block_cache = true;
options.filter_policy = NewBloomFilterPolicy(10);
options.prefix_extractor = prefix_extractor;
options.filter_policy = NewBloomFilterPolicy(10);
options.prefix_extractor = NewFixedPrefixTransform(8);
options.whole_key_filtering = false;
options.disable_auto_compactions = true;
options.max_background_compactions = 2;
options.create_if_missing = true;
options.disable_seek_compaction = true;
options.memtable_factory.reset(NewHashSkipListRepFactory(prefix_extractor));
// Tricky: options.prefix_extractor will be released by
// NewHashSkipListRepFactory after use.
options.memtable_factory.reset(
NewHashSkipListRepFactory(options.prefix_extractor));
// prefix specified, with blooms: 2 RAND I/Os
// SeekToFirst

@ -35,16 +35,17 @@ using std::unique_ptr;
namespace rocksdb {
class PlainTableDBTest {
protected:
public:
protected:
private:
std::string dbname_;
Env* env_;
DB* db_;
Options last_options_;
static std::unique_ptr<const SliceTransform> prefix_transform;
PlainTableDBTest() :
env_(Env::Default()) {
public:
PlainTableDBTest() : env_(Env::Default()) {
dbname_ = test::TmpDir() + "/plain_table_db_test";
ASSERT_OK(DestroyDB(dbname_, Options()));
db_ = nullptr;
@ -60,7 +61,7 @@ public:
Options CurrentOptions() {
Options options;
options.table_factory.reset(new PlainTableFactory(16, 2, 0.8));
options.prefix_extractor = NewFixedPrefixTransform(8);
options.prefix_extractor = prefix_transform.get();
options.allow_mmap_reads = true;
return options;
}
@ -167,8 +168,11 @@ public:
}
};
std::unique_ptr<const SliceTransform> PlainTableDBTest::prefix_transform(
NewFixedPrefixTransform(8));
TEST(PlainTableDBTest, Empty) {
ASSERT_TRUE(db_ != nullptr);
ASSERT_TRUE(dbfull() != nullptr);
ASSERT_EQ("NOT_FOUND", Get("0000000000000foo"));
}

@ -647,7 +647,7 @@ class Harness {
case PLAIN_TABLE_FULL_STR_PREFIX:
support_prev_ = false;
only_support_prefix_seek_ = true;
options_.prefix_extractor = NewNoopTransform();
options_.prefix_extractor = noop_transform.get();
options_.allow_mmap_reads = true;
options_.table_factory.reset(new PlainTableFactory());
constructor_ = new TableConstructor(options_.comparator, true);
@ -849,8 +849,12 @@ class Harness {
bool support_prev_;
bool only_support_prefix_seek_;
shared_ptr<Comparator> internal_comparator_;
static std::unique_ptr<const SliceTransform> noop_transform;
};
std::unique_ptr<const SliceTransform> Harness::noop_transform(
NewNoopTransform());
static bool Between(uint64_t val, uint64_t low, uint64_t high) {
bool result = (val >= low) && (val <= high);
if (!result) {

Loading…
Cancel
Save