From c4548d5f1f46645d996c7640d591397769ccbaf4 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Mon, 13 Jan 2014 15:01:34 -0800 Subject: [PATCH] WriteBatch to provide a way for user to query data size directly and only return constant reference of data in Data() Summary: WriteBatch::Data() now is easily to be misuse by users. Also, there is no cheap way for user of WriteBatch to know the data size accumulated. This patch fix the problem by: (1) return a constant reference to Data() so it's obvious to caller what it means. (2) add a function to return data size directly Test Plan: make all check Reviewers: haobo, igor, kailiu Reviewed By: kailiu CC: zshao, leveldb Differential Revision: https://reviews.facebook.net/D15123 --- include/rocksdb/write_batch.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/rocksdb/write_batch.h b/include/rocksdb/write_batch.h index 798807045..30abead50 100644 --- a/include/rocksdb/write_batch.h +++ b/include/rocksdb/write_batch.h @@ -88,7 +88,10 @@ class WriteBatch { Status Iterate(Handler* handler) const; // Retrieve the serialized version of this batch. - std::string Data() { return rep_; } + std::string Data() const { return rep_; } + + // Retrieve data size of the batch. + size_t GetDataSize() const { return rep_.size(); } // Returns the number of updates in the batch int Count() const;