Commit fb87cfdf authored by cmumford@chromium.org's avatar cmumford@chromium.org

LevelDBDatabase::Compact compacts db (on disk) w/o requiring reopen.

This change writes (flushes) compacted data to disk resulting in
changes, which would previously only be flushed the next db close/open
cycle, to be written immediately.

BUG=329347

Review URL: https://codereview.chromium.org/397323003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284313 0039d316-1c4b-4281-b951-d872f2087c98
parent 84b7a55e
...@@ -641,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ...@@ -641,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest,
const int kTestFillBytes = 1024 * 1024 * 5; // 5MB const int kTestFillBytes = 1024 * 1024 * 5; // 5MB
EXPECT_GT(after_filling, kTestFillBytes); EXPECT_GT(after_filling, kTestFillBytes);
const int kTestCompactBytes = 1024 * 1024 * 1; // 1MB const int kTestCompactBytes = 1024 * 10; // 10kB
EXPECT_LT(after_deleting, kTestCompactBytes); EXPECT_LT(after_deleting, kTestCompactBytes);
} }
......
...@@ -395,6 +395,8 @@ void LevelDBDatabase::Compact(const base::StringPiece& start, ...@@ -395,6 +395,8 @@ void LevelDBDatabase::Compact(const base::StringPiece& start,
const base::StringPiece& stop) { const base::StringPiece& stop) {
const leveldb::Slice start_slice = MakeSlice(start); const leveldb::Slice start_slice = MakeSlice(start);
const leveldb::Slice stop_slice = MakeSlice(stop); const leveldb::Slice stop_slice = MakeSlice(stop);
// NULL batch means just wait for earlier writes to be done
db_->Write(leveldb::WriteOptions(), NULL);
db_->CompactRange(&start_slice, &stop_slice); db_->CompactRange(&start_slice, &stop_slice);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment