Get cursor into a BTree node, creating decode cache from boundaries if needed
| 6084 | |
| 6085 | // Get cursor into a BTree node, creating decode cache from boundaries if needed |
| 6086 | inline BTreePage::BinaryTree::Cursor getCursor(const ArenaPage* page, |
| 6087 | const RedwoodRecordRef& lowerBound, |
| 6088 | const RedwoodRecordRef& upperBound) { |
| 6089 | |
| 6090 | Reference<BTreePage::BinaryTree::DecodeCache> cache; |
| 6091 | |
| 6092 | if (page->extra.valid()) { |
| 6093 | cache = page->extra.getReference<BTreePage::BinaryTree::DecodeCache>(); |
| 6094 | } else { |
| 6095 | cache = makeReference<BTreePage::BinaryTree::DecodeCache>(lowerBound, upperBound, m_pDecodeCacheMemory); |
| 6096 | |
| 6097 | debug_printf("Created DecodeCache for ptr=%p lower=%s upper=%s %s\n", |
| 6098 | page->data(), |
| 6099 | lowerBound.toString(false).c_str(), |
| 6100 | upperBound.toString(false).c_str(), |
| 6101 | ((BTreePage*)page->data()) |
| 6102 | ->toString("cursor", |
| 6103 | lowerBound.value.present() ? lowerBound.getChildPage() : BTreeNodeLinkRef(), |
| 6104 | -1, |
| 6105 | lowerBound, |
| 6106 | upperBound) |
| 6107 | .c_str()); |
| 6108 | |
| 6109 | // Store decode cache into page based on height |
| 6110 | if (((BTreePage*)page->data())->height >= SERVER_KNOBS->REDWOOD_DECODECACHE_REUSE_MIN_HEIGHT) { |
| 6111 | page->extra = cache; |
| 6112 | } |
| 6113 | } |
| 6114 | |
| 6115 | return BTreePage::BinaryTree::Cursor(cache, ((BTreePage*)page->mutateData())->tree()); |
| 6116 | } |
| 6117 | |
| 6118 | // Get cursor into a BTree node from a child link |
| 6119 | inline BTreePage::BinaryTree::Cursor getCursor(const ArenaPage* page, const BTreePage::BinaryTree::Cursor& link) { |