A number of fixes:
- Replace raw slice comparison with a call to user comparator. Added test for custom comparators. - Fix end of namespace comments. - Fixed bug in picking inputs for a level-0 compaction. When finding overlapping files, the covered range may expand as files are added to the input set. We now correctly expand the range when this happens instead of continuing to use the old range. For example, suppose L0 contains files with the following ranges: F1: a .. d F2: c .. g F3: f .. j and the initial compaction target is F3. We used to search for range f..j which yielded {F2,F3}. However we now expand the range as soon as another file is added. In this case, when F2 is added, we expand the range to c..j and restart the search. That picks up file F1 as well. This change fixes a bug related to deleted keys showing up incorrectly after a compaction as described in Issue 44. (Sync with upstream @25072954)
This commit is contained in:
parent
299ccedfec
commit
36a5f8ed7f
@ -85,4 +85,4 @@ Status BuildTable(const std::string& dbname,
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -29,6 +29,6 @@ extern Status BuildTable(const std::string& dbname,
|
|||||||
Iterator* iter,
|
Iterator* iter,
|
||||||
FileMetaData* meta);
|
FileMetaData* meta);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_BUILDER_H_
|
#endif // STORAGE_LEVELDB_DB_BUILDER_H_
|
||||||
|
@ -352,7 +352,7 @@ TEST(CorruptionTest, UnrelatedKeys) {
|
|||||||
ASSERT_EQ(Value(1000, &tmp2).ToString(), v);
|
ASSERT_EQ(Value(1000, &tmp2).ToString(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -288,7 +288,7 @@ struct ThreadState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
class Benchmark {
|
class Benchmark {
|
||||||
private:
|
private:
|
||||||
@ -829,7 +829,7 @@ class Benchmark {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
FLAGS_write_buffer_size = leveldb::Options().write_buffer_size;
|
FLAGS_write_buffer_size = leveldb::Options().write_buffer_size;
|
||||||
|
@ -985,7 +985,7 @@ static void CleanupIteratorState(void* arg1, void* arg2) {
|
|||||||
state->mu->Unlock();
|
state->mu->Unlock();
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Iterator* DBImpl::NewInternalIterator(const ReadOptions& options,
|
Iterator* DBImpl::NewInternalIterator(const ReadOptions& options,
|
||||||
SequenceNumber* latest_snapshot) {
|
SequenceNumber* latest_snapshot) {
|
||||||
@ -1378,4 +1378,4 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -187,6 +187,6 @@ extern Options SanitizeOptions(const std::string& db,
|
|||||||
const InternalKeyComparator* icmp,
|
const InternalKeyComparator* icmp,
|
||||||
const Options& src);
|
const Options& src);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_DB_IMPL_H_
|
#endif // STORAGE_LEVELDB_DB_DB_IMPL_H_
|
||||||
|
@ -296,4 +296,4 @@ Iterator* NewDBIterator(
|
|||||||
return new DBIter(dbname, env, user_key_comparator, internal_iter, sequence);
|
return new DBIter(dbname, env, user_key_comparator, internal_iter, sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -21,6 +21,6 @@ extern Iterator* NewDBIterator(
|
|||||||
Iterator* internal_iter,
|
Iterator* internal_iter,
|
||||||
const SequenceNumber& sequence);
|
const SequenceNumber& sequence);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_DB_ITER_H_
|
#endif // STORAGE_LEVELDB_DB_DB_ITER_H_
|
||||||
|
102
db/db_test.cc
102
db/db_test.cc
@ -136,6 +136,33 @@ class DBTest {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a string that contains all key,value pairs in order,
|
||||||
|
// formatted like "(k1->v1)(k2->v2)".
|
||||||
|
std::string Contents() {
|
||||||
|
std::vector<std::string> forward;
|
||||||
|
std::string result;
|
||||||
|
Iterator* iter = db_->NewIterator(ReadOptions());
|
||||||
|
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
|
||||||
|
std::string s = IterStatus(iter);
|
||||||
|
result.push_back('(');
|
||||||
|
result.append(s);
|
||||||
|
result.push_back(')');
|
||||||
|
forward.push_back(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check reverse iteration results are the reverse of forward results
|
||||||
|
int matched = 0;
|
||||||
|
for (iter->SeekToLast(); iter->Valid(); iter->Prev()) {
|
||||||
|
ASSERT_LT(matched, forward.size());
|
||||||
|
ASSERT_EQ(IterStatus(iter), forward[forward.size() - matched - 1]);
|
||||||
|
matched++;
|
||||||
|
}
|
||||||
|
ASSERT_EQ(matched, forward.size());
|
||||||
|
|
||||||
|
delete iter;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::string AllEntriesFor(const Slice& user_key) {
|
std::string AllEntriesFor(const Slice& user_key) {
|
||||||
Iterator* iter = dbfull()->TEST_NewInternalIterator();
|
Iterator* iter = dbfull()->TEST_NewInternalIterator();
|
||||||
InternalKey target(user_key, kMaxSequenceNumber, kTypeValue);
|
InternalKey target(user_key, kMaxSequenceNumber, kTypeValue);
|
||||||
@ -1048,6 +1075,49 @@ TEST(DBTest, OverlapInLevel0) {
|
|||||||
ASSERT_EQ("NOT_FOUND", Get("600"));
|
ASSERT_EQ("NOT_FOUND", Get("600"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DBTest, L0_CompactionBug_Issue44_a) {
|
||||||
|
Reopen();
|
||||||
|
ASSERT_OK(Put("b", "v"));
|
||||||
|
Reopen();
|
||||||
|
ASSERT_OK(Delete("b"));
|
||||||
|
ASSERT_OK(Delete("a"));
|
||||||
|
Reopen();
|
||||||
|
ASSERT_OK(Delete("a"));
|
||||||
|
Reopen();
|
||||||
|
ASSERT_OK(Put("a", "v"));
|
||||||
|
Reopen();
|
||||||
|
Reopen();
|
||||||
|
ASSERT_EQ("(a->v)", Contents());
|
||||||
|
env_->SleepForMicroseconds(1000000); // Wait for compaction to finish
|
||||||
|
ASSERT_EQ("(a->v)", Contents());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DBTest, L0_CompactionBug_Issue44_b) {
|
||||||
|
Reopen();
|
||||||
|
Put("","");
|
||||||
|
Reopen();
|
||||||
|
Delete("e");
|
||||||
|
Put("","");
|
||||||
|
Reopen();
|
||||||
|
Put("c", "cv");
|
||||||
|
Reopen();
|
||||||
|
Put("","");
|
||||||
|
Reopen();
|
||||||
|
Put("","");
|
||||||
|
env_->SleepForMicroseconds(1000000); // Wait for compaction to finish
|
||||||
|
Reopen();
|
||||||
|
Put("d","dv");
|
||||||
|
Reopen();
|
||||||
|
Put("","");
|
||||||
|
Reopen();
|
||||||
|
Delete("d");
|
||||||
|
Delete("b");
|
||||||
|
Reopen();
|
||||||
|
ASSERT_EQ("(->)(c->cv)", Contents());
|
||||||
|
env_->SleepForMicroseconds(1000000); // Wait for compaction to finish
|
||||||
|
ASSERT_EQ("(->)(c->cv)", Contents());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(DBTest, ComparatorCheck) {
|
TEST(DBTest, ComparatorCheck) {
|
||||||
class NewComparator : public Comparator {
|
class NewComparator : public Comparator {
|
||||||
public:
|
public:
|
||||||
@ -1071,6 +1141,34 @@ TEST(DBTest, ComparatorCheck) {
|
|||||||
<< s.ToString();
|
<< s.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DBTest, CustomComparator) {
|
||||||
|
class NumberComparator : public Comparator {
|
||||||
|
public:
|
||||||
|
virtual const char* Name() const { return "test.NumberComparator"; }
|
||||||
|
virtual int Compare(const Slice& a, const Slice& b) const {
|
||||||
|
return (strtol(a.ToString().c_str(), NULL, 0) -
|
||||||
|
strtol(b.ToString().c_str(), NULL, 0));
|
||||||
|
}
|
||||||
|
virtual void FindShortestSeparator(std::string* s, const Slice& l) const {}
|
||||||
|
virtual void FindShortSuccessor(std::string* key) const {}
|
||||||
|
};
|
||||||
|
NumberComparator cmp;
|
||||||
|
Options new_options;
|
||||||
|
new_options.create_if_missing = true;
|
||||||
|
new_options.comparator = &cmp;
|
||||||
|
DestroyAndReopen(&new_options);
|
||||||
|
ASSERT_OK(Put("10", "ten"));
|
||||||
|
ASSERT_OK(Put("0x14", "twenty"));
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
ASSERT_EQ("ten", Get("10"));
|
||||||
|
ASSERT_EQ("ten", Get("0xa"));
|
||||||
|
ASSERT_EQ("twenty", Get("20"));
|
||||||
|
ASSERT_EQ("twenty", Get("0x14"));
|
||||||
|
Compact("0", "9999");
|
||||||
|
fprintf(stderr, "ss\n%s\n", DumpSSTableList().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST(DBTest, ManualCompaction) {
|
TEST(DBTest, ManualCompaction) {
|
||||||
ASSERT_EQ(config::kMaxMemCompactLevel, 2)
|
ASSERT_EQ(config::kMaxMemCompactLevel, 2)
|
||||||
<< "Need to update this test to match kMaxMemCompactLevel";
|
<< "Need to update this test to match kMaxMemCompactLevel";
|
||||||
@ -1207,7 +1305,7 @@ static void MTThreadBody(void* arg) {
|
|||||||
fprintf(stderr, "... stopping thread %d after %d ops\n", t->id, int(counter));
|
fprintf(stderr, "... stopping thread %d after %d ops\n", t->id, int(counter));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
TEST(DBTest, MultiThreaded) {
|
TEST(DBTest, MultiThreaded) {
|
||||||
// Initialize state
|
// Initialize state
|
||||||
@ -1525,7 +1623,7 @@ void BM_LogAndApply(int iters, int num_base_files) {
|
|||||||
buf, iters, us, ((float)us) / iters);
|
buf, iters, us, ((float)us) / iters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
if (argc > 1 && std::string(argv[1]) == "--benchmark") {
|
if (argc > 1 && std::string(argv[1]) == "--benchmark") {
|
||||||
|
@ -115,4 +115,4 @@ LookupKey::LookupKey(const Slice& user_key, SequenceNumber s) {
|
|||||||
end_ = dst;
|
end_ = dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -37,7 +37,7 @@ static const int kL0_StopWritesTrigger = 12;
|
|||||||
// space if the same key space is being repeatedly overwritten.
|
// space if the same key space is being repeatedly overwritten.
|
||||||
static const int kMaxMemCompactLevel = 2;
|
static const int kMaxMemCompactLevel = 2;
|
||||||
|
|
||||||
}
|
} // namespace config
|
||||||
|
|
||||||
class InternalKey;
|
class InternalKey;
|
||||||
|
|
||||||
@ -210,6 +210,6 @@ inline LookupKey::~LookupKey() {
|
|||||||
if (start_ != space_) delete[] start_;
|
if (start_ != space_) delete[] start_;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_FORMAT_H_
|
#endif // STORAGE_LEVELDB_DB_FORMAT_H_
|
||||||
|
@ -105,7 +105,7 @@ TEST(FormatTest, InternalKeyShortestSuccessor) {
|
|||||||
ShortSuccessor(IKey("\xff\xff", 100, kTypeValue)));
|
ShortSuccessor(IKey("\xff\xff", 100, kTypeValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -132,4 +132,4 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -75,6 +75,6 @@ extern Status SetCurrentFile(Env* env, const std::string& dbname,
|
|||||||
uint64_t descriptor_number);
|
uint64_t descriptor_number);
|
||||||
|
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_FILENAME_H_
|
#endif // STORAGE_LEVELDB_DB_FILENAME_H_
|
||||||
|
@ -115,7 +115,7 @@ TEST(FileNameTest, Construction) {
|
|||||||
ASSERT_EQ(kTempFile, type);
|
ASSERT_EQ(kTempFile, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -29,7 +29,7 @@ static const int kBlockSize = 32768;
|
|||||||
// Header is checksum (4 bytes), type (1 byte), length (2 bytes).
|
// Header is checksum (4 bytes), type (1 byte), length (2 bytes).
|
||||||
static const int kHeaderSize = 4 + 1 + 2;
|
static const int kHeaderSize = 4 + 1 + 2;
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_
|
#endif // STORAGE_LEVELDB_DB_LOG_FORMAT_H_
|
||||||
|
@ -255,5 +255,5 @@ unsigned int Reader::ReadPhysicalRecord(Slice* result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -102,7 +102,7 @@ class Reader {
|
|||||||
void operator=(const Reader&);
|
void operator=(const Reader&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_LOG_READER_H_
|
#endif // STORAGE_LEVELDB_DB_LOG_READER_H_
|
||||||
|
@ -492,8 +492,8 @@ TEST(LogTest, ReadPastEnd) {
|
|||||||
CheckOffsetPastEndReturnsNoRecords(5);
|
CheckOffsetPastEndReturnsNoRecords(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -99,5 +99,5 @@ Status Writer::EmitPhysicalRecord(RecordType t, const char* ptr, size_t n) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -42,7 +42,7 @@ class Writer {
|
|||||||
void operator=(const Writer&);
|
void operator=(const Writer&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace log
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_
|
#endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_
|
||||||
|
@ -142,4 +142,4 @@ bool MemTable::Get(const LookupKey& key, std::string* value, Status* s) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -86,6 +86,6 @@ class MemTable {
|
|||||||
void operator=(const MemTable&);
|
void operator=(const MemTable&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_MEMTABLE_H_
|
#endif // STORAGE_LEVELDB_DB_MEMTABLE_H_
|
||||||
|
@ -377,11 +377,11 @@ class Repairer {
|
|||||||
fname.c_str(), s.ToString().c_str());
|
fname.c_str(), s.ToString().c_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Status RepairDB(const std::string& dbname, const Options& options) {
|
Status RepairDB(const std::string& dbname, const Options& options) {
|
||||||
Repairer repairer(dbname, options);
|
Repairer repairer(dbname, options);
|
||||||
return repairer.Run();
|
return repairer.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -375,4 +375,4 @@ bool SkipList<Key,Comparator>::Contains(const Key& key) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -371,7 +371,7 @@ TEST(SkipTest, Concurrent3) { RunConcurrent(3); }
|
|||||||
TEST(SkipTest, Concurrent4) { RunConcurrent(4); }
|
TEST(SkipTest, Concurrent4) { RunConcurrent(4); }
|
||||||
TEST(SkipTest, Concurrent5) { RunConcurrent(5); }
|
TEST(SkipTest, Concurrent5) { RunConcurrent(5); }
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -61,6 +61,6 @@ class SnapshotList {
|
|||||||
SnapshotImpl list_;
|
SnapshotImpl list_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_
|
#endif // STORAGE_LEVELDB_DB_SNAPSHOT_H_
|
||||||
|
@ -92,4 +92,4 @@ void TableCache::Evict(uint64_t file_number) {
|
|||||||
cache_->Erase(Slice(buf, sizeof(buf)));
|
cache_->Erase(Slice(buf, sizeof(buf)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -45,6 +45,6 @@ class TableCache {
|
|||||||
Cache* cache_;
|
Cache* cache_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_
|
#endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_
|
||||||
|
@ -263,4 +263,4 @@ std::string VersionEdit::DebugString() const {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -102,6 +102,6 @@ class VersionEdit {
|
|||||||
std::vector< std::pair<int, FileMetaData> > new_files_;
|
std::vector< std::pair<int, FileMetaData> > new_files_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_
|
#endif // STORAGE_LEVELDB_DB_VERSION_EDIT_H_
|
||||||
|
@ -39,7 +39,7 @@ TEST(VersionEditTest, EncodeDecode) {
|
|||||||
TestEncodeDecode(edit);
|
TestEncodeDecode(edit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -61,7 +61,7 @@ std::string IntSetToString(const std::set<uint64_t>& s) {
|
|||||||
result += "}";
|
result += "}";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Version::~Version() {
|
Version::~Version() {
|
||||||
assert(refs_ == 0);
|
assert(refs_ == 0);
|
||||||
@ -253,7 +253,8 @@ void Version::AddIterators(const ReadOptions& options,
|
|||||||
// If "*iter" points at a value or deletion for user_key, store
|
// If "*iter" points at a value or deletion for user_key, store
|
||||||
// either the value, or a NotFound error and return true.
|
// either the value, or a NotFound error and return true.
|
||||||
// Else return false.
|
// Else return false.
|
||||||
static bool GetValue(Iterator* iter, const Slice& user_key,
|
static bool GetValue(const Comparator* cmp,
|
||||||
|
Iterator* iter, const Slice& user_key,
|
||||||
std::string* value,
|
std::string* value,
|
||||||
Status* s) {
|
Status* s) {
|
||||||
if (!iter->Valid()) {
|
if (!iter->Valid()) {
|
||||||
@ -264,7 +265,7 @@ static bool GetValue(Iterator* iter, const Slice& user_key,
|
|||||||
*s = Status::Corruption("corrupted key for ", user_key);
|
*s = Status::Corruption("corrupted key for ", user_key);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (parsed_key.user_key != user_key) {
|
if (cmp->Compare(parsed_key.user_key, user_key) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (parsed_key.type) {
|
switch (parsed_key.type) {
|
||||||
@ -360,7 +361,7 @@ Status Version::Get(const ReadOptions& options,
|
|||||||
f->number,
|
f->number,
|
||||||
f->file_size);
|
f->file_size);
|
||||||
iter->Seek(ikey);
|
iter->Seek(ikey);
|
||||||
const bool done = GetValue(iter, user_key, value, &s);
|
const bool done = GetValue(ucmp, iter, user_key, value, &s);
|
||||||
if (!iter->status().ok()) {
|
if (!iter->status().ok()) {
|
||||||
s = iter->status();
|
s = iter->status();
|
||||||
delete iter;
|
delete iter;
|
||||||
@ -450,16 +451,29 @@ void Version::GetOverlappingInputs(
|
|||||||
user_end = end->user_key();
|
user_end = end->user_key();
|
||||||
}
|
}
|
||||||
const Comparator* user_cmp = vset_->icmp_.user_comparator();
|
const Comparator* user_cmp = vset_->icmp_.user_comparator();
|
||||||
for (size_t i = 0; i < files_[level].size(); i++) {
|
for (size_t i = 0; i < files_[level].size(); ) {
|
||||||
FileMetaData* f = files_[level][i];
|
FileMetaData* f = files_[level][i++];
|
||||||
if (begin != NULL &&
|
const Slice file_start = f->smallest.user_key();
|
||||||
user_cmp->Compare(f->largest.user_key(), user_begin) < 0) {
|
const Slice file_limit = f->largest.user_key();
|
||||||
|
if (begin != NULL && user_cmp->Compare(file_limit, user_begin) < 0) {
|
||||||
// "f" is completely before specified range; skip it
|
// "f" is completely before specified range; skip it
|
||||||
} else if (end != NULL &&
|
} else if (end != NULL && user_cmp->Compare(file_start, user_end) > 0) {
|
||||||
user_cmp->Compare(f->smallest.user_key(), user_end) > 0) {
|
|
||||||
// "f" is completely after specified range; skip it
|
// "f" is completely after specified range; skip it
|
||||||
} else {
|
} else {
|
||||||
inputs->push_back(f);
|
inputs->push_back(f);
|
||||||
|
if (level == 0) {
|
||||||
|
// Level-0 files may overlap each other. So check if the newly
|
||||||
|
// added file has expanded the range. If so, restart search.
|
||||||
|
if (begin != NULL && user_cmp->Compare(file_start, user_begin) < 0) {
|
||||||
|
user_begin = file_start;
|
||||||
|
inputs->clear();
|
||||||
|
i = 0;
|
||||||
|
} else if (end != NULL && user_cmp->Compare(file_limit, user_end) > 0) {
|
||||||
|
user_end = file_limit;
|
||||||
|
inputs->clear();
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1369,4 +1383,4 @@ void Compaction::ReleaseInputs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -365,6 +365,6 @@ class Compaction {
|
|||||||
size_t level_ptrs_[config::kNumLevels];
|
size_t level_ptrs_[config::kNumLevels];
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_VERSION_SET_H_
|
#endif // STORAGE_LEVELDB_DB_VERSION_SET_H_
|
||||||
|
@ -172,7 +172,7 @@ TEST(FindFileTest, OverlappingFiles) {
|
|||||||
ASSERT_TRUE(Overlaps("600", "700"));
|
ASSERT_TRUE(Overlaps("600", "700"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -120,7 +120,7 @@ class MemTableInserter : public WriteBatch::Handler {
|
|||||||
sequence_++;
|
sequence_++;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Status WriteBatchInternal::InsertInto(const WriteBatch* b,
|
Status WriteBatchInternal::InsertInto(const WriteBatch* b,
|
||||||
MemTable* memtable) {
|
MemTable* memtable) {
|
||||||
@ -135,4 +135,4 @@ void WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) {
|
|||||||
b->rep_.assign(contents.data(), contents.size());
|
b->rep_.assign(contents.data(), contents.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -41,7 +41,7 @@ class WriteBatchInternal {
|
|||||||
static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
|
static Status InsertInto(const WriteBatch* batch, MemTable* memtable);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|
#endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_
|
||||||
|
@ -82,7 +82,7 @@ TEST(WriteBatchTest, Corruption) {
|
|||||||
PrintContents(&batch));
|
PrintContents(&batch));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -155,7 +155,7 @@ static Slice TrimSpace(Slice s) {
|
|||||||
return Slice(s.data() + start, limit - start);
|
return Slice(s.data() + start, limit - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
class Benchmark {
|
class Benchmark {
|
||||||
private:
|
private:
|
||||||
@ -652,7 +652,7 @@ class Benchmark {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
@ -124,7 +124,7 @@ static Slice TrimSpace(Slice s) {
|
|||||||
return Slice(s.data() + start, limit - start);
|
return Slice(s.data() + start, limit - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
class Benchmark {
|
class Benchmark {
|
||||||
private:
|
private:
|
||||||
@ -467,7 +467,7 @@ class Benchmark {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
@ -365,10 +365,10 @@ class InMemoryEnv : public EnvWrapper {
|
|||||||
FileSystem file_map_; // Protected by mutex_.
|
FileSystem file_map_; // Protected by mutex_.
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Env* NewMemEnv(Env* base_env) {
|
Env* NewMemEnv(Env* base_env) {
|
||||||
return new InMemoryEnv(base_env);
|
return new InMemoryEnv(base_env);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -15,6 +15,6 @@ class Env;
|
|||||||
// *base_env must remain live while the result is in use.
|
// *base_env must remain live while the result is in use.
|
||||||
Env* NewMemEnv(Env* base_env);
|
Env* NewMemEnv(Env* base_env);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_
|
#endif // STORAGE_LEVELDB_HELPERS_MEMENV_MEMENV_H_
|
||||||
|
@ -225,7 +225,7 @@ TEST(MemEnvTest, DBTest) {
|
|||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -94,6 +94,6 @@ class Cache {
|
|||||||
void operator=(const Cache&);
|
void operator=(const Cache&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_CACHE_H_
|
#endif // STORAGE_LEVELDB_UTIL_CACHE_H_
|
||||||
|
@ -58,6 +58,6 @@ class Comparator {
|
|||||||
// must not be deleted.
|
// must not be deleted.
|
||||||
extern const Comparator* BytewiseComparator();
|
extern const Comparator* BytewiseComparator();
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_COMPARATOR_H_
|
||||||
|
@ -155,6 +155,6 @@ Status DestroyDB(const std::string& name, const Options& options);
|
|||||||
// on a database that contains important information.
|
// on a database that contains important information.
|
||||||
Status RepairDB(const std::string& dbname, const Options& options);
|
Status RepairDB(const std::string& dbname, const Options& options);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_DB_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_DB_H_
|
||||||
|
@ -318,6 +318,6 @@ class EnvWrapper : public Env {
|
|||||||
Env* target_;
|
Env* target_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_ENV_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_ENV_H_
|
||||||
|
@ -95,6 +95,6 @@ extern Iterator* NewEmptyIterator();
|
|||||||
// Return an empty iterator with the specified status.
|
// Return an empty iterator with the specified status.
|
||||||
extern Iterator* NewErrorIterator(const Status& status);
|
extern Iterator* NewErrorIterator(const Status& status);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
|
||||||
|
@ -182,6 +182,6 @@ struct WriteOptions {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
|
||||||
|
@ -103,7 +103,7 @@ inline int Slice::compare(const Slice& b) const {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_SLICE_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_SLICE_H_
|
||||||
|
@ -95,6 +95,6 @@ inline void Status::operator=(const Status& s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_STATUS_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_STATUS_H_
|
||||||
|
@ -65,6 +65,6 @@ class Table {
|
|||||||
void operator=(const Table&);
|
void operator=(const Table&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_TABLE_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_TABLE_H_
|
||||||
|
@ -86,6 +86,6 @@ class TableBuilder {
|
|||||||
void operator=(const TableBuilder&);
|
void operator=(const TableBuilder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
|
||||||
|
@ -59,6 +59,6 @@ class WriteBatch {
|
|||||||
// Intentionally copyable
|
// Intentionally copyable
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_
|
#endif // STORAGE_LEVELDB_INCLUDE_WRITE_BATCH_H_
|
||||||
|
@ -138,7 +138,7 @@ class AtomicPointer {
|
|||||||
#undef ARCH_CPU_X86_FAMILY
|
#undef ARCH_CPU_X86_FAMILY
|
||||||
#undef ARCH_CPU_ARM_FAMILY
|
#undef ARCH_CPU_ARM_FAMILY
|
||||||
|
|
||||||
} // namespace leveldb::port
|
} // namespace port
|
||||||
} // namespace leveldb
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // PORT_ATOMIC_POINTER_H_
|
#endif // PORT_ATOMIC_POINTER_H_
|
||||||
|
@ -60,5 +60,5 @@ void CondVar::SignalAll() {
|
|||||||
PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
|
PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace port
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -150,7 +150,7 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace port
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
|
#endif // STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
|
||||||
|
@ -119,7 +119,7 @@ extern bool Snappy_Uncompress(const char* input_data, size_t input_length,
|
|||||||
// The concatenation of all "data[0,n-1]" fragments is the heap profile.
|
// The concatenation of all "data[0,n-1]" fragments is the heap profile.
|
||||||
extern bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg);
|
extern bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg);
|
||||||
|
|
||||||
}
|
} // namespace port
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_PORT_PORT_EXAMPLE_H_
|
#endif // STORAGE_LEVELDB_PORT_PORT_EXAMPLE_H_
|
||||||
|
@ -46,5 +46,5 @@ void CondVar::SignalAll() {
|
|||||||
PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
|
PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace port
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -260,4 +260,4 @@ Iterator* Block::NewIterator(const Comparator* cmp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -38,6 +38,6 @@ class Block {
|
|||||||
class Iter;
|
class Iter;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_TABLE_BLOCK_H_
|
#endif // STORAGE_LEVELDB_TABLE_BLOCK_H_
|
||||||
|
@ -106,4 +106,4 @@ void BlockBuilder::Add(const Slice& key, const Slice& value) {
|
|||||||
counter_++;
|
counter_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -52,6 +52,6 @@ class BlockBuilder {
|
|||||||
void operator=(const BlockBuilder&);
|
void operator=(const BlockBuilder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_
|
#endif // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_
|
||||||
|
@ -132,4 +132,4 @@ Status ReadBlock(RandomAccessFile* file,
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -98,6 +98,6 @@ inline BlockHandle::BlockHandle()
|
|||||||
size_(~static_cast<uint64_t>(0)) {
|
size_(~static_cast<uint64_t>(0)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_TABLE_FORMAT_H_
|
#endif // STORAGE_LEVELDB_TABLE_FORMAT_H_
|
||||||
|
@ -54,7 +54,7 @@ class EmptyIterator : public Iterator {
|
|||||||
private:
|
private:
|
||||||
Status status_;
|
Status status_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Iterator* NewEmptyIterator() {
|
Iterator* NewEmptyIterator() {
|
||||||
return new EmptyIterator(Status::OK());
|
return new EmptyIterator(Status::OK());
|
||||||
@ -64,4 +64,4 @@ Iterator* NewErrorIterator(const Status& status) {
|
|||||||
return new EmptyIterator(status);
|
return new EmptyIterator(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -181,7 +181,7 @@ void MergingIterator::FindLargest() {
|
|||||||
}
|
}
|
||||||
current_ = largest;
|
current_ = largest;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n) {
|
Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n) {
|
||||||
assert(n >= 0);
|
assert(n >= 0);
|
||||||
@ -194,4 +194,4 @@ Iterator* NewMergingIterator(const Comparator* cmp, Iterator** list, int n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -21,6 +21,6 @@ class Iterator;
|
|||||||
extern Iterator* NewMergingIterator(
|
extern Iterator* NewMergingIterator(
|
||||||
const Comparator* comparator, Iterator** children, int n);
|
const Comparator* comparator, Iterator** children, int n);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_TABLE_MERGER_H_
|
#endif // STORAGE_LEVELDB_TABLE_MERGER_H_
|
||||||
|
@ -172,4 +172,4 @@ uint64_t Table::ApproximateOffsetOf(const Slice& key) const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -224,4 +224,4 @@ uint64_t TableBuilder::FileSize() const {
|
|||||||
return rep_->offset;
|
return rep_->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -60,7 +60,7 @@ class ReverseKeyComparator : public Comparator {
|
|||||||
*key = Reverse(s);
|
*key = Reverse(s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
static ReverseKeyComparator reverse_key_comparator;
|
static ReverseKeyComparator reverse_key_comparator;
|
||||||
|
|
||||||
static void Increment(const Comparator* cmp, std::string* key) {
|
static void Increment(const Comparator* cmp, std::string* key) {
|
||||||
@ -85,7 +85,7 @@ struct STLLessThan {
|
|||||||
return cmp->Compare(Slice(a), Slice(b)) < 0;
|
return cmp->Compare(Slice(a), Slice(b)) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
class StringSink: public WritableFile {
|
class StringSink: public WritableFile {
|
||||||
public:
|
public:
|
||||||
@ -847,7 +847,7 @@ TEST(TableTest, ApproximateOffsetOfCompressed) {
|
|||||||
ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 4000, 6000));
|
ASSERT_TRUE(Between(c.ApproximateOffsetOf("xyz"), 4000, 6000));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -169,7 +169,7 @@ void TwoLevelIterator::InitDataBlock() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
Iterator* NewTwoLevelIterator(
|
Iterator* NewTwoLevelIterator(
|
||||||
Iterator* index_iter,
|
Iterator* index_iter,
|
||||||
@ -179,4 +179,4 @@ Iterator* NewTwoLevelIterator(
|
|||||||
return new TwoLevelIterator(index_iter, block_function, arg, options);
|
return new TwoLevelIterator(index_iter, block_function, arg, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -29,6 +29,6 @@ extern Iterator* NewTwoLevelIterator(
|
|||||||
void* arg,
|
void* arg,
|
||||||
const ReadOptions& options);
|
const ReadOptions& options);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_
|
#endif // STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_
|
||||||
|
@ -65,4 +65,4 @@ char* Arena::AllocateNewBlock(size_t block_bytes) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -63,6 +63,6 @@ inline char* Arena::Allocate(size_t bytes) {
|
|||||||
return AllocateFallback(bytes);
|
return AllocateFallback(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_ARENA_H_
|
#endif // STORAGE_LEVELDB_UTIL_ARENA_H_
|
||||||
|
@ -61,7 +61,7 @@ TEST(ArenaTest, Simple) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -325,4 +325,4 @@ Cache* NewLRUCache(size_t capacity) {
|
|||||||
return new ShardedLRUCache(capacity);
|
return new ShardedLRUCache(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -179,7 +179,7 @@ TEST(CacheTest, NewId) {
|
|||||||
ASSERT_NE(a, b);
|
ASSERT_NE(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -191,4 +191,4 @@ bool GetLengthPrefixedSlice(Slice* input, Slice* result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -99,6 +99,6 @@ inline const char* GetVarint32Ptr(const char* p,
|
|||||||
return GetVarint32PtrFallback(p, limit, value);
|
return GetVarint32PtrFallback(p, limit, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_CODING_H_
|
#endif // STORAGE_LEVELDB_UTIL_CODING_H_
|
||||||
|
@ -166,7 +166,7 @@ TEST(Coding, Strings) {
|
|||||||
ASSERT_EQ("", input.ToString());
|
ASSERT_EQ("", input.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -63,11 +63,11 @@ class BytewiseComparatorImpl : public Comparator {
|
|||||||
// *key is a run of 0xffs. Leave it alone.
|
// *key is a run of 0xffs. Leave it alone.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
static const BytewiseComparatorImpl bytewise;
|
static const BytewiseComparatorImpl bytewise;
|
||||||
|
|
||||||
const Comparator* BytewiseComparator() {
|
const Comparator* BytewiseComparator() {
|
||||||
return &bytewise;
|
return &bytewise;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -328,5 +328,5 @@ uint32_t Extend(uint32_t crc, const char* buf, size_t size) {
|
|||||||
return l ^ 0xffffffffu;
|
return l ^ 0xffffffffu;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace crc32c
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -39,7 +39,7 @@ inline uint32_t Unmask(uint32_t masked_crc) {
|
|||||||
return ((rot >> 17) | (rot << 15));
|
return ((rot >> 17) | (rot << 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace crc32c
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_CRC32C_H_
|
#endif // STORAGE_LEVELDB_UTIL_CRC32C_H_
|
||||||
|
@ -64,8 +64,8 @@ TEST(CRC, Mask) {
|
|||||||
ASSERT_EQ(crc, Unmask(Unmask(Mask(Mask(crc)))));
|
ASSERT_EQ(crc, Unmask(Unmask(Mask(Mask(crc)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace crc32c
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -79,4 +79,4 @@ Status ReadFileToString(Env* env, const std::string& fname, std::string* data) {
|
|||||||
EnvWrapper::~EnvWrapper() {
|
EnvWrapper::~EnvWrapper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -553,7 +553,7 @@ void PosixEnv::StartThread(void (*function)(void* arg), void* arg) {
|
|||||||
pthread_create(&t, NULL, &StartThreadWrapper, state));
|
pthread_create(&t, NULL, &StartThreadWrapper, state));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
static pthread_once_t once = PTHREAD_ONCE_INIT;
|
||||||
static Env* default_env;
|
static Env* default_env;
|
||||||
@ -564,4 +564,4 @@ Env* Env::Default() {
|
|||||||
return default_env;
|
return default_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -95,7 +95,7 @@ TEST(EnvPosixTest, StartThread) {
|
|||||||
ASSERT_EQ(state.val, 3);
|
ASSERT_EQ(state.val, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
return leveldb::test::RunAllTests();
|
return leveldb::test::RunAllTests();
|
||||||
|
@ -42,4 +42,4 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -136,4 +136,4 @@ std::string Histogram::ToString() const {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -37,6 +37,6 @@ class Histogram {
|
|||||||
double StandardDeviation() const;
|
double StandardDeviation() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
|
#endif // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
|
||||||
|
@ -78,4 +78,4 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) {
|
|||||||
return (digits > 0);
|
return (digits > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -42,6 +42,6 @@ extern bool ConsumeChar(Slice* in, char c);
|
|||||||
// unspecified state.
|
// unspecified state.
|
||||||
extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val);
|
extern bool ConsumeDecimalNumber(Slice* in, uint64_t* val);
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_LOGGING_H_
|
#endif // STORAGE_LEVELDB_UTIL_LOGGING_H_
|
||||||
|
@ -33,7 +33,7 @@ class MutexLock {
|
|||||||
void operator=(const MutexLock&);
|
void operator=(const MutexLock&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
|
#endif // STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
|
||||||
|
@ -25,4 +25,4 @@ Options::Options()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -93,6 +93,6 @@ class PosixLogger : public Logger {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_
|
#endif // STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_
|
||||||
|
@ -54,6 +54,6 @@ class Random {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_RANDOM_H_
|
#endif // STORAGE_LEVELDB_UTIL_RANDOM_H_
|
||||||
|
@ -72,4 +72,4 @@ std::string Status::ToString() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -73,5 +73,5 @@ int RandomSeed() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace test
|
||||||
}
|
} // namespace leveldb
|
||||||
|
@ -132,7 +132,7 @@ void TCONCAT(_Test_,name)::_Run()
|
|||||||
extern bool RegisterTest(const char* base, const char* name, void (*func)());
|
extern bool RegisterTest(const char* base, const char* name, void (*func)());
|
||||||
|
|
||||||
|
|
||||||
}
|
} // namespace test
|
||||||
}
|
} // namespace leveldb
|
||||||
|
|
||||||
#endif // STORAGE_LEVELDB_UTIL_TESTHARNESS_H_
|
#endif // STORAGE_LEVELDB_UTIL_TESTHARNESS_H_
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user