| 394 | |
| 395 | |
| 396 | UCHAR* IndexNode::writeNode(UCHAR* pagePointer, bool leafNode, bool withData) |
| 397 | { |
| 398 | /************************************** |
| 399 | * |
| 400 | * w r i t e N o d e |
| 401 | * |
| 402 | ************************************** |
| 403 | * |
| 404 | * Functional description |
| 405 | * Write a leaf/page node to the page by the |
| 406 | * given page_pointer. |
| 407 | * |
| 408 | **************************************/ |
| 409 | nodePointer = pagePointer; |
| 410 | |
| 411 | // AB: 2004-02-22 |
| 412 | // To allow as much as compression possible we |
| 413 | // store numbers per 7 bit and the 8-th bit tell us |
| 414 | // if we need to go on reading or we're done. |
| 415 | // Also for duplicate node entries (length and prefix |
| 416 | // are zero) we don't store the length and prefix |
| 417 | // information. This will save at least 2 bytes per node. |
| 418 | |
| 419 | if (!withData) |
| 420 | { |
| 421 | // First move data so we can't override it. |
| 422 | // For older structure node was always the same, but length |
| 423 | // from new structure depends on the values. |
| 424 | const USHORT offset = getNodeSize(leafNode) - length; |
| 425 | pagePointer += offset; // set pointer to right position |
| 426 | memmove(pagePointer, data, length); |
| 427 | pagePointer -= offset; // restore pointer to original position |
| 428 | } |
| 429 | |
| 430 | // Internal flags |
| 431 | UCHAR internalFlags = 0; |
| 432 | if (isEndLevel) { |
| 433 | internalFlags = BTN_END_LEVEL_FLAG; |
| 434 | } |
| 435 | else if (isEndBucket) { |
| 436 | internalFlags = BTN_END_BUCKET_FLAG; |
| 437 | } |
| 438 | else if (length == 0) |
| 439 | { |
| 440 | if (prefix == 0) { |
| 441 | internalFlags = BTN_ZERO_PREFIX_ZERO_LENGTH_FLAG; |
| 442 | } |
| 443 | else { |
| 444 | internalFlags = BTN_ZERO_LENGTH_FLAG; |
| 445 | } |
| 446 | } |
| 447 | else if (length == 1) { |
| 448 | internalFlags = BTN_ONE_LENGTH_FLAG; |
| 449 | } |
| 450 | |
| 451 | SINT64 number = recordNumber.getValue(); |
| 452 | if (number < 0) { |
| 453 | number = 0; |
no test coverage detected