Package etch

Class Etch

java.lang.Object
etch.Etch

public class Etch extends Object
A stupid, fast database for immutable data you want carved in stone. We solve the cache invalidation problem, quite effectively, by never changing anything. Once a value is written for a given key, it cannot be changed. Etch is indifferent to the exact meaning of keys, but they must have a fixed length of 32 bytes (256 bits). It is intended that keys are pseudo-random hash values, which will result in desirable distributions of data for the radix tree structure. Radix tree index blocks are arrays of 8 byte pointers. To avoid creating too many index blocks when collisions occur, a chained entry list inside is created in unused space in index blocks. Once there is no more space, chains are collapsed to a new index block. Header of file is 42 bytes as follows: - Magic number 0xe7c6 (2 bytes) - Database length in bytes (8 bytes) - Root hash (32 bytes) Pointers in index blocks are of 4 possible types, determined by the two high bits (MSBs): - 00 high bits: pointer to data - 01 high bits: pointer to next index node - 10 high bits: start of chained entry list - 11 high bits: continuation of chained entry list Data is stored as: - 32 bytes key - X bytes monotonic label of which - 1 byte status - 8 bytes Memory Size - 2 bytes data length N (a short) - N byes actual data