Are ETS Bulk Operations Atomic?
Based on the documentation here :
Functions that overlap within a table, such as
select
andmatch
, give the same guarantee assafe_fixtable
.
Where
[...] The function
safe_fixtable
can be used to ensure that a sequence of first / 1 and subsequent / 2 calls traverses the table without error and that every existing object in the table is visited exactly once, even if another (or the same) process simultaneously deletes or inserts objects into the table.
And specifically related to your question:
Nothing else is guaranteed; in particular, objects that are inserted or deleted during such a traversal may be visited once or not at all.
EDIT
ets:tab2list/1
calls ets:match_object/2
, which is an inline function (BIF) implemented in C. The implementation here uses BIF ets_select2
, which is the implementation for ets:select/2
.
ets:file2tab
ends the call load_table/3
it just uses ets:insert/2
.
The code ets:tab2file/3
in ets.erl
uses ets:select/3
to get the first chunk and then ets:select/1
to get the remaining chunks in the table.
source to share