1*9507f98cSAndroid Build Coastguard Worker // Copyright (c) 2011 The LevelDB Authors. All rights reserved. 2*9507f98cSAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*9507f98cSAndroid Build Coastguard Worker // found in the LICENSE file. See the AUTHORS file for names of contributors. 4*9507f98cSAndroid Build Coastguard Worker 5*9507f98cSAndroid Build Coastguard Worker #ifndef STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 6*9507f98cSAndroid Build Coastguard Worker #define STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 7*9507f98cSAndroid Build Coastguard Worker 8*9507f98cSAndroid Build Coastguard Worker #include "db/dbformat.h" 9*9507f98cSAndroid Build Coastguard Worker #include "leveldb/write_batch.h" 10*9507f98cSAndroid Build Coastguard Worker 11*9507f98cSAndroid Build Coastguard Worker namespace leveldb { 12*9507f98cSAndroid Build Coastguard Worker 13*9507f98cSAndroid Build Coastguard Worker class MemTable; 14*9507f98cSAndroid Build Coastguard Worker 15*9507f98cSAndroid Build Coastguard Worker // WriteBatchInternal provides static methods for manipulating a 16*9507f98cSAndroid Build Coastguard Worker // WriteBatch that we don't want in the public WriteBatch interface. 17*9507f98cSAndroid Build Coastguard Worker class WriteBatchInternal { 18*9507f98cSAndroid Build Coastguard Worker public: 19*9507f98cSAndroid Build Coastguard Worker // Return the number of entries in the batch. 20*9507f98cSAndroid Build Coastguard Worker static int Count(const WriteBatch* batch); 21*9507f98cSAndroid Build Coastguard Worker 22*9507f98cSAndroid Build Coastguard Worker // Set the count for the number of entries in the batch. 23*9507f98cSAndroid Build Coastguard Worker static void SetCount(WriteBatch* batch, int n); 24*9507f98cSAndroid Build Coastguard Worker 25*9507f98cSAndroid Build Coastguard Worker // Return the sequence number for the start of this batch. 26*9507f98cSAndroid Build Coastguard Worker static SequenceNumber Sequence(const WriteBatch* batch); 27*9507f98cSAndroid Build Coastguard Worker 28*9507f98cSAndroid Build Coastguard Worker // Store the specified number as the sequence number for the start of 29*9507f98cSAndroid Build Coastguard Worker // this batch. 30*9507f98cSAndroid Build Coastguard Worker static void SetSequence(WriteBatch* batch, SequenceNumber seq); 31*9507f98cSAndroid Build Coastguard Worker Contents(const WriteBatch * batch)32*9507f98cSAndroid Build Coastguard Worker static Slice Contents(const WriteBatch* batch) { return Slice(batch->rep_); } 33*9507f98cSAndroid Build Coastguard Worker ByteSize(const WriteBatch * batch)34*9507f98cSAndroid Build Coastguard Worker static size_t ByteSize(const WriteBatch* batch) { return batch->rep_.size(); } 35*9507f98cSAndroid Build Coastguard Worker 36*9507f98cSAndroid Build Coastguard Worker static void SetContents(WriteBatch* batch, const Slice& contents); 37*9507f98cSAndroid Build Coastguard Worker 38*9507f98cSAndroid Build Coastguard Worker static Status InsertInto(const WriteBatch* batch, MemTable* memtable); 39*9507f98cSAndroid Build Coastguard Worker 40*9507f98cSAndroid Build Coastguard Worker static void Append(WriteBatch* dst, const WriteBatch* src); 41*9507f98cSAndroid Build Coastguard Worker }; 42*9507f98cSAndroid Build Coastguard Worker 43*9507f98cSAndroid Build Coastguard Worker } // namespace leveldb 44*9507f98cSAndroid Build Coastguard Worker 45*9507f98cSAndroid Build Coastguard Worker #endif // STORAGE_LEVELDB_DB_WRITE_BATCH_INTERNAL_H_ 46