Record
Record
Properties
key
public string $key
value
public mixed $value
ptr
public int $ptr
parentNode
public Node $parentNode
file
private mixed $file
Methods
create
Creates a new Record instance.
public create(Node $parentNode, string $key): self
Parameters
Parameter | Type | Description |
---|---|---|
$parentNode | Node | the parent node of the record |
$key | string | the key of the record |
read
Reads the record's value from the file.
public read(?int $ptr): mixed
If the value is already in memory, it is returned directly. Otherwise, it seeks to the record's position in the file, reads its length and data, unserializes the data, and returns the value.
Parameters
Parameter | Type | Description |
---|---|---|
$ptr | int | the pointer to the record in the file. If null, uses the current record's pointer. |
write
Writes the record's key and value to the file.
public write(string $key, mixed $value): bool
Serializes the value and writes it to the file. If the record already exists and the new data fits within the allocated space, it updates the record in-place. Otherwise, it appends the new record to the end of the file and updates the pointer.
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the record |
$value | mixed | the value of the record |
moveTo
Moves the record to a new leaf node.
public moveTo(Node $leaf): bool
This method updates the record's parent node and file handle, resets its pointer, writes the record to the new location in the file, and adds the record to the new leaf node.
Parameters
Parameter | Type | Description |
---|---|---|
$leaf | Node | the new leaf node to move the record to |
Generated by Hazaar API Doc Generator on Sat, 23 Aug 2025 22:23:42 +0000