forked from UWQuickstep/quickstep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStorageBlockInfo.hpp
159 lines (135 loc) · 4.6 KB
/
StorageBlockInfo.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
#ifndef QUICKSTEP_STORAGE_STORAGE_BLOCK_INFO_HPP_
#define QUICKSTEP_STORAGE_STORAGE_BLOCK_INFO_HPP_
#include <climits>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>
#include <vector>
#include "utility/Macros.hpp"
namespace quickstep {
class TupleStorageSubBlock;
/** \addtogroup Storage
* @{
*/
/**
* @brief A globally unique identifier for a StorageBlock or StorageBlob.
* @note A block id whose domain is ZERO means an invalid or nonexistent block.
**/
typedef std::uint64_t block_id;
typedef std::uint16_t block_id_domain;
typedef std::uint64_t block_id_counter;
static constexpr block_id kInvalidBlockId = 0;
static constexpr int kBlockIdDomainLengthInDigits = std::numeric_limits<block_id_domain>::digits10;
static constexpr int kBlockIdCounterLengthInDigits = std::numeric_limits<block_id_counter>::digits10;
static constexpr block_id_domain kMaxDomain = static_cast<block_id_domain>(0xFFFF);
typedef std::vector<block_id> BlocksInPartition;
/**
* @brief All-static object that provides access to block_id.
**/
class BlockIdUtil {
public:
/**
* @brief Factory method to get a block id by its domain and counter.
*
* @param domain The domain of the desired block id.
* @param counter The counter of the desired block id.
* @return The block id set by its domain and counter.
**/
static inline block_id GetBlockId(const block_id_domain domain, const block_id_counter counter) {
block_id block = (static_cast<block_id>(domain) << kDomainShift)
| (static_cast<block_id>(counter) & kCounterMask);
return block;
}
/**
* @brief Get the domain of the given block id.
*
* @param block The block id.
* @return The domain of the block id.
**/
static inline block_id_domain Domain(const block_id block) {
return static_cast<block_id_domain>(block >> kDomainShift);
}
/**
* @brief Get the counter of the given block id.
*
* @param block The block id.
* @return The counter of the block id.
**/
static inline block_id_counter Counter(const block_id block) {
return static_cast<block_id_counter>(block & kCounterMask);
}
/**
* @brief Get the string format of the given block id.
*
* @param block The block id.
* @return The stringified the block id.
**/
static std::string ToString(const block_id block);
private:
// Undefined default constructor. Class is all-static and should not be
// instantiated.
BlockIdUtil();
static constexpr std::uint64_t kCounterMask = static_cast<std::uint64_t>(0xFFFFFFFFFFFFULL);
static constexpr unsigned kDomainShift = 48;
DISALLOW_COPY_AND_ASSIGN(BlockIdUtil);
};
/**
* @brief Identifies a single tuple within a StorageBlock.
*
* @note A negative value indicates an invalid/unset/nonexistent tuple.
**/
typedef int tuple_id;
const tuple_id kMaxTupleID = INT_MAX;
/**
* @brief Codes for the different implementations of TupleStorageSubBlock.
**/
enum TupleStorageSubBlockType {
kBasicColumnStore,
kCompressedPackedRowStore,
kCompressedColumnStore,
kSplitRowStore,
kNumTupleStorageSubBlockTypes // Not an actual TupleStorageSubBlockType, exists for counting purposes.
};
/**
* @brief Names corresponsing to TupleStorageSubBlockType.
* @note Defined out-of-line in StorageBlockInfo.cpp
**/
extern const char *kTupleStorageSubBlockTypeNames[];
/**
* @brief Codes for the different implementations of IndexSubBlock.
**/
enum IndexSubBlockType {
kCSBTree = 0,
kSMA,
kBloomFilter,
kBitWeavingV,
kBitWeavingH,
kNumIndexSubBlockTypes // Not an actual IndexSubBlockType, exists for counting purposes.
};
/**
* @brief Names corresponsing to IndexSubBlockType.
* @note Defined out-of-line in StorageBlockInfo.cpp
**/
extern const char *kIndexSubBlockTypeNames[];
/** @} */
} // namespace quickstep
#endif // QUICKSTEP_STORAGE_STORAGE_BLOCK_INFO_HPP_