82 delay_data_sync_.Release_Store(NULL);
83 data_sync_error_.Release_Store(NULL);
84 no_space_.Release_Store(NULL);
85 non_writable_.Release_Store(NULL);
86 count_random_reads_ =
false;
87 manifest_sync_error_.Release_Store(NULL);
88 manifest_write_error_.Release_Store(NULL);
102 ~DataFile() {
delete base_; }
104 if (env_->
no_space_.Acquire_Load() != NULL) {
108 return base_->
Append(data);
120 return base_->
Sync();
129 ~ManifestFile() {
delete base_; }
134 return base_->
Append(data);
143 return base_->
Sync();
148 if (non_writable_.Acquire_Load() != NULL) {
152 Status s = target()->NewWritableFile(f, r);
154 if (strstr(f.c_str(),
".ldb") != NULL ||
155 strstr(f.c_str(),
".log") != NULL) {
156 *r =
new DataFile(
this, *r);
157 }
else if (strstr(f.c_str(),
"MANIFEST") != NULL) {
158 *r =
new ManifestFile(
this, *r);
168 AtomicCounter* counter_;
171 : target_(target), counter_(counter) {
173 virtual ~CountingFile() {
delete target_; }
174 virtual Status Read(uint64_t offset,
size_t n,
Slice* result,
175 char* scratch)
const {
176 counter_->Increment();
177 return target_->
Read(offset, n, result, scratch);
181 Status s = target()->NewRandomAccessFile(f, r);
182 if (s.
ok() && count_random_reads_) {
183 *r =
new CountingFile(*r, &random_read_counter_);
223 delete filter_policy_;
230 if (option_config_ >= kEnd) {
242 switch (option_config_) {
259 return reinterpret_cast<DBImpl*
>(db_);
282 if (options != NULL) {
285 opts = CurrentOptions();
288 last_options_ = opts;
290 return DB::Open(opts, dbname_, &db_);
293 Status Put(
const std::string& k,
const std::string& v) {
301 std::string
Get(
const std::string& k,
const Snapshot* snapshot = NULL) {
305 Status s = db_->
Get(options, k, &result);
307 result =
"NOT_FOUND";
308 }
else if (!s.
ok()) {
317 std::vector<std::string> forward;
321 std::string s = IterStatus(iter);
322 result.push_back(
'(');
324 result.push_back(
')');
325 forward.push_back(s);
332 ASSERT_EQ(IterStatus(iter), forward[forward.size() - matched - 1]);
342 Iterator* iter = dbfull()->TEST_NewInternalIterator();
351 while (iter->
Valid()) {
354 result +=
"CORRUPTED";
384 std::string property;
388 return atoi(property.c_str());
394 result += NumTableFilesAtLevel(level);
402 int last_non_zero_offset = 0;
404 int f = NumTableFilesAtLevel(level);
406 snprintf(buf,
sizeof(buf),
"%s%d", (level ?
"," :
""), f);
409 last_non_zero_offset = result.size();
412 result.resize(last_non_zero_offset);
417 std::vector<std::string> files;
419 return static_cast<int>(files.size());
423 Range r(start, limit);
435 void MakeTables(
int n,
const std::string& small,
const std::string& large) {
436 for (
int i = 0; i < n; i++) {
439 dbfull()->TEST_CompactMemTable();
445 void FillLevels(
const std::string& smallest,
const std::string& largest) {
450 fprintf(stderr,
"---\n%s:\n", label);
451 fprintf(stderr,
"maxoverlap: %lld\n",
452 static_cast<long long>(
453 dbfull()->TEST_MaxNextLevelOverlappingBytes()));
455 int num = NumTableFilesAtLevel(level);
457 fprintf(stderr,
" level %3d : %d files\n", level, num);
463 std::string property;
473 result =
"(invalid)";
479 std::vector<std::string> filenames;
483 for (
size_t i = 0; i < filenames.size(); i++) {
494 std::vector<std::string> filenames;
498 int files_renamed = 0;
499 for (
size_t i = 0; i < filenames.size(); i++) {
507 return files_renamed;
515 }
while (ChangeOptions());
526 }
while (ChangeOptions());
537 }
while (ChangeOptions());
542 Options options = CurrentOptions();
550 env_->delay_data_sync_.Release_Store(env_);
551 Put(
"k1", std::string(100000,
'x'));
552 Put(
"k2", std::string(100000,
'y'));
554 env_->delay_data_sync_.Release_Store(NULL);
555 }
while (ChangeOptions());
561 dbfull()->TEST_CompactMemTable();
563 }
while (ChangeOptions());
570 ASSERT_TRUE(db_->GetProperty(
"leveldb.approximate-memory-usage", &val));
571 int mem_usage = atoi(val.c_str());
574 }
while (ChangeOptions());
580 for (
int i = 0; i < 2; i++) {
581 std::string key = (i == 0) ? std::string(
"foo") : std::string(200,
'x');
583 const Snapshot* s1 = db_->GetSnapshot();
587 dbfull()->TEST_CompactMemTable();
590 db_->ReleaseSnapshot(s1);
592 }
while (ChangeOptions());
603 dbfull()->TEST_CompactMemTable();
605 dbfull()->TEST_CompactMemTable();
607 }
while (ChangeOptions());
617 dbfull()->TEST_CompactMemTable();
619 }
while (ChangeOptions());
634 }
while (ChangeOptions());
648 int compaction_count = 0;
649 while (NumTableFilesAtLevel(0) == 0 ||
650 NumTableFilesAtLevel(2) == 0) {
651 ASSERT_LE(compaction_count, 100) <<
"could not fill levels 0 and 2";
655 dbfull()->TEST_CompactMemTable();
659 dbfull()->TEST_CompactRange(1, NULL, NULL);
665 for (
int i = 0; i < 1000; i++) {
673 }
while (ChangeOptions());
680 ASSERT_EQ(IterStatus(iter),
"(invalid)");
683 ASSERT_EQ(IterStatus(iter),
"(invalid)");
686 ASSERT_EQ(IterStatus(iter),
"(invalid)");
698 ASSERT_EQ(IterStatus(iter),
"(invalid)");
702 ASSERT_EQ(IterStatus(iter),
"(invalid)");
707 ASSERT_EQ(IterStatus(iter),
"(invalid)");
711 ASSERT_EQ(IterStatus(iter),
"(invalid)");
716 ASSERT_EQ(IterStatus(iter),
"(invalid)");
721 ASSERT_EQ(IterStatus(iter),
"(invalid)");
724 ASSERT_EQ(IterStatus(iter),
"(invalid)");
742 ASSERT_EQ(IterStatus(iter),
"(invalid)");
746 ASSERT_EQ(IterStatus(iter),
"(invalid)");
755 ASSERT_EQ(IterStatus(iter),
"(invalid)");
759 ASSERT_EQ(IterStatus(iter),
"(invalid)");
770 ASSERT_EQ(IterStatus(iter),
"(invalid)");
799 ASSERT_EQ(IterStatus(iter),
"(invalid)");
807 ASSERT_EQ(IterStatus(iter),
"(invalid)");
814 ASSERT_OK(Put(
"b", std::string(100000,
'b')));
816 ASSERT_OK(Put(
"d", std::string(100000,
'd')));
817 ASSERT_OK(Put(
"e", std::string(100000,
'e')));
824 ASSERT_EQ(IterStatus(iter),
"b->" + std::string(100000,
'b'));
828 ASSERT_EQ(IterStatus(iter),
"d->" + std::string(100000,
'd'));
830 ASSERT_EQ(IterStatus(iter),
"e->" + std::string(100000,
'e'));
832 ASSERT_EQ(IterStatus(iter),
"(invalid)");
835 ASSERT_EQ(IterStatus(iter),
"e->" + std::string(100000,
'e'));
837 ASSERT_EQ(IterStatus(iter),
"d->" + std::string(100000,
'd'));
841 ASSERT_EQ(IterStatus(iter),
"b->" + std::string(100000,
'b'));
845 ASSERT_EQ(IterStatus(iter),
"(invalid)");
864 }
while (ChangeOptions());
886 }
while (ChangeOptions());
898 }
while (ChangeOptions());
905 Options options = CurrentOptions();
912 ASSERT_OK(Put(
"big1", std::string(10000000,
'x')));
913 ASSERT_OK(Put(
"big2", std::string(1000,
'y')));
919 ASSERT_EQ(std::string(10000000,
'x'), Get(
"big1"));
920 ASSERT_EQ(std::string(1000,
'y'), Get(
"big2"));
921 }
while (ChangeOptions());
924 static std::string
Key(
int i) {
926 snprintf(buf,
sizeof(buf),
"key%06d", i);
927 return std::string(buf);
931 Options options = CurrentOptions();
937 int starting_num_tables = TotalTableFiles();
938 for (
int i = 0; i < N; i++) {
941 int ending_num_tables = TotalTableFiles();
942 ASSERT_GT(ending_num_tables, starting_num_tables);
944 for (
int i = 0; i < N; i++) {
950 for (
int i = 0; i < N; i++) {
957 Options options = CurrentOptions();
959 ASSERT_OK(Put(
"big1", std::string(200000,
'1')));
960 ASSERT_OK(Put(
"big2", std::string(200000,
'2')));
961 ASSERT_OK(Put(
"small3", std::string(10,
'3')));
962 ASSERT_OK(Put(
"small4", std::string(10,
'4')));
968 Options options = CurrentOptions();
972 ASSERT_EQ(std::string(200000,
'1'), Get(
"big1"));
973 ASSERT_EQ(std::string(200000,
'2'), Get(
"big2"));
974 ASSERT_EQ(std::string(10,
'3'), Get(
"small3"));
975 ASSERT_EQ(std::string(10,
'4'), Get(
"small4"));
980 Options options = CurrentOptions();
988 std::vector<std::string> values;
989 for (
int i = 0; i < 80; i++) {
996 dbfull()->TEST_CompactRange(0, NULL, NULL);
1000 for (
int i = 0; i < 80; i++) {
1006 Options options = CurrentOptions();
1017 for (
int i = 0; i < 5 * kMaxFiles; i++) {
1019 ASSERT_LE(TotalTableFiles(), kMaxFiles);
1020 fprintf(stderr,
"after %d: %d files\n",
int(i+1), TotalTableFiles());
1025 Options options = CurrentOptions();
1029 FillLevels(
"A",
"Z");
1037 const std::string value(1000,
'x');
1040 for (
int i = 0; i < 100000; i++) {
1042 snprintf(key,
sizeof(key),
"B%010d", i);
1046 dbfull()->TEST_CompactMemTable();
1047 dbfull()->TEST_CompactRange(0, NULL, NULL);
1051 Put(
"B100",
"bvalue2");
1053 dbfull()->TEST_CompactMemTable();
1057 ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576);
1058 dbfull()->TEST_CompactRange(0, NULL, NULL);
1059 ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576);
1060 dbfull()->TEST_CompactRange(1, NULL, NULL);
1061 ASSERT_LE(dbfull()->TEST_MaxNextLevelOverlappingBytes(), 20*1048576);
1064 static bool Between(uint64_t val, uint64_t low, uint64_t high) {
1065 bool result = (val >= low) && (val <= high);
1067 fprintf(stderr,
"Value %llu is not in range [%llu, %llu]\n",
1068 (
unsigned long long)(val),
1069 (
unsigned long long)(low),
1070 (
unsigned long long)(high));
1077 Options options = CurrentOptions();
1089 static const int S1 = 100000;
1090 static const int S2 = 105000;
1092 for (
int i = 0; i < N; i++) {
1108 for (
int run = 0; run < 3; run++) {
1111 for (
int compact_start = 0; compact_start < N; compact_start += 10) {
1112 for (
int i = 0; i < N; i += 10) {
1120 std::string cstart_str =
Key(compact_start);
1121 std::string cend_str =
Key(compact_start + 9);
1122 Slice cstart = cstart_str;
1123 Slice cend = cend_str;
1124 dbfull()->TEST_CompactRange(0, &cstart, &cend);
1130 }
while (ChangeOptions());
1135 Options options = CurrentOptions();
1152 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1156 for (
int run = 0; run < 3; run++) {
1171 dbfull()->TEST_CompactRange(0, NULL, NULL);
1173 }
while (ChangeOptions());
1177 Put(
"foo",
"hello");
1183 Put(
"foo",
"newvalue1");
1184 for (
int i = 0; i < 100; i++) {
1187 Put(
"foo",
"newvalue2");
1201 const Snapshot* s1 = db_->GetSnapshot();
1203 const Snapshot* s2 = db_->GetSnapshot();
1205 const Snapshot* s3 = db_->GetSnapshot();
1213 db_->ReleaseSnapshot(s3);
1218 db_->ReleaseSnapshot(s1);
1222 db_->ReleaseSnapshot(s2);
1224 }
while (ChangeOptions());
1230 FillLevels(
"a",
"z");
1234 Put(
"pastfoo",
"v");
1235 const Snapshot* snapshot = db_->GetSnapshot();
1237 Put(
"pastfoo2",
"v2");
1239 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1244 db_->ReleaseSnapshot(snapshot);
1245 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ tiny, " + big +
" ]");
1247 dbfull()->TEST_CompactRange(0, NULL, &x);
1248 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ tiny ]");
1251 dbfull()->TEST_CompactRange(1, NULL, &x);
1252 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ tiny ]");
1255 }
while (ChangeOptions());
1260 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1262 ASSERT_EQ(NumTableFilesAtLevel(last), 1);
1267 dbfull()->TEST_CompactMemTable();
1268 ASSERT_EQ(NumTableFilesAtLevel(last), 1);
1269 ASSERT_EQ(NumTableFilesAtLevel(last-1), 1);
1273 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ v2, DEL, v1 ]");
1274 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1275 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ v2, DEL, v1 ]");
1277 dbfull()->TEST_CompactRange(last-2, NULL, &z);
1280 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ v2, v1 ]");
1281 dbfull()->TEST_CompactRange(last-1, NULL, NULL);
1284 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ v2 ]");
1289 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1291 ASSERT_EQ(NumTableFilesAtLevel(last), 1);
1296 dbfull()->TEST_CompactMemTable();
1297 ASSERT_EQ(NumTableFilesAtLevel(last), 1);
1298 ASSERT_EQ(NumTableFilesAtLevel(last-1), 1);
1301 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ DEL, v1 ]");
1302 ASSERT_OK(dbfull()->TEST_CompactMemTable());
1303 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ DEL, v1 ]");
1304 dbfull()->TEST_CompactRange(last-2, NULL, NULL);
1306 ASSERT_EQ(AllEntriesFor(
"foo"),
"[ DEL, v1 ]");
1307 dbfull()->TEST_CompactRange(last-1, NULL, NULL);
1320 dbfull()->TEST_CompactMemTable();
1323 dbfull()->TEST_CompactMemTable();
1332 dbfull()->TEST_CompactMemTable();
1336 dbfull()->TEST_CompactMemTable();
1340 dbfull()->TEST_CompactRange(1, NULL, NULL);
1341 dbfull()->TEST_CompactRange(2, NULL, NULL);
1348 dbfull()->TEST_CompactMemTable();
1351 }
while (ChangeOptions());
1400 virtual const char* Name()
const {
return "leveldb.NewComparator"; }
1401 virtual int Compare(
const Slice& a,
const Slice& b)
const {
1404 virtual void FindShortestSeparator(std::string* s,
const Slice& l)
const {
1407 virtual void FindShortSuccessor(std::string* key)
const {
1412 Options new_options = CurrentOptions();
1414 Status s = TryReopen(&new_options);
1423 virtual const char* Name()
const {
return "test.NumberComparator"; }
1424 virtual int Compare(
const Slice& a,
const Slice& b)
const {
1425 return ToNumber(a) - ToNumber(b);
1427 virtual void FindShortestSeparator(std::string* s,
const Slice& l)
const {
1431 virtual void FindShortSuccessor(std::string* key)
const {
1435 static int ToNumber(
const Slice& x) {
1446 NumberComparator cmp;
1447 Options new_options = CurrentOptions();
1452 DestroyAndReopen(&new_options);
1455 for (
int i = 0; i < 2; i++) {
1462 Compact(
"[0]",
"[9999]");
1465 for (
int run = 0; run < 2; run++) {
1466 for (
int i = 0; i < 1000; i++) {
1468 snprintf(buf,
sizeof(buf),
"[%d]", i*10);
1471 Compact(
"[0]",
"[1000000]");
1477 <<
"Need to update this test to match kMaxMemCompactLevel";
1479 MakeTables(3,
"p",
"q");
1491 Compact(
"p1",
"p9");
1495 MakeTables(3,
"c",
"e");
1503 MakeTables(1,
"a",
"z");
1505 db_->CompactRange(NULL, NULL);
1551 ASSERT_TRUE(!s.
ok()) <<
"Locking did not prevent re-opening db";
1556 Options options = CurrentOptions();
1563 const int num_files = CountFiles();
1564 env_->no_space_.Release_Store(env_);
1565 for (
int i = 0; i < 10; i++) {
1567 dbfull()->TEST_CompactRange(level, NULL, NULL);
1570 env_->no_space_.Release_Store(NULL);
1575 Options options = CurrentOptions();
1580 env_->non_writable_.Release_Store(env_);
1581 std::string big(100000,
'x');
1583 for (
int i = 0; i < 20; i++) {
1584 fprintf(stderr,
"iter %d; errors %d\n", i, errors);
1585 if (!Put(
"foo", big).ok()) {
1591 env_->non_writable_.Release_Store(NULL);
1598 Options options = CurrentOptions();
1601 env_->data_sync_error_.Release_Store(env_);
1615 env_->data_sync_error_.Release_Store(NULL);
1634 for (
int iter = 0; iter < 2; iter++) {
1635 port::AtomicPointer* error_type = (iter == 0)
1636 ? &env_->manifest_sync_error_
1637 : &env_->manifest_write_error_;
1640 Options options = CurrentOptions();
1642 options.create_if_missing =
true;
1643 options.error_if_exists =
false;
1644 DestroyAndReopen(&options);
1649 dbfull()->TEST_CompactMemTable();
1652 ASSERT_EQ(NumTableFilesAtLevel(last), 1);
1655 error_type->Release_Store(env_);
1656 dbfull()->TEST_CompactRange(last, NULL, NULL);
1660 error_type->Release_Store(NULL);
1671 dbfull()->TEST_CompactMemTable();
1676 Options options = CurrentOptions();
1678 Status s = TryReopen(&options);
1689 dbfull()->TEST_CompactMemTable();
1693 Options options = CurrentOptions();
1695 Status s = TryReopen(&options);
1703 const int num_files = CountFiles();
1704 for (
int i = 0; i < 10; i++) {
1712 env_->count_random_reads_ =
true;
1713 Options options = CurrentOptions();
1720 const int N = 10000;
1721 for (
int i = 0; i < N; i++) {
1725 for (
int i = 0; i < N; i += 100) {
1728 dbfull()->TEST_CompactMemTable();
1731 env_->delay_data_sync_.Release_Store(env_);
1734 env_->random_read_counter_.Reset();
1735 for (
int i = 0; i < N; i++) {
1738 int reads = env_->random_read_counter_.Read();
1739 fprintf(stderr,
"%d present => %d reads\n", N, reads);
1744 env_->random_read_counter_.Reset();
1745 for (
int i = 0; i < N; i++) {
1748 reads = env_->random_read_counter_.Read();
1749 fprintf(stderr,
"%d missing => %d reads\n", N, reads);
1752 env_->delay_data_sync_.Release_Store(NULL);
1781 uintptr_t counter = 0;
1782 fprintf(stderr,
"... starting thread %d\n",
id);
1786 while (t->
state->
stop.Acquire_Load() == NULL) {
1787 t->
state->
counter[id].Release_Store(reinterpret_cast<void*>(counter));
1789 int key = rnd.
Uniform(kNumKeys);
1791 snprintf(keybuf,
sizeof(keybuf),
"%016d", key);
1796 snprintf(valbuf,
sizeof(valbuf),
"%d.%d.%-1000d",
1797 key,
id, static_cast<int>(counter));
1808 ASSERT_EQ(3, sscanf(value.c_str(),
"%d.%d.%d", &k, &w, &c)) << value;
1812 ASSERT_LE(static_cast<uintptr_t>(c), reinterpret_cast<uintptr_t>(
1819 fprintf(stderr,
"... stopping thread %d after %d ops\n",
id,
int(counter));
1829 mt.stop.Release_Store(0);
1831 mt.counter[id].Release_Store(0);
1832 mt.thread_done[id].Release_Store(0);
1838 thread[id].state = &mt;
1847 mt.stop.Release_Store(&mt);
1849 while (mt.thread_done[
id].Acquire_Load() == NULL) {
1853 }
while (ChangeOptions());
1857 typedef std::map<std::string, std::string>
KVMap;
1876 const Slice& key, std::string* value) {
1886 const KVMap* snapshot_state =
1888 return new ModelIter(snapshot_state,
false);
1893 snapshot->
map_ = map_;
1904 virtual void Put(
const Slice& key,
const Slice& value) {
1907 virtual void Delete(
const Slice& key) {
1912 handler.map_ = &map_;
1913 return batch->
Iterate(&handler);
1920 for (
int i = 0; i < n; i++) {
1931 : map_(map), owned_(owned), iter_(map_->end()) {
1934 if (owned_)
delete map_;
1936 virtual bool Valid()
const {
return iter_ != map_->end(); }
1939 if (map_->empty()) {
1940 iter_ = map_->end();
1942 iter_ = map_->find(map_->rbegin()->first);
1946 iter_ = map_->lower_bound(k.
ToString());
1963 int len = (rnd->
OneIn(3)
1986 fprintf(stderr,
"step %d: Key mismatch: '%s' vs. '%s'\n",
1995 fprintf(stderr,
"step %d: Value mismatch for key '%s': '%s' vs. '%s'\n",
2006 fprintf(stderr,
"step %d: Mismatch at end of iterators: %d vs. %d\n",
2011 fprintf(stderr,
"%d entries compared: ok=%d\n", count, ok);
2020 ModelDB model(CurrentOptions());
2021 const int N = 10000;
2025 for (
int step = 0; step < N; step++) {
2026 if (step % 100 == 0) {
2027 fprintf(stderr,
"Step %d of %d\n", step, N);
2040 }
else if (p < 90) {
2048 const int num = rnd.
Uniform(8);
2049 for (
int i = 0; i < num; i++) {
2050 if (i == 0 || !rnd.
OneIn(10)) {
2067 if ((step % 100) == 0) {
2074 if (db_snap != NULL) db_->ReleaseSnapshot(db_snap);
2080 db_snap = db_->GetSnapshot();
2084 if (db_snap != NULL) db_->ReleaseSnapshot(db_snap);
2085 }
while (ChangeOptions());
2090 snprintf(buf,
sizeof(buf),
"%016u", num);
2091 return std::string(buf);
2115 VersionSet vset(dbname, &options, NULL, &cmp);
2120 for (
int i = 0; i < num_base_files; i++) {
2123 vbase.AddFile(2, fnum++, 1 , start, limit);
2127 uint64_t start_micros = env->
NowMicros();
2129 for (
int i = 0; i < iters; i++) {
2134 vedit.
AddFile(2, fnum++, 1 , start, limit);
2137 uint64_t stop_micros = env->
NowMicros();
2138 unsigned int us = stop_micros - start_micros;
2140 snprintf(buf,
sizeof(buf),
"%d", num_base_files);
2142 "BM_LogAndApply/%-6s %8d iters : %9u us (%7.0f us / iter)\n",
2143 buf, iters, us, ((
float)us) / iters);
2149 if (argc > 1 && std::string(argv[1]) ==
"--benchmark") {
virtual const Snapshot * GetSnapshot()
ModelIter(const KVMap *map, bool owned)
virtual Status status() const =0
virtual Status Put(const WriteOptions &o, const Slice &k, const Slice &v)
static const SequenceNumber kMaxSequenceNumber
std::string Get(const std::string &k, const Snapshot *snapshot=NULL)
virtual bool Valid() const
bool ParseFileName(const std::string &fname, uint64_t *number, FileType *type)
static Status NotFound(const Slice &msg, const Slice &msg2=Slice())
static const int kL0_StopWritesTrigger
static const int kNumLevels
static bool CompareIterators(int step, DB *model, DB *db, const Snapshot *model_snap, const Snapshot *db_snap)
virtual Slice key() const =0
virtual void CompactRange(const Slice *begin, const Slice *end)=0
std::string MakeKey(unsigned int num)
virtual Slice value() const =0
port::AtomicPointer counter[kNumThreads]
Status Delete(const std::string &k)
void DeleteFile(int level, uint64_t file)
virtual void Seek(const Slice &k)
Status TryReopen(Options *options)
std::string AllEntriesFor(const Slice &user_key)
port::AtomicPointer delay_data_sync_
static bool Between(uint64_t val, uint64_t low, uint64_t high)
virtual void FindShortestSeparator(std::string *start, const Slice &limit) const =0
std::string DumpSSTableList()
Status LogAndApply(VersionEdit *edit, port::Mutex *mu) EXCLUSIVE_LOCKS_REQUIRED(mu)
virtual void SleepForMicroseconds(int micros)=0
Status Iterate(Handler *handler) const
virtual void SeekToFirst()=0
std::map< std::string, std::string, STLLessThan > KVMap
void FillLevels(const std::string &smallest, const std::string &largest)
static std::string RandomString(Random *rnd, int len)
std::string ToString() const
virtual void Seek(const Slice &target)=0
int NumTableFilesAtLevel(int level)
virtual void SeekToLast()=0
bool ParseInternalKey(const Slice &internal_key, ParsedInternalKey *result)
virtual Status Put(const WriteOptions &options, const Slice &key, const Slice &value)=0
KVMap::const_iterator iter_
void IncrementBy(int count)
virtual bool GetProperty(const Slice &property, std::string *value)
void DumpFileCounts(const char *label)
Status DestroyDB(const std::string &dbname, const Options &options)
void Reopen(Options *options=NULL)
virtual Iterator * NewIterator(const ReadOptions &options)
port::AtomicPointer manifest_write_error_
void Compact(const Slice &start, const Slice &limit)
int compare(const Slice &b) const
std::string TableFileName(const std::string &name, uint64_t number)
virtual void GetApproximateSizes(const Range *r, int n, uint64_t *sizes)
virtual void SeekToFirst()
virtual Status Write(const WriteOptions &options, WriteBatch *batch)
virtual bool GetProperty(const Slice &property, std::string *value)=0
std::string ToString() const
void Delete(const Slice &key)
virtual Status Get(const ReadOptions &options, const Slice &key, std::string *value)
virtual Status Delete(const WriteOptions &options, const Slice &key)=0
AtomicCounter random_read_counter_
virtual Slice key() const
port::AtomicPointer non_writable_
virtual Status Get(const ReadOptions &options, const Slice &key, std::string *value)=0
static Status Open(const Options &options, const std::string &name, DB **dbptr)
uint64_t Size(const Slice &start, const Slice &limit)
static std::string RandomKey(Random *rnd)
static const int kMaxMemCompactLevel
std::string EscapeString(const Slice &value)
std::string IterStatus(Iterator *iter)
Status RenameFile(const std::string &s, const std::string &t)
const FilterPolicy * NewBloomFilterPolicy(int bits_per_key)
TEST(AutoCompactTest, ReadAll)
Status DeleteFile(const std::string &f)
virtual void GetApproximateSizes(const Range *range, int n, uint64_t *sizes)=0
virtual void FindShortSuccessor(std::string *key) const =0
Status Recover(bool *save_manifest)
uint32_t Skewed(int max_log)
std::string SSTTableFileName(const std::string &name, uint64_t number)
virtual Status status() const
virtual Status Delete(const WriteOptions &o, const Slice &key)
Status Put(const std::string &k, const std::string &v)
std::string FilesPerLevel()
void BM_LogAndApply(int iters, int num_base_files)
void DestroyAndReopen(Options *options=NULL)
static const int kTestSeconds
ModelDB(const Options &options)
Cache * NewLRUCache(size_t capacity)
const Comparator * BytewiseComparator()
static const int kNumKeys
const FilterPolicy * filter_policy
virtual void ReleaseSnapshot(const Snapshot *snapshot)
virtual void SeekToLast()
Status NewWritableFile(const std::string &f, WritableFile **r)
const Comparator * comparator
virtual void CompactRange(const Slice *start, const Slice *end)
virtual Iterator * NewIterator(const ReadOptions &options)=0
virtual uint64_t NowMicros()=0
virtual Slice value() const
port::AtomicPointer no_space_
void AddFile(int level, uint64_t file, uint64_t file_size, const InternalKey &smallest, const InternalKey &largest)
virtual Status Append(const Slice &data)=0
const Snapshot * snapshot
virtual int Compare(const Slice &a, const Slice &b) const =0
std::string RandomKey(Random *rnd, int len)
port::AtomicPointer thread_done[kNumThreads]
Slice RandomString(Random *rnd, int len, std::string *dst)
Status GetChildren(const std::string &dir, std::vector< std::string > *r)
const FilterPolicy * filter_policy_
int main(int argc, char **argv)
void MakeTables(int n, const std::string &small, const std::string &large)
static Status IOError(const Slice &msg, const Slice &msg2=Slice())
virtual Status Read(uint64_t offset, size_t n, Slice *result, char *scratch) const =0
virtual bool Valid() const =0
Status NewRandomAccessFile(const std::string &f, RandomAccessFile **r)
static void MTThreadBody(void *arg)
void Put(const Slice &key, const Slice &value)
void DelayMilliseconds(int millis)
std::string NumberToString(uint64_t num)
port::AtomicPointer data_sync_error_
port::AtomicPointer manifest_sync_error_
static const int kNumThreads
CompressionType compression