作者: 谢瑞阳 10225101483 徐翔宇 10225101535
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

48 rindas
1.3 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. } // namespace log
  34. } // namespace leveldb
  35. #endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_