Commit 7eff2e4b authored by cmumford's avatar cmumford Committed by Commit bot

IndexedDB: Switched two Iterator::Seek calls to Transaction::Get.

Switching for two reasons:

1. Semantics are simpler because, in each of these cases, there was never a
   subsequent iteration - just a check to see if the iterator key matched
   the desired key.
2. The Transaction::Get() call uses the LevelDB filter which (when enabled)
   can significantly reduce disk reads, thus improving performance.

This change, along with enabling the bloom filter, resolves a performance
issue introduced by r273048.

BUG=409520

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

Cr-Commit-Position: refs/heads/master@{#294675}
parent 66602da3
...@@ -2678,13 +2678,14 @@ leveldb::Status IndexedDBBackingStore::Transaction::GetBlobInfoForRecord( ...@@ -2678,13 +2678,14 @@ leveldb::Status IndexedDBBackingStore::Transaction::GetBlobInfoForRecord(
NOTREACHED(); NOTREACHED();
return InternalInconsistencyStatus(); return InternalInconsistencyStatus();
} }
scoped_ptr<LevelDBIterator> it = transaction()->CreateIterator();
std::string encoded_key = blob_entry_key.Encode(); std::string encoded_key = blob_entry_key.Encode();
leveldb::Status s = it->Seek(encoded_key); bool found;
std::string encoded_value;
leveldb::Status s = transaction()->Get(encoded_key, &encoded_value, &found);
if (!s.ok()) if (!s.ok())
return s; return s;
if (it->IsValid() && CompareKeys(it->Key(), encoded_key) == 0) { if (found) {
if (!DecodeBlobData(it->Value().as_string(), &value->blob_info)) { if (!DecodeBlobData(encoded_value, &value->blob_info)) {
INTERNAL_READ_ERROR(GET_BLOB_INFO_FOR_RECORD); INTERNAL_READ_ERROR(GET_BLOB_INFO_FOR_RECORD);
return InternalInconsistencyStatus(); return InternalInconsistencyStatus();
} }
...@@ -3981,7 +3982,6 @@ bool IndexedDBBackingStore::Transaction::CollectBlobFilesToRemove() { ...@@ -3981,7 +3982,6 @@ bool IndexedDBBackingStore::Transaction::CollectBlobFilesToRemove() {
// Look up all old files to remove as part of the transaction, store their // Look up all old files to remove as part of the transaction, store their
// names in blobs_to_remove_, and remove their old blob data entries. // names in blobs_to_remove_, and remove their old blob data entries.
if (iter != blob_change_map_.end()) { if (iter != blob_change_map_.end()) {
scoped_ptr<LevelDBIterator> db_iter = transaction_->CreateIterator();
for (; iter != blob_change_map_.end(); ++iter) { for (; iter != blob_change_map_.end(); ++iter) {
BlobEntryKey blob_entry_key; BlobEntryKey blob_entry_key;
StringPiece key_piece(iter->second->key()); StringPiece key_piece(iter->second->key());
...@@ -3996,11 +3996,13 @@ bool IndexedDBBackingStore::Transaction::CollectBlobFilesToRemove() { ...@@ -3996,11 +3996,13 @@ bool IndexedDBBackingStore::Transaction::CollectBlobFilesToRemove() {
else else
DCHECK_EQ(database_id_, blob_entry_key.database_id()); DCHECK_EQ(database_id_, blob_entry_key.database_id());
std::string blob_entry_key_bytes = blob_entry_key.Encode(); std::string blob_entry_key_bytes = blob_entry_key.Encode();
db_iter->Seek(blob_entry_key_bytes); bool found;
if (db_iter->IsValid() && std::string blob_entry_value_bytes;
!CompareKeys(db_iter->Key(), blob_entry_key_bytes)) { leveldb::Status s = transaction_->Get(
blob_entry_key_bytes, &blob_entry_value_bytes, &found);
if (s.ok() && found) {
std::vector<IndexedDBBlobInfo> blob_info; std::vector<IndexedDBBlobInfo> blob_info;
if (!DecodeBlobData(db_iter->Value().as_string(), &blob_info)) { if (!DecodeBlobData(blob_entry_value_bytes, &blob_info)) {
INTERNAL_READ_ERROR_UNTESTED(TRANSACTION_COMMIT_METHOD); INTERNAL_READ_ERROR_UNTESTED(TRANSACTION_COMMIT_METHOD);
transaction_ = NULL; transaction_ = NULL;
return false; return false;
......
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