Hashed file types
A hashed file is one operating system file. TAFC PB201214 creates four types of them; CREATE-FILE takes the type as TYPE=J4 and so on, and rejects J2 and J5. The first 8 bytes of a file tell its type.
| Type | First 8 bytes | File offsets | Notes |
|---|---|---|---|
| J4 | JBC__HS4 | 8 bytes | the default type; a fixed number of groups |
| JR | JBC__HSR | 8 bytes | "resilient"; grows and splits by itself, needs no resizing |
| J3 | JBC__HS3 | 4 bytes | the type before J4; 1024-byte blocks |
| JP | JBC__HSP | 8 bytes | J3 with 8-byte offsets and 4096-byte blocks |
A dictionary (the file whose name ends with ]D) is a hashed file of the same kind as a data file. A UD file is not a hashed file: it is a folder with one operating system file for each record.
The four types share these rules:
- All integers are big-endian and unsigned. Offsets count from the start of the file.
- The file is a sequence of frames of one size. The first frame holds the header.
- A record key is hashed to a group. The records of a group follow each other with nothing between them, and are searched in order.
- A record is a key and a body. The body is a string of bytes: attributes are separated by byte 0xfe, values by 0xfd and subvalues by 0xfc, as described in @AM (@FM), @VM, @SM, @TM.
- A record body at or above a size limit set in the header is stored out of its group, in frames of its own, and the group keeps only an offset to it.
- Frames that are no longer used go to a list of free frames and are taken from it before the file grows.
- Bytes after the used part of a frame are not cleared. They hold whatever was there before and mean nothing.
The chapters that follow describe each type as TAFC PB201214 writes it on x86-64 Linux. The descriptions were checked against files made by TAFC under scripted writes, deletes and clears: a reader built from them lists every such file in the order of SELECT, and for J4 and JR a writer built from them produces the same bytes as TAFC. Record locks, encrypted files and secondary indexes are not described.
See Reading hashed files with jfiles for a command that reads all four types.
The jBC/jBASE data files explorer shows a file of any of the four types in the browser: a map of its frames, a block diagram of the type, every field of a frame over its bytes, and the path of a key lookup from the hash to the record. It offers files made by TAFC as samples and can open a file of your own.