作者: 韩晨旭 10225101440 李畅 10225102463
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
814 B

  1. #ifndef VTABLE_BUILDER_H
  2. #define VTABLE_BUILDER_H
  3. #include "leveldb/options.h"
  4. #include "leveldb/slice.h"
  5. #include "table/vtable_format.h"
  6. #include "util/coding.h"
  7. namespace leveldb {
  8. class VTableBuilder {
  9. public:
  10. VTableBuilder(const Options& options, WritableFile* file);
  11. // Add a record to the vTable
  12. void Add(const VTableRecord& record, VTableHandle* handle);
  13. // Builder status, return non-ok iff some error occurs
  14. Status status() const { return status_; }
  15. // Finish building the vTable
  16. Status Finish();
  17. // Abandon building the vTable
  18. void Abandon();
  19. private:
  20. bool ok() const { return status().ok(); }
  21. WritableFile* file_;
  22. uint64_t file_size_{0};
  23. Status status_;
  24. RecordEncoder encoder_;
  25. };
  26. } // namespace leveldb
  27. #endif //VTABLE_BUILDER_H