jonnify·bcs /bcs/elixir-core/property-stores

B2.2 · dive 2 of 3

Property stores on ETS.

A system’s state is an :ordered_set :private table whose only key is a branded id — so a newest-first page and a time window come from the key, with no clock.

An ordered keyspace, read by page_desc and window. Select a part.
ordered_set · private ORD0KQ7aORD0KQ7mORD0KQ8cORD0KQ8xORD0KQ9dORD0KQ9rthe only key page_desc(3):ets.lastthen :ets.prev window(lo, hi):ets.select
readout · Select a part. State is an :ordered_set :private ETS table keyed by the branded id; chronology and placement come from the key.
§1

The idea

echo_data · bcs/property_store.ex

A system’s state is a property store: an ETS table created :ordered_set and :private, whose only key is the branded id and whose value is a property bundle. :private is the boundary — only the owning process reads it, so a lookup from outside raises rather than returning a forbidden row. put(store, id, value) writes the bundle under the id; get(store, id) reads it; record_entity notes that the system owns a name.

Because the id sorts as its mint instant sorts, :ordered_set keeps the table in time order, and the store needs no clock column. page_desc(store, n) reads a newest-first page by taking :ets.last and walking back through :ets.prev, n times; window(store, lo, hi) reads a time range as a key-range :ets.select. A feed and a window come from the shape of the key, not from a timestamp the system has to maintain.

The store also answers where a row belongs without a side table. placement(id) parses the id and routes it through hash32 — placement(USR0KHTOWnGLuC) is 234878118 — the same function that locates a cache shard or a partition. One placement idea, reused: the store, the cache, and the bus all address a row from its identity alone.

echo_data · branded_id.ex · the vectors self_check! asserts at bootverified
placement(USR0KHTOWnGLuC)        →  234878118            native and pure agree
parse(USR0NgWEfAEJfs)            →  {:ok, "USR", 320636799581945856}
decode(USRzzzzzzzzzzz)           →  :error               an overflow is refused, not wrapped

The three dives are in the module: B2.2 · Property Stores on ETS.

§4

The doors

the sibling courses
§2

References

sources · related

Sources

Related