log_format.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. //
  10. // Log format information shared by reader and writer.
  11. // See ../doc/log_format.txt for more detail.
  12. #pragma once
  13. #include <cstdint>
  14. #include "rocksdb/rocksdb_namespace.h"
  15. namespace ROCKSDB_NAMESPACE {
  16. namespace log {
  17. enum RecordType : uint8_t {
  18. // Zero is reserved for preallocated files
  19. kZeroType = 0,
  20. kFullType = 1,
  21. // For fragments
  22. kFirstType = 2,
  23. kMiddleType = 3,
  24. kLastType = 4,
  25. // For recycled log files
  26. kRecyclableFullType = 5,
  27. kRecyclableFirstType = 6,
  28. kRecyclableMiddleType = 7,
  29. kRecyclableLastType = 8,
  30. // Compression Type
  31. kSetCompressionType = 9,
  32. // For all the values >= 10, the 1 bit indicates whether it's recyclable
  33. // User-defined timestamp sizes
  34. kUserDefinedTimestampSizeType = 10,
  35. kRecyclableUserDefinedTimestampSizeType = 11,
  36. // For WAL verification
  37. kPredecessorWALInfoType = 130,
  38. kRecyclePredecessorWALInfoType = 131,
  39. };
  40. // Unknown type of value with the 8-th bit set will be ignored
  41. constexpr uint8_t kRecordTypeSafeIgnoreMask = 1 << 7;
  42. constexpr uint8_t kMaxRecordType = kRecyclePredecessorWALInfoType;
  43. constexpr unsigned int kBlockSize = 32768;
  44. // Header is checksum (4 bytes), length (2 bytes), type (1 byte)
  45. constexpr int kHeaderSize = 4 + 2 + 1;
  46. // Recyclable header is checksum (4 bytes), length (2 bytes), type (1 byte),
  47. // log number (4 bytes).
  48. constexpr int kRecyclableHeaderSize = 4 + 2 + 1 + 4;
  49. } // namespace log
  50. } // namespace ROCKSDB_NAMESPACE