From 5b7e50500f6cb3e680b277f871392ac706c5c1d7 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Fri, 3 Jun 2016 00:39:01 +0100 Subject: ETS: Allow for matchspec-based replacement --- lib/stdlib/doc/src/ets.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 05401a2d40..36c803b40c 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -1490,6 +1490,27 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> + + + Match the objects in an ETS table against a match_spec and + replaces matching objects with the match_spec result + +

Matches the objects in the table Tab using a + match_spec. If the + an object is matched, and the match_spec result is an object with the + same key, the existing object is replaced with the match_spec result. + For any other result from the match_spec the object is kept + unchanged.

+

The function returns the number of objects actually + replaced in the table.

+ +

The match_spec has to return an object with the same key if + the object is to be replaced. No other return value will get the + object replaced.

+
+
+
+ Continue matching objects in an ETS table. -- cgit v1.2.3 From e15319fcdb5c99514cd63d7a02d04c97587e8853 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Mon, 27 Jun 2016 22:09:37 +0100 Subject: Disable ets:select_replace/2 for bags The existing implementation presented both semantic inconsistencies and performance issues. --- lib/stdlib/doc/src/ets.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 36c803b40c..3e9ad89b26 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -1495,6 +1495,10 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> Match the objects in an ETS table against a match_spec and replaces matching objects with the match_spec result + +

For the moment, due to performance and semantic constraints, + tables of type bag are not yet supported.

+

Matches the objects in the table Tab using a match_spec. If the an object is matched, and the match_spec result is an object with the -- cgit v1.2.3 From ed71ea35bad9a511125c82ce42160cad9fa8311f Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Sat, 25 Feb 2017 22:00:17 +0000 Subject: Reject unsafe matchspecs on ets:select_replace/2 Preemptively fail operation with badarg if the replacement object might have a different key. --- lib/stdlib/doc/src/ets.xml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 3e9ad89b26..29d22ffae5 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -1492,25 +1492,21 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> - Match the objects in an ETS table against a match_spec and - replaces matching objects with the match_spec result + Match and replace objects atomically in an ETS table

For the moment, due to performance and semantic constraints, tables of type bag are not yet supported.

Matches the objects in the table Tab using a - match_spec. If the - an object is matched, and the match_spec result is an object with the - same key, the existing object is replaced with the match_spec result. - For any other result from the match_spec the object is kept - unchanged.

-

The function returns the number of objects actually - replaced in the table.

+ match specification. If the + an object is matched, the existing object is replaced with + the match specificatoin result.

+

The function returns the total number of replaced objects.

-

The match_spec has to return an object with the same key if - the object is to be replaced. No other return value will get the - object replaced.

+

If there's a risk a match specification might return + a tuple with a different key, the whole operation will fail + with badarg.

-- cgit v1.2.3 From 25648cad32b782cff5b513cb1e1a72d2f9f4ada7 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Thu, 23 Mar 2017 00:09:58 +0000 Subject: ets: Polish select_replace/2 documentation --- lib/stdlib/doc/src/ets.xml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 29d22ffae5..d1ec176f81 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -1494,19 +1494,17 @@ is_integer(X), is_integer(Y), X + Y < 4711]]> Match and replace objects atomically in an ETS table - -

For the moment, due to performance and semantic constraints, - tables of type bag are not yet supported.

-

Matches the objects in the table Tab using a - match specification. If the + match specification. If an object is matched, the existing object is replaced with - the match specificatoin result.

+ the match specification result, which must retain + the original key or the operation will fail with badarg.

+

For the moment, due to performance and semantic constraints, + tables of type bag are not yet supported.

The function returns the total number of replaced objects.

-

If there's a risk a match specification might return - a tuple with a different key, the whole operation will fail - with badarg.

+

The match/replacement operation atomicity scope is limited + to each individual object.

-- cgit v1.2.3