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