~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/leveldb/table/block_builder.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2
 
// Use of this source code is governed by a BSD-style license that can be
3
 
// found in the LICENSE file. See the AUTHORS file for names of contributors.
4
 
 
5
 
#ifndef STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_
6
 
#define STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_
7
 
 
8
 
#include <vector>
9
 
 
10
 
#include <stdint.h>
11
 
#include "leveldb/slice.h"
12
 
 
13
 
namespace leveldb {
14
 
 
15
 
struct Options;
16
 
 
17
 
class BlockBuilder {
18
 
 public:
19
 
  explicit BlockBuilder(const Options* options);
20
 
 
21
 
  // Reset the contents as if the BlockBuilder was just constructed.
22
 
  void Reset();
23
 
 
24
 
  // REQUIRES: Finish() has not been callled since the last call to Reset().
25
 
  // REQUIRES: key is larger than any previously added key
26
 
  void Add(const Slice& key, const Slice& value);
27
 
 
28
 
  // Finish building the block and return a slice that refers to the
29
 
  // block contents.  The returned slice will remain valid for the
30
 
  // lifetime of this builder or until Reset() is called.
31
 
  Slice Finish();
32
 
 
33
 
  // Returns an estimate of the current (uncompressed) size of the block
34
 
  // we are building.
35
 
  size_t CurrentSizeEstimate() const;
36
 
 
37
 
  // Return true iff no entries have been added since the last Reset()
38
 
  bool empty() const {
39
 
    return buffer_.empty();
40
 
  }
41
 
 
42
 
 private:
43
 
  const Options*        options_;
44
 
  std::string           buffer_;      // Destination buffer
45
 
  std::vector<uint32_t> restarts_;    // Restart points
46
 
  int                   counter_;     // Number of entries emitted since restart
47
 
  bool                  finished_;    // Has Finish() been called?
48
 
  std::string           last_key_;
49
 
 
50
 
  // No copying allowed
51
 
  BlockBuilder(const BlockBuilder&);
52
 
  void operator=(const BlockBuilder&);
53
 
};
54
 
 
55
 
}  // namespace leveldb
56
 
 
57
 
#endif  // STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_