include/leveldb/table.h

filter: Statementstmt 100% 1 / 1 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 1 / 1 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/leveldb/env.h ↑ Summary port/atomic_pointer.h »
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_INCLUDE_TABLE_H_
6 #define STORAGE_LEVELDB_INCLUDE_TABLE_H_
7  
8 #include <stdint.h>
9 #include "leveldb/iterator.h"
10  
11 namespace leveldb {
12  
13 class Block;
14 class BlockHandle;
15 struct Options;
16 class RandomAccessFile;
17 struct ReadOptions;
18  
19 // A Table is a sorted map from strings to strings. Tables are
20 // immutable and persistent. A Table may be safely accessed from
21 // multiple threads without external synchronization.
22 class Table {
23 public:
24 // Attempt to open the table that is stored in bytes [0..file_size)
25 // of "file", and read the metadata entries necessary to allow
26 // retrieving data from the table.
27 //
28 // If successful, returns ok and sets "*table" to the newly opened
29 // table. The client should delete "*table" when no longer needed.
30 // If there was an error while initializing the table, sets "*table"
31 // to NULL and returns a non-ok status. Does not take ownership of
32 // "*source", but the client must ensure that "source" remains live
33 // for the duration of the returned table's lifetime.
34 //
35 // *file must remain live while this Table is in use.
36 static Status Open(const Options& options,
37 RandomAccessFile* file,
38 uint64_t file_size,
39 Table** table);
40  
41 ~Table();
42  
43 // Returns a new iterator over the table contents.
44 // The result of NewIterator() is initially invalid (caller must
45 // call one of the Seek methods on the iterator before using it).
46 Iterator* NewIterator(const ReadOptions&) const;
47  
48 // Given a key, return an approximate byte offset in the file where
49 // the data for that key begins (or would begin if the key were
50 // present in the file). The returned value is in terms of file
51 // bytes, and so includes effects like compression of the underlying data.
52 // E.g., the approximate offset of the last key in the table will
53 // be close to the file length.
54 uint64_t ApproximateOffsetOf(const Slice& key) const;
55  
56 private:
57 struct Rep;
58 Rep* rep_;
59  
60 1 explicit Table(Rep* rep) { rep_ = rep; }
61 static Iterator* BlockReader(void*, const ReadOptions&, const Slice&);
62  
63 // No copying allowed
64 Table(const Table&);
65 void operator=(const Table&);
66 };
67  
68 }
69  
70 #endif // STORAGE_LEVELDB_INCLUDE_TABLE_H_
« include/leveldb/env.h ↑ Summary port/atomic_pointer.h »