cabol / shards

Partitioned ETS tables for Erlang and Elixir

Home Page:https://hexdocs.pm/shards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow to call `shards_local` without the state – using a default state.

cabol opened this issue · comments

Most of the cases, the tables are created with default parameters, normally shards is used locally, using default pick funs. For those cases, it is not necessary to recover the state first, it can be created with default parameters, and avoid an unnecessary call to the ETS control table – such as shards does currently. To achieve this, two things are required:

  1. Improve shards_state module, add setters functions in order to be able to create a sate and modify its properties.
  2. In shards_local module, for all those function that receives the state as parameter, add an equivalent function without the state, creating a default one. E.g.: for shards_local:insert/3:
insert(Tab, ObjOrObjL, State)

Create an equivalent function without the State param, like this:

insert(Tab, ObjOrObjL) ->
  insert(Tab, ObjOrObjL, shards_state:new()).