diff options
author | Sverker Eriksson <[email protected]> | 2019-02-15 16:42:33 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-02-15 16:42:33 +0100 |
commit | 77cff6693158dc2ab20b798db9c124a2c82f5e2a (patch) | |
tree | 96e7977b0052a2b562db6170e61e3c0791bfac23 /lib/stdlib | |
parent | 1808e847e27456ac998aa686b18fd566bd9ffc24 (diff) | |
parent | 7e05835aa76645635ab6f1471c779adf4accb827 (diff) | |
download | otp-77cff6693158dc2ab20b798db9c124a2c82f5e2a.tar.gz otp-77cff6693158dc2ab20b798db9c124a2c82f5e2a.tar.bz2 otp-77cff6693158dc2ab20b798db9c124a2c82f5e2a.zip |
Merge PR-2139 from sverker/ets-doc-partially-bound-key/OTP-15545
Add ETS docs about partially bound key traversal
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/doc/src/ets.xml | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index ccccf7de88..622edc072e 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -188,6 +188,21 @@ is used to keep the table fixated during the entire traversal.</p> </item> </list> + <p>Traversals using <c>match</c> and <c>select</c> functions may not need to + scan the entire table depending on how the key is specified. A match + pattern with a <em>fully bound key</em> (without any match variables) will + optimize the operation to a single key lookup without any table traversal + at all. For <c>ordered_set</c> a <em>partially bound key</em> will limit the + traversal to only scan a subset of the table based on term order. A + partially bound key is either a list or a tuple with a prefix that is fully + bound. Example:</p> +<pre> +1> <input>T = ets:new(t,[ordered_set]), ets:insert(T, {"555-1234", "John Smith"}).</input> +true +2> <input>%% Efficient search of all with area code 555</input> +2> <input>ets:match(T,{[$5,$5,$5,$- |'$1'],'$2'}).</input> +[["1234","John Smith"]] +</pre> </section> <section> |