aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2019-02-08 20:16:52 +0100
committerSverker Eriksson <[email protected]>2019-02-08 20:16:52 +0100
commit7e05835aa76645635ab6f1471c779adf4accb827 (patch)
tree7f5bfd90bb8077847b54599d496b76afdfd6b6fb /lib/stdlib/doc
parentb01083b47699f0494053abfbe7ae1f50142b1b49 (diff)
downloadotp-7e05835aa76645635ab6f1471c779adf4accb827.tar.gz
otp-7e05835aa76645635ab6f1471c779adf4accb827.tar.bz2
otp-7e05835aa76645635ab6f1471c779adf4accb827.zip
stdlib: Add ETS docs about partially bound key traversal
Diffstat (limited to 'lib/stdlib/doc')
-rw-r--r--lib/stdlib/doc/src/ets.xml15
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>