Xbase.CdxParser (Xbase v0.1.0)
View SourceParser for CDX (compound index) files used in dBase for fast data access.
CDX files implement a B-tree structure with 512-byte pages containing root, branch, and leaf nodes. The file begins with a header containing metadata about the index structure and key expressions.
Summary
Functions
Closes a CDX file handle and cleans up resources.
Opens a CDX file and parses its header.
Parses a CDX file header from binary data.
Parses a CDX B-tree node from binary page data.
Reads a B-tree node from a specific page number.
Searches for a key in the B-tree starting from the root node.
Functions
Closes a CDX file handle and cleans up resources.
Parameters
cdx_file
- CdxFile structure from open_cdx/1
Returns
:ok
- File closed successfully
Opens a CDX file and parses its header.
Parameters
file_path
- Path to the CDX file
Returns
{:ok, CdxFile.t()}
- Successfully opened CDX file{:error, reason}
- Error opening or parsing file
Parses a CDX file header from binary data.
Parameters
header_binary
- 512 bytes of header data
Returns
{:ok, CdxHeader.t()}
- Successfully parsed header{:error, reason}
- Error parsing header
Parses a CDX B-tree node from binary page data.
Parameters
page_data
- 512 bytes of page datakey_length
- Length of keys in this index
Returns
{:ok, CdxNode.t()}
- Successfully parsed node{:error, reason}
- Error parsing node
Reads a B-tree node from a specific page number.
Parameters
cdx_file
- CdxFile structure from open_cdx/1page_number
- Page number to read (0-based)
Returns
{:ok, CdxNode.t()}
- Successfully read node{:error, reason}
- Error reading node
Searches for a key in the B-tree starting from the root node.
Parameters
cdx_file
- CdxFile structuresearch_key
- Key to search for
Returns
{:ok, record_number}
- Found key, returns record number{:error, :not_found}
- Key not found{:error, reason}
- Error during search