小组成员:10215300402-朱维清 & 10222140408 谷杰
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

48 linhas
1.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_DB_LOG_WRITER_H_
  5. #define STORAGE_LEVELDB_DB_LOG_WRITER_H_
  6. #include <stdint.h>
  7. #include "db/log_format.h"
  8. #include "leveldb/slice.h"
  9. #include "leveldb/status.h"
  10. namespace leveldb {
  11. class WritableFile;
  12. namespace log {
  13. class Writer {
  14. public:
  15. // Create a writer that will append data to "*dest".
  16. // "*dest" must be initially empty.
  17. // "*dest" must remain live while this Writer is in use.
  18. explicit Writer(WritableFile* dest);
  19. ~Writer();
  20. Status AddRecord(const Slice& slice);
  21. private:
  22. WritableFile* dest_;
  23. int block_offset_; // Current offset in block
  24. // crc32c values for all supported record types. These are
  25. // pre-computed to reduce the overhead of computing the crc of the
  26. // record type stored in the header.
  27. uint32_t type_crc_[kMaxRecordType + 1];
  28. Status EmitPhysicalRecord(RecordType type, const char* ptr, size_t length);
  29. // No copying allowed
  30. Writer(const Writer&);
  31. void operator=(const Writer&);
  32. };
  33. }
  34. }
  35. #endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_