sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget(/translations/zh_CN/core-api/assoc_arraymodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/zh_TW/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/it_IT/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ja_JP/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/ko_KR/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget(/translations/sp_SP/core-api/assoc_arraymodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h(Generic Associative Array Implementationh]h(Generic Associative Array Implementation}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhB/var/lib/git/docbuild/linux/Documentation/core-api/assoc_array.rsthKubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(h[This associative array implementation is an object container with the following properties:h]h[This associative array implementation is an object container with the following properties:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhenumerated_list)}(hhh](h list_item)}(hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything). .. note:: Pointers to objects _must_ be zero in the least significant bit. h](h)}(hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything).h]hObjects are opaque pointers. The implementation does not care where they point (if anywhere) or what they point to (if anything).}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubhnote)}(h@Pointers to objects _must_ be zero in the least significant bit.h]h)}(hhh]h@Pointers to objects _must_ be zero in the least significant bit.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhNhNubh)}(hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects. h]h)}(hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects.h]hObjects do not need to contain linkage blocks for use by the array. This permits an object to be located in multiple arrays simultaneously. Rather, the array is made up of metadata blocks that point to objects.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(h``. The associative array is rooted on the following structure::h](hThe public API can be found in }(hj2hhhNhNubhliteral)}(h````h]h}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj2ubh>. The associative array is rooted on the following structure:}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK;hj!hhubh literal_block)}(h#struct assoc_array { ... };h]h#struct assoc_array { ... };}hjVsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jThhhK>hj!hhubh)}(hDThe code is selected by enabling ``CONFIG_ASSOCIATIVE_ARRAY`` with::h](h!The code is selected by enabling }(hjfhhhNhNubj;)}(h``CONFIG_ASSOCIATIVE_ARRAY``h]hCONFIG_ASSOCIATIVE_ARRAY}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjfubh with:}(hjfhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKBhj!hhubjU)}(h$./script/config -e ASSOCIATIVE_ARRAYh]h$./script/config -e ASSOCIATIVE_ARRAY}hjsbah}(h]h ]h"]h$]h&]jdjeuh1jThhhKDhj!hhubh)}(hhh](h)}(h Edit Scripth]h Edit Script}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKHubh)}(hXIThe insertion and deletion functions produce an 'edit script' that can later be applied to effect the changes without risking ``ENOMEM``. This retains the preallocated metadata blocks that will be installed in the internal tree and keeps track of the metadata blocks that will be removed from the tree when the script is applied.h](hThe insertion and deletion functions produce an ‘edit script’ that can later be applied to effect the changes without risking }(hjhhhNhNubj;)}(h ``ENOMEM``h]hENOMEM}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hjubh. This retains the preallocated metadata blocks that will be installed in the internal tree and keeps track of the metadata blocks that will be removed from the tree when the script is applied.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKJhjhhubh)}(hXThis is also used to keep track of dead blocks and dead objects after the script has been applied so that they can be freed later. The freeing is done after an RCU grace period has passed - thus allowing access functions to proceed under the RCU read lock.h]hXThis is also used to keep track of dead blocks and dead objects after the script has been applied so that they can be freed later. The freeing is done after an RCU grace period has passed - thus allowing access functions to proceed under the RCU read lock.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhjhhubh)}(hCThe script appears as outside of the API as a pointer of the type::h]hBThe script appears as outside of the API as a pointer of the type:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKUhjhhubjU)}(hstruct assoc_array_edit;h]hstruct assoc_array_edit;}hjsbah}(h]h ]h"]h$]h&]jdjeuh1jThhhKWhjhhubh)}(h4There are two functions for dealing with the script:h]h4There are two functions for dealing with the script:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjhhubh)}(hhh](h)}(hX<Apply an edit script:: void assoc_array_apply_edit(struct assoc_array_edit *edit); This will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to ``call_rcu()`` to free it and any dead stuff it points to. h](h)}(hApply an edit script::h]hApply an edit script:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubjU)}(h;void assoc_array_apply_edit(struct assoc_array_edit *edit);h]h;void assoc_array_apply_edit(struct assoc_array_edit *edit);}hjsbah}(h]h ]h"]h$]h&]jdjeuh1jThhhK]hjubh)}(hThis will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to ``call_rcu()`` to free it and any dead stuff it points to.h](hThis will perform the edit functions, interpolating various write barriers to permit accesses under the RCU read lock to continue. The edit script will then be passed to }(hj hhhNhNubj;)}(h``call_rcu()``h]h call_rcu()}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj ubh, to free it and any dead stuff it points to.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK_hjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXCancel an edit script:: void assoc_array_cancel_edit(struct assoc_array_edit *edit); This frees the edit script and all preallocated memory immediately. If this was for insertion, the new object is *not* released by this function, but must rather be released by the caller. h](h)}(hCancel an edit script::h]hCancel an edit script:}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjFubjU)}(h hhhNhNubj;)}(h``0``h]h0}(hjF hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj> ubh if no objects were in the array or else it will return the result of the last iterator function called. Iteration stops immediately if any call to the iteration function results in a non-zero return.}(hj> hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM-hjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hX.Find an object in an associative array:: void *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key); This walks through the array's internal tree directly to the object specified by the index key. This may be used on an array at the same time as the array is being modified, provided the RCU read lock is held. The function will return the object if found (and set ``*_type`` to the object type) or will return ``NULL`` if the object was not found. h](h)}(h(Find an object in an associative array::h]h'Find an object in an associative array:}(hjh hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM3hjd ubjU)}(hvoid *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);h]hvoid *assoc_array_find(const struct assoc_array *array, const struct assoc_array_ops *ops, const void *index_key);}hjv sbah}(h]h ]h"]h$]h&]jdjeuh1jThhhM5hjd ubh)}(h_This walks through the array's internal tree directly to the object specified by the index key.h]haThis walks through the array’s internal tree directly to the object specified by the index key.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjd ubh)}(hqThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held.h]hqThis may be used on an array at the same time as the array is being modified, provided the RCU read lock is held.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hjd ubh)}(hThe function will return the object if found (and set ``*_type`` to the object type) or will return ``NULL`` if the object was not found.h](h6The function will return the object if found (and set }(hj hhhNhNubj;)}(h ``*_type``h]h*_type}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj ubh$ to the object type) or will return }(hj hhhNhNubj;)}(h``NULL``h]hNULL}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj ubh if the object was not found.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM?hjd ubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjjhj j uh1hhjhhhhhMubeh}(h]access-functionsah ]h"]access functionsah$]h&]uh1hhj!hhhhhMubh)}(hhh](h)}(hIndex Key Formh]hIndex Key Form}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMDubh)}(hThe index key can be of any form, but since the algorithms aren't told how long the key is, it is strongly recommended that the index key includes its length very early on before any variation due to the length would have an effect on comparisons.h]hThe index key can be of any form, but since the algorithms aren’t told how long the key is, it is strongly recommended that the index key includes its length very early on before any variation due to the length would have an effect on comparisons.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMFhj hhubh)}(hThis will cause leaves with different length keys to scatter away from each other - and those with the same length keys to cluster together.h]hThis will cause leaves with different length keys to scatter away from each other - and those with the same length keys to cluster together.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMKhj hhubh)}(h~It is also recommended that the index key begin with a hash of the rest of the key to maximise scattering throughout keyspace.h]h~It is also recommended that the index key begin with a hash of the rest of the key to maximise scattering throughout keyspace.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhj hhubh)}(hIThe better the scattering, the wider and lower the internal tree will be.h]hIThe better the scattering, the wider and lower the internal tree will be.}(hj! hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMQhj hhubh)}(hPoor scattering isn't too much of a problem as there are shortcuts and nodes can contain mixtures of leaves and metadata pointers.h]hPoor scattering isn’t too much of a problem as there are shortcuts and nodes can contain mixtures of leaves and metadata pointers.}(hj/ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShj hhubh)}(hX;The index key is read in chunks of machine word. Each chunk is subdivided into one nibble (4 bits) per level, so on a 32-bit CPU this is good for 8 levels and on a 64-bit CPU, 16 levels. Unless the scattering is really poor, it is unlikely that more than one word of any particular index key will have to be used.h]hX;The index key is read in chunks of machine word. Each chunk is subdivided into one nibble (4 bits) per level, so on a 32-bit CPU this is good for 8 levels and on a 64-bit CPU, 16 levels. Unless the scattering is really poor, it is unlikely that more than one word of any particular index key will have to be used.}(hj= hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhj hhubeh}(h]index-key-formah ]h"]index key formah$]h&]uh1hhj!hhhhhMDubeh}(h]the-public-apiah ]h"]the public apiah$]h&]uh1hhhhhhhhK9ubh)}(hhh](h)}(hInternal Workingsh]hInternal Workings}(hj^ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj[ hhhhhM^ubh)}(hThe associative array data structure has an internal tree. This tree is constructed of two types of metadata blocks: nodes and shortcuts.h]hThe associative array data structure has an internal tree. This tree is constructed of two types of metadata blocks: nodes and shortcuts.}(hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM`hj[ hhubh)}(hGA node is an array of slots. Each slot can contain one of four things:h]hGA node is an array of slots. Each slot can contain one of four things:}(hjz hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchj[ hhubh bullet_list)}(hhh](h)}(h2A NULL pointer, indicating that the slot is empty.h]h)}(hj h]h2A NULL pointer, indicating that the slot is empty.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMehj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(h A pointer to an object (a leaf).h]h)}(hj h]h A pointer to an object (a leaf).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMfhj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(h&A pointer to a node at the next level.h]h)}(hj h]h&A pointer to a node at the next level.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubh)}(hA pointer to a shortcut. h]h)}(hA pointer to a shortcut.h]hA pointer to a shortcut.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhj ubah}(h]h ]h"]h$]h&]uh1hhj hhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1j hhhMehj[ hhubh)}(hhh](h)}(hBasic Internal Tree Layouth]hBasic Internal Tree Layout}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMlubh)}(hIgnoring shortcuts for the moment, the nodes form a multilevel tree. The index key space is strictly subdivided by the nodes in the tree and nodes occur on fixed levels. For example::h]hIgnoring shortcuts for the moment, the nodes form a multilevel tree. The index key space is strictly subdivided by the nodes in the tree and nodes occur on fixed levels. For example:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhj hhubjU)}(hX$Level: 0 1 2 3 =============== =============== =============== =============== NODE D NODE B NODE C +------>+---+ +------>+---+ +------>+---+ | | 0 | NODE A | | 0 | | | 0 | | +---+ +---+ | +---+ | +---+ | : : | 0 | | : : | : : | +---+ +---+ | +---+ | +---+ | | f | | 1 |---+ | 3 |---+ | 7 |---+ +---+ +---+ +---+ +---+ : : : : | 8 |---+ +---+ +---+ +---+ | NODE E | e |---+ | f | : : +------>+---+ +---+ | +---+ +---+ | 0 | | f | | | f | +---+ +---+ | +---+ : : | NODE F +---+ +------>+---+ | f | | 0 | NODE G +---+ +---+ +------>+---+ : : | | 0 | +---+ | +---+ | 6 |---+ : : +---+ +---+ : : | f | +---+ +---+ | f | +---+h]hX$Level: 0 1 2 3 =============== =============== =============== =============== NODE D NODE B NODE C +------>+---+ +------>+---+ +------>+---+ | | 0 | NODE A | | 0 | | | 0 | | +---+ +---+ | +---+ | +---+ | : : | 0 | | : : | : : | +---+ +---+ | +---+ | +---+ | | f | | 1 |---+ | 3 |---+ | 7 |---+ +---+ +---+ +---+ +---+ : : : : | 8 |---+ +---+ +---+ +---+ | NODE E | e |---+ | f | : : +------>+---+ +---+ | +---+ +---+ | 0 | | f | | | f | +---+ +---+ | +---+ : : | NODE F +---+ +------>+---+ | f | | 0 | NODE G +---+ +---+ +------>+---+ : : | | 0 | +---+ | +---+ | 6 |---+ : : +---+ +---+ : : | f | +---+ +---+ | f | +---+}hj sbah}(h]h ]h"]h$]h&]jdjeuh1jThhhMrhj hhubh)}(hIn the above example, there are 7 nodes (A-G), each with 16 slots (0-f). Assuming no other meta data nodes in the tree, the key space is divided thusly:h]hIn the above example, there are 7 nodes (A-G), each with 16 slots (0-f). Assuming no other meta data nodes in the tree, the key space is divided thusly:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh block_quote)}(h=========== ==== KEY PREFIX NODE =========== ==== 137* D 138* E 13[0-69-f]* C 1[0-24-f]* B e6* G e[0-57-f]* F [02-df]* A =========== ==== h]htable)}(hhh]htgroup)}(hhh](hcolspec)}(hhh]h}(h]h ]h"]h$]h&]colwidthK uh1j= hj: ubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hj: ubhthead)}(hhh]hrow)}(hhh](hentry)}(hhh]h)}(h KEY PREFIXh]h KEY PREFIX}(hjb hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj_ ubah}(h]h ]h"]h$]h&]uh1j] hjZ ubj^ )}(hhh]h)}(hNODEh]hNODE}(hjy hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjv ubah}(h]h ]h"]h$]h&]uh1j] hjZ ubeh}(h]h ]h"]h$]h&]uh1jX hjU ubah}(h]h ]h"]h$]h&]uh1jS hj: ubhtbody)}(hhh](jY )}(hhh](j^ )}(hhh]h)}(h137*h]h137*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hDh]hD}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h138*h]h138*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hEh]hE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h 13[0-69-f]*h]h 13[0-69-f]*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hCh]hC}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj& ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h 1[0-24-f]*h]h 1[0-24-f]*}(hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjF ubah}(h]h ]h"]h$]h&]uh1j] hjC ubj^ )}(hhh]h)}(hBh]hB}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj] ubah}(h]h ]h"]h$]h&]uh1j] hjC ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(he6*h]he6*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj} ubah}(h]h ]h"]h$]h&]uh1j] hjz ubj^ )}(hhh]h)}(hGh]hG}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hjz ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h e[0-57-f]*h]h e[0-57-f]*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hFh]hF}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h[02-df]*h]h[02-df]*}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hAh]hA}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubeh}(h]h ]h"]h$]h&]uh1j hj: ubeh}(h]h ]h"]h$]h&]colsKuh1j8 hj5 ubah}(h]h ]h"]h$]h&]uh1j3 hj/ ubah}(h]h ]h"]h$]h&]uh1j- hhhMhj hhubh)}(hdSo, for instance, keys with the following example index keys will be found in the appropriate nodes:h]hdSo, for instance, keys with the following example index keys will be found in the appropriate nodes:}(hj8 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj. )}(hX=============== ======= ==== INDEX KEY PREFIX NODE =============== ======= ==== 13694892892489 13 C 13795289025897 137 D 13889dde88793 138 E 138bbb89003093 138 E 1394879524789 12 C 1458952489 1 B 9431809de993ba \- A b4542910809cd \- A e5284310def98 e F e68428974237 e6 G e7fffcbd443 e F f3842239082 \- A =============== ======= ==== h]j4 )}(hhh]j9 )}(hhh](j> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjM ubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjM ubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjM ubjT )}(hhh]jY )}(hhh](j^ )}(hhh]h)}(h INDEX KEYh]h INDEX KEY}(hjw hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjt ubah}(h]h ]h"]h$]h&]uh1j] hjq ubj^ )}(hhh]h)}(hPREFIXh]hPREFIX}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hjq ubj^ )}(hhh]h)}(hNODEh]hNODE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hjq ubeh}(h]h ]h"]h$]h&]uh1jX hjn ubah}(h]h ]h"]h$]h&]uh1jS hjM ubj )}(hhh](jY )}(hhh](j^ )}(hhh]h)}(h13694892892489h]h13694892892489}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(h13h]h13}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubj^ )}(hhh]h)}(hj+ h]hC}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j] hj ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h13795289025897h]h13795289025897}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h137h]h137}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/ubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hD}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjFubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h 13889dde88793h]h 13889dde88793}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjeubah}(h]h ]h"]h$]h&]uh1j] hjbubj^ )}(hhh]h)}(h138h]h138}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj|ubah}(h]h ]h"]h$]h&]uh1j] hjbubj^ )}({hhh]h)}(hj h]hE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjbubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h138bbb89003093h]h138bbb89003093}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h138h]h138}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h 1394879524789h]h 1394879524789}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h12h]h12}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj+ h]hC}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj-ubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h 1458952489h]h 1458952489}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjLubah}(h]h ]h"]h$]h&]uh1j] hjIubj^ )}(hhh]h)}(h1h]h1}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubah}(h]h ]h"]h$]h&]uh1j] hjIubj^ )}(hhh]h)}(hjb h]hB}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjzubah}(h]h ]h"]h$]h&]uh1j] hjIubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h9431809de993bah]h9431809de993ba}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h\-h]h-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h b4542910809cdh]h b4542910809cd}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h\-h]h-}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h e5284310def98h]h e5284310def98}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj3ubah}(h]h ]h"]h$]h&]uh1j] hj0ubj^ )}(hhh]h)}(heh]he}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjJubah}(h]h ]h"]h$]h&]uh1j] hj0ubj^ )}(hhh]h)}(hj h]hF}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjaubah}(h]h ]h"]h$]h&]uh1j] hj0ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h e68428974237h]h e68428974237}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hj}ubj^ )}(hhh]h)}(he6h]he6}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hj}ubj^ )}(hhh]h)}(hj h]hG}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hj}ubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h e7fffcbd443h]h e7fffcbd443}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hjOh]he}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubjY )}(hhh](j^ )}(hhh]h)}(h f3842239082h]h f3842239082}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h\-h]h-}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj0ubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hj h]hA}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjGubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj ubeh}(h]h ]h"]h$]h&]uh1j hjM ubeh}(h]h ]h"]h$]h&]colsKuh1j8 hjJ ubah}(h]h ]h"]h$]h&]uh1j3 hjF ubah}(h]h ]h"]h$]h&]uh1j- hhhMhj hhubh)}(hTo save memory, if a node can hold all the leaves in its portion of keyspace, then the node will have all those leaves in it and will not have any metadata pointers - even if some of those leaves would like to be in the same slot.h]hTo save memory, if a node can hold all the leaves in its portion of keyspace, then the node will have all those leaves in it and will not have any metadata pointers - even if some of those leaves would like to be in the same slot.}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hXA node can contain a heterogeneous mix of leaves and metadata pointers. Metadata pointers must be in the slots that match their subdivisions of key space. The leaves can be in any slot not occupied by a metadata pointer. It is guaranteed that none of the leaves in a node will match a slot occupied by a metadata pointer. If the metadata pointer is there, any leaf whose key matches the metadata key prefix must be in the subtree that the metadata pointer points to.h]hXA node can contain a heterogeneous mix of leaves and metadata pointers. Metadata pointers must be in the slots that match their subdivisions of key space. The leaves can be in any slot not occupied by a metadata pointer. It is guaranteed that none of the leaves in a node will match a slot occupied by a metadata pointer. If the metadata pointer is there, any leaf whose key matches the metadata key prefix must be in the subtree that the metadata pointer points to.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(h=In the above example list of index keys, node A will contain:h]h=In the above example list of index keys, node A will contain:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj. )}(hXS==== =============== ================== SLOT CONTENT INDEX KEY (PREFIX) ==== =============== ================== 1 PTR TO NODE B 1* any LEAF 9431809de993ba any LEAF b4542910809cd e PTR TO NODE F e* any LEAF f3842239082 ==== =============== ================== h]j4 )}(hhh]j9 )}(hhh](j> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubjT )}(hhh]jY )}(hhh](j^ )}(hhh]h)}(hSLOTh]hSLOT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hCONTENTh]hCONTENT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hINDEX KEY (PREFIX)h]hINDEX KEY (PREFIX)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hjubah}(h]h ]h"]h$]h&]uh1jS hjubj )}(hhh](jY )}(hhh](j^ )}(hhh]h)}(hjhh]h1}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj+ubah}(h]h ]h"]h$]h&]uh1j] hj(ubj^ )}(hhh]h)}(h PTR TO NODE Bh]h PTR TO NODE B}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjAubah}(h]h ]h"]h$]h&]uh1j] hj(ubj^ )}(hhh]h)}(h1*h]h1*}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjXubah}(h]h ]h"]h$]h&]uh1j] hj(ubeh}(h]h ]h"]h$]h&]uh1jX hj%ubjY )}(hhh](j^ )}(hhh]h)}(hanyh]hany}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjxubah}(h]h ]h"]h$]h&]uh1j] hjuubj^ )}(hhh]h)}(hLEAFh]hLEAF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjuubj^ )}(hhh]h)}(h9431809de993bah]h9431809de993ba}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjuubeh}(h]h ]h"]h$]h&]uh1jX hj%ubjY )}(hhh](j^ )}(hhh]h)}(hanyh]hany}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hLEAFh]hLEAF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h b4542910809cdh]h b4542910809cd}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj%ubjY )}(hhh](j^ )}(hhh]h)}(hjOh]he}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h PTR TO NODE Fh]h PTR TO NODE F}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj*ubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(he*h]he*}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjAubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hj%ubjY )}(hhh](j^ )}(hhh]h)}(hanyh]hany}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjaubah}(h]h ]h"]h$]h&]uh1j] hj^ubj^ )}(hhh]h)}(hLEAFh]hLEAF}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjxubah}(h]h ]h"]h$]h&]uh1j] hj^ubj^ )}(hhh]h)}(h f3842239082h]h f3842239082}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hj^ubeh}(h]h ]h"]h$]h&]uh1jX hj%ubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]colsKuh1j8 hjubah}(h]h ]h"]h$]h&]uh1j3 hjubah}(h]h ]h"]h$]h&]uh1j- hhhMhj hhubh)}(h and node B:h]h and node B:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj. )}(h==== =============== ================== SLOT CONTENT INDEX KEY (PREFIX) ==== =============== ================== 3 PTR TO NODE C 13* any LEAF 1458952489 ==== =============== ================== h]j4 )}(hhh]j9 )}(hhh](j> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubj> )}(hhh]h}(h]h ]h"]h$]h&]colwidthKuh1j= hjubjT )}(hhh]jY )}(hhh](j^ )}(hhh]h)}(hSLOTh]hSLOT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hCONTENTh]hCONTENT}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hINDEX KEY (PREFIX)h]hINDEX KEY (PREFIX)}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/ubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hjubah}(h]h ]h"]h$]h&]uh1jS hjubj )}(hhh](jY )}(hhh](j^ )}(hhh]h)}(h3h]h3}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjXubah}(h]h ]h"]h$]h&]uh1j] hjUubj^ )}(hhh]h)}(h PTR TO NODE Ch]h PTR TO NODE C}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjoubah}(h]h ]h"]h$]h&]uh1j] hjUubj^ )}(hhh]h)}(h13*h]h13*}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjUubeh}(h]h ]h"]h$]h&]uh1jX hjRubjY )}(hhh](j^ )}(hhh]h)}(hanyh]hany}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(hLEAFh]hLEAF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubj^ )}(hhh]h)}(h 1458952489h]h 1458952489}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j] hjubeh}(h]h ]h"]h$]h&]uh1jX hjRubeh}(h]h ]h"]h$]h&]uh1j hjubeh}(h]h ]h"]h$]h&]colsKuh1j8 hjubah}(h]h ]h"]h$]h&]uh1j3 hjubah}(h]h ]h"]h$]h&]uh1j- hhhMhj hhubeh}(h]basic-internal-tree-layoutah ]h"]basic internal tree layoutah$]h&]uh1hhj[ hhhhhMlubh)}(hhh](h)}(h Shortcutsh]h Shortcuts}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hShortcuts are metadata records that jump over a piece of keyspace. A shortcut is a replacement for a series of single-occupancy nodes ascending through the levels. Shortcuts exist to save memory and to speed up traversal.h]hShortcuts are metadata records that jump over a piece of keyspace. A shortcut is a replacement for a series of single-occupancy nodes ascending through the levels. Shortcuts exist to save memory and to speed up traversal.}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX6It is possible for the root of the tree to be a shortcut - say, for example, the tree contains at least 17 nodes all with key prefix ``1111``. The insertion algorithm will insert a shortcut to skip over the ``1111`` keyspace in a single bound and get to the fourth level where these actually become different.h](hIt is possible for the root of the tree to be a shortcut - say, for example, the tree contains at least 17 nodes all with key prefix }(hj1hhhNhNubj;)}(h``1111``h]h1111}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj1ubhC. The insertion algorithm will insert a shortcut to skip over the }(hj1hhhNhNubj;)}(h``1111``h]h1111}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1j:hj1ubh^ keyspace in a single bound and get to the fourth level where these actually become different.}(hj1hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h] shortcutsah ]h"] shortcutsah$]h&]uh1hhj[ hhhhhMubh)}(hhh](h)}(hSplitting And Collapsing Nodesh]hSplitting And Collapsing Nodes}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjkhhhhhMubh)}(hXKEach node has a maximum capacity of 16 leaves and metadata pointers. If the insertion algorithm finds that it is trying to insert a 17th object into a node, that node will be split such that at least two leaves that have a common key segment at that level end up in a separate node rooted on that slot for that common key segment.h]hXKEach node has a maximum capacity of 16 leaves and metadata pointers. If the insertion algorithm finds that it is trying to insert a 17th object into a node, that node will be split such that at least two leaves that have a common key segment at that level end up in a separate node rooted on that slot for that common key segment.}(hj|hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjkhhubh)}(hIf the leaves in a full node and the leaf that is being inserted are sufficiently similar, then a shortcut will be inserted into the tree.h]hIf the leaves in a full node and the leaf that is being inserted are sufficiently similar, then a shortcut will be inserted into the tree.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjkhhubh)}(hWhen the number of objects in the subtree rooted at a node falls to 16 or fewer, then the subtree will be collapsed down to a single node - and this will ripple towards the root if possible.h]hWhen the number of objects in the subtree rooted at a node falls to 16 or fewer, then the subtree will be collapsed down to a single node - and this will ripple towards the root if possible.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjkhhubeh}(h]splitting-and-collapsing-nodesah ]h"]splitting and collapsing nodesah$]h&]uh1hhj[ hhhhhMubh)}(hhh](h)}(hNon-Recursive Iterationh]hNon-Recursive Iteration}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hX"Each node and shortcut contains a back pointer to its parent and the number of slot in that parent that points to it. None-recursive iteration uses these to proceed rootwards through the tree, going to the parent node, slot N + 1 to make sure progress is made without the need for a stack.h]hX"Each node and shortcut contains a back pointer to its parent and the number of slot in that parent that points to it. None-recursive iteration uses these to proceed rootwards through the tree, going to the parent node, slot N + 1 to make sure progress is made without the need for a stack.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hMThe backpointers, however, make simultaneous alteration and iteration tricky.h]hMThe backpointers, however, make simultaneous alteration and iteration tricky.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]non-recursive-iterationah ]h"]non-recursive iterationah$]h&]uh1hhj[ hhhhhMubh)}(hhh](h)}(h%Simultaneous Alteration And Iterationh]h%Simultaneous Alteration And Iteration}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(h(There are a number of cases to consider:h]h(There are a number of cases to consider:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hhh](h)}(hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don't change otherwise. An old leaf won't be freed until after the RCU grace period. h]h)}(hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don't change otherwise. An old leaf won't be freed until after the RCU grace period.h]hSimple insert/replace. This involves simply replacing a NULL or old matching leaf pointer with the pointer to the new leaf after a barrier. The metadata blocks don’t change otherwise. An old leaf won’t be freed until after the RCU grace period.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don't change otherwise. The old leaf won't be freed until after the RCU grace period. h]h)}(hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don't change otherwise. The old leaf won't be freed until after the RCU grace period.h]hSimple delete. This involves just clearing an old matching leaf. The metadata blocks don’t change otherwise. The old leaf won’t be freed until after the RCU grace period.}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXInsertion replacing part of a subtree that we haven't yet entered. This may involve replacement of part of that subtree - but that won't affect the iteration as we won't have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change). h]h)}(hXInsertion replacing part of a subtree that we haven't yet entered. This may involve replacement of part of that subtree - but that won't affect the iteration as we won't have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change).h]hX#Insertion replacing part of a subtree that we haven’t yet entered. This may involve replacement of part of that subtree - but that won’t affect the iteration as we won’t have reached the pointer to it yet and the ancestry blocks are not replaced (the layout of those does not change).}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj5ubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXInsertion replacing nodes that we're actively processing. This isn't a problem as we've passed the anchoring pointer and won't switch onto the new layout until we follow the back pointers - at which point we've already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers). We might, however, re-see some leaves that have been split out into a new branch that's in a slot further along than we were at. h](h)}(hX^Insertion replacing nodes that we're actively processing. This isn't a problem as we've passed the anchoring pointer and won't switch onto the new layout until we follow the back pointers - at which point we've already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers).h]hXhInsertion replacing nodes that we’re actively processing. This isn’t a problem as we’ve passed the anchoring pointer and won’t switch onto the new layout until we follow the back pointers - at which point we’ve already examined the leaves in the replaced node (we iterate over all the leaves in a node before following any of its metadata pointers).}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjMubh)}(hWe might, however, re-see some leaves that have been split out into a new branch that's in a slot further along than we were at.h]hWe might, however, re-see some leaves that have been split out into a new branch that’s in a slot further along than we were at.}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjMubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hInsertion replacing nodes that we're processing a dependent branch of. This won't affect us until we follow the back pointers. Similar to (4). h]h)}(hInsertion replacing nodes that we're processing a dependent branch of. This won't affect us until we follow the back pointers. Similar to (4).h]hInsertion replacing nodes that we’re processing a dependent branch of. This won’t affect us until we follow the back pointers. Similar to (4).}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjsubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hXUDeletion collapsing a branch under us. This doesn't affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn't process it a second time as we'll go back to slot + 1. h]h)}(hXTDeletion collapsing a branch under us. This doesn't affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn't process it a second time as we'll go back to slot + 1.h]hXZDeletion collapsing a branch under us. This doesn’t affect us because the back pointers will get us back to the parent of the new node before we could see the new node. The entire collapsed subtree is thrown away unchanged - and will still be rooted on the same slot, so we shouldn’t process it a second time as we’ll go back to slot + 1.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1hhjhhhhhNubeh}(h]h ]h"]h$]h&]jjjhj j uh1hhjhhhhhMubh)}(hXxUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too. However, when we're changing a shortcut into a node this isn't a problem as shortcuts only have one slot and so the parent slot number isn't used when traversing backwards over one. This means that it's okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.h](h)}(hXUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too.h]hXUnder some circumstances, we need to simultaneously change the parent pointer and the parent slot pointer on a node (say, for example, we inserted another node before it and moved it up a level). We cannot do this without locking against a read - so we have to replace that node too.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hjubh)}(hXZHowever, when we're changing a shortcut into a node this isn't a problem as shortcuts only have one slot and so the parent slot number isn't used when traversing backwards over one. This means that it's okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.h]hXbHowever, when we’re changing a shortcut into a node this isn’t a problem as shortcuts only have one slot and so the parent slot number isn’t used when traversing backwards over one. This means that it’s okay to change the slot number first - provided suitable barriers are used to make sure the parent slot number is read after the back pointer.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM,hjubeh}(h]h ]h"]h$]h&]uh1hhjhhhhhNubh)}(hObsolete blocks and leaves are freed up after an RCU grace period has passed, so as long as anyone doing walking or iteration holds the RCU read lock, the old superstructure should not go away on them.h]hObsolete blocks and leaves are freed up after an RCU grace period has passed, so as long as anyone doing walking or iteration holds the RCU read lock, the old superstructure should not go away on them.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM2hjhhubeh}(h]%simultaneous-alteration-and-iterationah ]h"]%simultaneous alteration and iterationah$]h&]uh1hhj[ hhhhhMubeh}(h]internal-workingsah ]h"]internal workingsah$]h&]uh1hhhhhhhhM^ubeh}(h](generic-associative-array-implementationah ]h"](generic associative array implementationah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksj] footnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(jjjjjX jU jjjujrjjj j jP jM jjjj jhjejjjjjju nametypes}(jjjX jjujj jP jjjhjjjuh}(jhjhjU j!jjjrjjjxj jjM j jj[ j j jejjjkjjjju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]hsystem_message)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "4" (ordinal 4)h]h>Enumerated list start value not ordinal-1: “4” (ordinal 4)}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj{ubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1jyhjxhhhhhKubatransform_messages] transformerN include_log] decorationNhhub.