提交 2ba866e0 编写于 作者: A Abhishek Kona

GetSequence API in write batch.

Summary:
WriteBatch is now used by the GetUpdatesSinceAPI. This API is external
and will be used by the rocks server. Rocks Server and others will need
to know about the Sequence Number in the WriteBatch. This public method
will allow for that.

Test Plan: make all check.

Reviewers: dhruba

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D7293
上级 d0a30935
......@@ -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, &current);
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, &current);
ASSERT_TRUE(current > lastSequence);
lastSequence = current;
ASSERT_TRUE(iter->status().ok());
......
......@@ -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() {
......
......@@ -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_;
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册