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

Function find_area_start_point

src/jrd/btr.cpp:4712–4933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4710
4711
4712static UCHAR* find_area_start_point(btree_page* bucket, const temporary_key* key,
4713 UCHAR* value,
4714 USHORT* return_prefix, bool descending,
4715 int retrieval, RecordNumber find_record_number)
4716{
4717/**************************************
4718 *
4719 * f i n d _ a r e a _ s t a r t _ p o i n t
4720 *
4721 **************************************
4722 *
4723 * Functional description
4724 * Locate and return a pointer to a start area.
4725 * The starting nodes for a area are
4726 * defined with jump nodes. A jump node
4727 * contains the prefix information for
4728 * a node at a specific offset.
4729 *
4730 **************************************/
4731 const bool useFindRecordNumber = (find_record_number != NO_VALUE);
4732 const bool leafPage = (bucket->btr_level == 0);
4733 const UCHAR* keyPointer = key->key_data;
4734 const UCHAR* const keyEnd = keyPointer + key->key_length;
4735
4736 // Retrieve jump information.
4737 UCHAR* pointer = bucket->btr_nodes;
4738 UCHAR n = bucket->btr_jump_count;
4739
4740 // Set begin of page as default.
4741 IndexJumpNode prevJumpNode;
4742 prevJumpNode.offset = BTR_SIZE + bucket->btr_jump_size;
4743 prevJumpNode.prefix = 0;
4744 prevJumpNode.length = 0;
4745
4746 temporary_key jumpKey;
4747 jumpKey.key_length = 0;
4748 jumpKey.key_flags = 0;
4749
4750 USHORT prefix = 0;
4751 USHORT testPrefix = 0;
4752
4753 while (n)
4754 {
4755 IndexJumpNode jumpNode;
4756 pointer = jumpNode.readJumpNode(pointer);
4757
4758 IndexNode node;
4759 node.readNode((UCHAR*) bucket + jumpNode.offset, leafPage);
4760
4761 // jumpKey will hold complete data off referenced node
4762 memcpy(jumpKey.key_data + jumpNode.prefix, jumpNode.data, jumpNode.length);
4763 memcpy(jumpKey.key_data + node.prefix, node.data, node.length);
4764 jumpKey.key_length = node.prefix + node.length;
4765
4766 keyPointer = key->key_data + jumpNode.prefix;
4767 const UCHAR* q = jumpKey.key_data + jumpNode.prefix;
4768 const UCHAR* const nodeEnd = jumpKey.key_data + jumpKey.key_length;
4769 bool done = false;

Callers 2

find_node_start_pointFunction · 0.85
find_pageFunction · 0.85

Calls 2

readJumpNodeMethod · 0.80
readNodeMethod · 0.80

Tested by

no test coverage detected