diff --git a/db/db_test.cc b/db/db_test.cc index 808fd7605..117853c1e 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2284,8 +2284,8 @@ TEST(DBTest, TransactionLogIterator) { SequenceNumber lastSequence = 0; while (iter->Valid()) { WriteBatch batch; - iter->GetBatch(&batch); - SequenceNumber current = WriteBatchInternal::Sequence(&batch); + SequenceNumber current; + iter->GetBatch(&batch, ¤t); ASSERT_TRUE(current > lastSequence); ++i; lastSequence = current; @@ -2310,8 +2310,8 @@ TEST(DBTest, TransactionLogIterator) { SequenceNumber lastSequence = 0; while (iter->Valid()) { WriteBatch batch; - iter->GetBatch(&batch); - SequenceNumber current = WriteBatchInternal::Sequence(&batch); + SequenceNumber current; + iter->GetBatch(&batch, ¤t); ASSERT_TRUE(current > lastSequence); lastSequence = current; ASSERT_TRUE(iter->status().ok()); diff --git a/db/transaction_log_iterator_impl.cc b/db/transaction_log_iterator_impl.cc index e2781a574..c2ca14a36 100644 --- a/db/transaction_log_iterator_impl.cc +++ b/db/transaction_log_iterator_impl.cc @@ -51,9 +51,11 @@ Status TransactionLogIteratorImpl::OpenLogFile(const LogFile& logFile, } } -void TransactionLogIteratorImpl::GetBatch(WriteBatch* batch) { +void TransactionLogIteratorImpl::GetBatch(WriteBatch* batch, + SequenceNumber* seq) { assert(isValid_); // cannot call in a non valid state. WriteBatchInternal::SetContents(batch, currentRecord_); + *seq = WriteBatchInternal::Sequence(batch); } Status TransactionLogIteratorImpl::status() { diff --git a/db/transaction_log_iterator_impl.h b/db/transaction_log_iterator_impl.h index 38b344f63..880032100 100644 --- a/db/transaction_log_iterator_impl.h +++ b/db/transaction_log_iterator_impl.h @@ -43,7 +43,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator { virtual Status status(); - virtual void GetBatch(WriteBatch* batch); + virtual void GetBatch(WriteBatch* batch, SequenceNumber* seq); private: const std::string& dbname_; diff --git a/include/leveldb/transaction_log_iterator.h b/include/leveldb/transaction_log_iterator.h index 8f46cac80..a4bb99aa7 100644 --- a/include/leveldb/transaction_log_iterator.h +++ b/include/leveldb/transaction_log_iterator.h @@ -26,8 +26,9 @@ class TransactionLogIterator { // Return the Error Status when the iterator is not Valid. virtual Status status() = 0; - // If valid return's the current write_batch. - virtual void GetBatch(WriteBatch* batch) = 0; + // If valid return's the current write_batch and the sequence number of the + // latest transaction contained in the batch. + virtual void GetBatch(WriteBatch* batch, SequenceNumber* seq) = 0; }; } // namespace leveldb