Skip to content

Encoding

This document describes how Actionbase encodes and stores data internally. This information is primarily for contributors and those who need to understand the low-level storage format.

For high-level concepts, see Core Concepts.

Actionbase stores edge data using multiple row types in the datastore backend. Each row type serves a specific query purpose.

Row TypeType CodePurposeQuery Type
Edge State-3Current edge stateGet
Edge Index-4Index entriesScan
Edge Count-2Edge countsCount

Stores the current state of edges for Get queries.

[4-byte hash] + [1-byte + source] + [1-byte + table code] + [1-byte + type code(-3)] + [1-byte + target]
FieldTypeDescription
activeBooleanEdge active status
versionLongEdge version
propertiesMapProperty values with version per property
createdAtLongCreation timestamp
deletedAtLongDeletion timestamp

Stores index entries for Scan queries. Uses Narrow Row format for high-cardinality indexes.

[4-byte hash] + [1-byte + directed source] + [1-byte + table code] + [1-byte + type code(-4)] +
[1-byte + direction] + [1-byte + index code] + [(1-byte + N) * # index values] + [1-byte + directed target]
FieldTypeDescription
versionLongEdge version
propertiesMapProperty values

Stores counters for Count queries. Uses the datastore backend’s increment operation.

[4-byte hash] + [1-byte + directed source] + [1-byte + table code] + [1-byte + type code(-2)] + [1-byte + direction]
FieldTypeDescription
countLongEdge count

All row keys follow a common pattern:

[4-byte hash] + [1-byte + source] + [1-byte + table code] + [1-byte + type code] + [additional fields...]
ComponentSizePurpose
Hash4 bytesxxhash32 for region distribution
Type Code1 byteIdentifies data type (-2, -3, -4)
Source/TargetVariablePrefixed with 1-byte length

The hash prefix ensures even distribution across HBase regions, preventing hotspots.

Actionbase uses byte headers to maintain type information:

[1-byte type information] + [actual value]
AspectDescription
Type CodeDistinguishes NULL, STRING, INT, FLOAT, JSON, etc.
Sort OrderIncludes ASC/DESC for index ordering
EncodingValues encoded according to sort order
Row TypeVersion Scope
EdgeStateVersion per property
EdgeIndexVersion per edge

The 4-byte xxhash32 prefix ensures:

  • Even distribution across storage regions
  • Prevention of write hotspots
  • Balanced read/write load

Type codes use negative values (-2, -3, -4) to:

  • Separate from user data
  • Enable efficient key range scanning
  • Provide clear type identification

All variable-length fields use 1-byte length prefix:

  • Enables efficient parsing
  • Supports binary-safe encoding
  • Allows prefix-based scanning