log_format.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "rocksdb/rocksdb_namespace.h"
  14. namespace ROCKSDB_NAMESPACE {
  15. namespace log {
  16. enum RecordType {
  17. // Zero is reserved for preallocated files
  18. kZeroType = 0,
  19. kFullType = 1,
  20. // For fragments
  21. kFirstType = 2,
  22. kMiddleType = 3,
  23. kLastType = 4,
  24. // For recycled log files
  25. kRecyclableFullType = 5,
  26. kRecyclableFirstType = 6,
  27. kRecyclableMiddleType = 7,
  28. kRecyclableLastType = 8,
  29. };
  30. static const int kMaxRecordType = kRecyclableLastType;
  31. static const unsigned int kBlockSize = 32768;
  32. // Header is checksum (4 bytes), length (2 bytes), type (1 byte)
  33. static const int kHeaderSize = 4 + 2 + 1;
  34. // Recyclable header is checksum (4 bytes), length (2 bytes), type (1 byte),
  35. // log number (4 bytes).
  36. static const int kRecyclableHeaderSize = 4 + 2 + 1 + 4;
  37. } // namespace log
  38. } // namespace ROCKSDB_NAMESPACE