Plebeia.StorageSourceGeneric cell based storage
Reader: Read only mode. Multiple readers can exist.
Writer: Read write mode. Only 1 writer can exist for a storage.
Private : Modifications are private. See MAP_PRIVATE of the document of mmap()
2 Open, close, and commit
Create a new storage
* length: The initial size of the storage in cells, excluding pos. * resize_step: How many cells allocated for each resize * version: Default is Verison.version * string : The path name
Open an existing storage
Truncate the data file and reinitialize it. All the contents are lost. length is the initial reserved size of the reinitialized file.
For reader to update the storage to catch up the update by the writer process. For Writer and Private, it does nothing.
Write the current state of the storage. Once called, the state is shared with the reader processes with process sync enabled.
Note that commit does NOT assure the persistence of the data after a system crash. Use flush to make it persistent even after a crash.
Flushes all the added data to the disk. The data added to the storage before the call of flush are persisted even after a system crash. Data added after the last call of flush may be lost after a system crash.
flush may trigger huge disk writes. Too frequent call of flush may degrates the performance.
For readers. Enable the process synchronization between the writer process. Once enabled, update_reader checks the header for the process sync instead of the disk sync.
Do not call this function before the writer calls commit. Otherwise readers can misuse an invalid header value.
2 Accessor
Get the status of the storage
For Reader, it only returns the lastest information it knows in memory. Writer may already update this information on the disk.
Set the last index of root hash. Note that the data are only saved to the file when Header.commit is called.
2 Read and write
Get the content of the cell specified by the index
make a 2-cell-wide writable buffer from the beginning of the cell of the given index
Get the contiguous bytes from the head of the index
Allocate cells and return the first index