Definition: | object data = getd_by_index(integer node, integer tid=1) |
Description: |
Retrieve the data corresponding to the specified node index, a result from getd_index().
tid should, fairly obviously, always match the tid that was passed to getd_index(), if any. |
Comments: |
If there is no default value that getd() can return to signify a non-existent key, you
must test whether the result of getd_index() is zero, and if not that result can be
used (quickly, without another search) to retrieve the associated data using getd_by_index().
Obviously, you should not hang on to the results from getd_index() for very long; after several deld()/setd() that node index could easily end up on a free list or get recycled. Some rebalancing operations may move an existing record to a new home even though that record is not being updated itself. In some cases a lock may be required over a getd_index()/getd_by_index() pair to prevent any interference by another thread. Note that getd_by_index(0) currently always simply returns 0 (rather than the setd_default() setting), but that may be changed in some future release, possibly to trigger a fatal error. |
Example: |
?getd_by_index(getd_index("key")) |
See Also: | getd, getd_index |