Record
Record
Properties
key
public string $keyvalue
public mixed $valueptr
public int $ptrparentNode
public Node $parentNodefile
private mixed $fileMethods
create
Creates a new Record instance.
public create(Node $parentNode, string $key): selfParameters
| 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): mixedIf 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): boolSerializes 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): boolThis 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 Mon, 27 Oct 2025 13:01:29 +0000