Sunday 15 May 2011

What is the best way, to traverse and update all elements in an Erlang ETS table? -



What is the best way, to traverse and update all elements in an Erlang ETS table? -

could help me out "best practice" approach, iterate on elements in ets table once, while updating each element? table private set, , traverse through ets:foldl, using ets:update_element in input function, not sure, if safe approach, updating elements destructively may give me same element 1 other time - according documentation. not insert new keys, update values, please, tell me, if approach safe, or show me alternative way accomplish updates efficiently!

thank you!

you can utilize first/1 , next/2. see next/2 doco here: http://www.erlang.org/doc/man/ets.html#next-2

i think ets documentation answered concern:

no other back upwards available within ets guarantee consistency between objects. however, safe_fixtable/2 function can used guarantee sequence of first/1 , next/2 calls traverse table without errors , each existing object in table visited once, if process (or same process) simultaneously deletes or inserts objects table. nil more guaranteed; in particular objects inserted or deleted during such traversal may visited 1 time or not @ all. functions internally traverse on table, select , match, give same guarantee safe_fixtable.

erlang updates traversal ets

No comments:

Post a Comment