# getd_by_index

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().
pwa/p2js: | Supported.
Comments: | tid should, fairly obviously, always match the tid that was passed to getd_index(), if any. 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 all cases where a lock is required to prevent interference by another thread, then obviously said lock must not be released and re-obtained between the getd_index() and getd_by_index() calls. 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