Basic idea: A Nim DSL that describes the game model declaratively
There is a raw list/sequence of the data for fast iteration over all elements. The implementation
should be either based on an ordinary contiguous sequence or something like: http://plflib.org/colony.htm which is essentially a linked list of growing arrays so that no reallocations are required.
In addition to the contiguous storage there can be multiple indexes into the data. The indexes can be hash based or based on a BTree depending on whether ranges queries need to be supported. There is always a primary key of type integer that can be used to index the contiguous array.
An example:
table t:
type Entry = object
key: string
val: int
hashIndex key
btreeIndex val
with: del
shared: true
count C: val > 10
lazyCount B: val > 1000From this declaration all the procedural code is generated, accessors ensure the different views on the data are kept up-to-date etc. t supports lookups by key because there is a hashIndex on key. It supports range queries on val because there is a BTree index on val.
- Deletion in a hash table implementation usually requires "tombstones", an implementation can be faster if deletion is not supported at all, hence deletion has to be enabled via
with: del. shared: truemeans it should use Nim's shared memory heap. All operations on the data then needs to take a lock. The implementation can use "lock stripes" or even atomic compare and swap loops to improve performance.count C: pcounts the number of entries that fullfill the predicatep.Cis the name of the counter.lazyCountdoes the same but the counter is only available after a full run iteration overtand invalidated on every update operation.