Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

67 righe
2.2 KiB

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