Categorygithub.com/superfly/ltx
modulepackage
0.3.13
Repository: https://github.com/superfly/ltx.git
Documentation: pkg.go.dev

# README

Lite Transaction File (LTX)

The LTX file format provides a way to store SQLite transactional data in a way that can be encrypted and compacted and is optimized for performance.

File Format

An LTX file is composed of several sections:

  1. Header
  2. Page block
  3. Trailer

The header contains metadata about the file, the page block contains page frames, and the trailer contains checksums of the file and the database end state.

Header

The header provides information about the number of page frames as well as database information such as the page size and database size. LTX files can be compacted together so each file contains the transaction ID (TXID) range that it represents. A timestamp provides users with a rough approximation of the time the transaction occurred and the checksum provides a basic integrity check.

OffsetSizeDescription
04Magic number. Always "LTX1".
44Flags. Reserved. Always 0.
84Page size, in bytes.
124Size of DB after transaction, in pages.
164Database ID.
208Minimum transaction ID.
288Maximum transaction ID.
368Timestamp (Milliseconds since epoch)
448Pre-apply DB checksum (CRC-ISO-64)
5248Reserved.

Page block

This block stores a series of page headers and page data.

OffsetSizeDescription
04Page number.
4NPage data.

Trailer

The trailer provides checksum for the LTX file data, a rolling checksum of the database state after the LTX file is applied, and the checksum of the trailer itself.

OffsetSizeDescription
08Post-apply DB checksum (CRC-ISO-64)
88File checksum (CRC-ISO-64)

# Packages

No description provided by the author

# Functions

ChecksumPage returns a CRC64 checksum that combines the page number & page data.
ChecksumPageWithHasher returns a CRC64 checksum that combines the page number & page data.
ChecksumReader reads an entire database file from r and computes its rolling checksum.
DecodeHeader decodes the header from r.
FormatFilename returns an LTX filename representing a range of transactions.
FormatTimestamp returns t with a fixed-width, millisecond-resolution UTC format.
IsValidHeaderFlags returns true unless flags outside the valid mask are set.
IsValidPageSize returns true if sz is between 512 and 64K and a power of two.
LockPgno returns the page number where the PENDING_BYTE exists.
NewCompactor returns a new instance of Compactor with default settings.
NewDecoder returns a new instance of Decoder.
NewEncoder returns a new instance of Encoder.
NewHasher returns a new CRC64-ISO hasher.
NewPos returns a new instance of Pos.
NewPosMismatchError returns a new instance of PosMismatchError.
ParseChecksum parses a 16-character hex string into a checksum.
ParseFilename parses a transaction range from an LTX file.
ParsePos parses Pos from its string representation.
ParseTimestamp parses a timestamp as RFC3339Milli (fixed-width) but will fallback to RFC3339Nano if it fails.
ParseTXID parses a 16-character hex string into a transaction ID.
PeekHeader reads & unmarshals the header from r.

# Constants

ChecksumFlag is a flag on the checksum to ensure it is non-zero.
Checksum size & positions.
Header flags.
Header flags.
Size constants.
Magic is the first 4 bytes of every LTX file.
MaxPageSize is the maximum allowed page size for SQLite.
Size constants.
No description provided by the author
RFC3339Milli is the standard time format for LTX timestamps.
Checksum size & positions.
Size constants.
Version is the current version of the LTX file format.

# Variables

# Structs

Compactor represents a compactor of LTX files.
Decoder represents a decoder of an LTX file.
Encoder implements a encoder for an LTX file.
FileSpec is an in-memory representation of an LTX file.
Header represents the header frame of an LTX file.
PageHeader represents the header for a single page in an LTX file.
PageSpec is an in-memory representation of an LTX page frame.
Pos represents the transactional position of a database.
PosMismatchError is returned when an LTX file is not contiguous with the current position.
Trailer represents the ending frame of an LTX file.

# Type aliases

Checksum represents an LTX checksum.
TXID represents a transaction ID.