MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / getNodeSize

Method getNodeSize

src/jrd/btn.cpp:175–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173
174
175USHORT IndexNode::getNodeSize(bool leafNode) const
176{
177/**************************************
178 *
179 * g e t N o d e S i z e
180 *
181 **************************************
182 *
183 * Functional description
184 * Return the size needed to store
185 * this node.
186 *
187 **************************************/
188 USHORT result = 0;
189
190 // Determine flags
191 UCHAR internalFlags = 0;
192 if (isEndLevel) {
193 internalFlags = BTN_END_LEVEL_FLAG;
194 }
195 else if (isEndBucket) {
196 internalFlags = BTN_END_BUCKET_FLAG;
197 }
198 else if (length == 0)
199 {
200 if (prefix == 0) {
201 internalFlags = BTN_ZERO_PREFIX_ZERO_LENGTH_FLAG;
202 }
203 else {
204 internalFlags = BTN_ZERO_LENGTH_FLAG;
205 }
206 }
207 else if (length == 1) {
208 internalFlags = BTN_ONE_LENGTH_FLAG;
209 }
210
211 // Store internal flags + 5 bits from number
212 SINT64 number = recordNumber.getValue();
213 if (number < 0) {
214 number = 0;
215 }
216 result++;
217 // If this is a END_LEVEL marker then we're done
218 if (isEndLevel) {
219 return result;
220 }
221
222 number >>= 5;
223 // Get size for storing remaining bits for number
224 // 5 bytes should be enough to fit remaining 34 bits of record number
225 if (number & QUADCONST(0xFFF0000000)) {
226 result += 5;
227 }
228 else if (number & QUADCONST(0xFFFFE00000)) {
229 result += 4;
230 }
231 else if (number & QUADCONST(0xFFFFFFC000)) {
232 result += 3;

Callers 2

fast_loadFunction · 0.80
insert_nodeFunction · 0.80

Calls 1

getValueMethod · 0.45

Tested by

no test coverage detected