data

package
v0.0.0-...-1561025 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package data provides Arrow IPC serialization and high-performance data handling. This package implements: - Arrow schema definitions for blockchain events - JSON to Arrow conversion - IPC serialization for Rust interop

Package data provides Arrow IPC serialization for zero-copy data transfer.

Package data provides Apache Arrow schema definitions matching HieraChain-Consensus (Rust). Schemas defined here MUST match exactly with src/core/schemas.rs to ensure Arrow IPC compatibility between Go and Rust components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockHeaderSchema

func BlockHeaderSchema() *arrow.Schema

BlockHeaderSchema returns the Arrow schema for a Block Header. Matches Rust: src/core/schemas.rs::get_block_header_schema()

Fields:

  • index: int64 (nullable) - Block index/height
  • timestamp: float64 (nullable) - Block creation timestamp
  • previous_hash: string (nullable) - Hash of previous block
  • nonce: int64 (nullable) - Block nonce
  • merkle_root: string (nullable) - Merkle root of events
  • hash: string (nullable) - Block hash

func BlockSchema

func BlockSchema() *arrow.Schema

BlockSchema returns the Arrow schema for a full Block (header + events). Matches Rust: src/core/schemas.rs::get_block_schema()

Fields:

  • index: int64 - Block index/height
  • timestamp: float64 - Block creation timestamp
  • previous_hash: string - Hash of previous block
  • nonce: int64 - Block nonce
  • merkle_root: string - Merkle root of events
  • hash: string - Block hash
  • events: list<struct> - List of events in the block
  • zk_proof: binary - ZK proof bytes (for SubChain -> MainChain)
  • zk_public_inputs: binary - Public inputs for ZK verification

func EventSchema

func EventSchema() *arrow.Schema

EventSchema returns the Arrow schema for an Event. Matches Rust: src/core/schemas.rs::get_event_schema()

Fields:

  • entity_id: string (nullable) - Entity identifier
  • event: string (nullable) - Event type name
  • timestamp: float64 (nullable) - Unix timestamp
  • details: map<string, string> (nullable) - Key-value metadata
  • data: binary (nullable) - Raw event data

func TransactionSchema

func TransactionSchema() *arrow.Schema

TransactionSchema returns the Arrow schema for a Transaction. Matches Rust: src/core/schemas.rs::get_transaction_schema() Updated to include ZK Proof fields for trustless verification

func ValidateSchema

func ValidateSchema(record arrow.Record, expected *arrow.Schema) error

ValidateSchema checks if a record matches the expected schema.

Types

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

Converter handles JSON to Arrow conversion.

func NewConverter

func NewConverter() *Converter

NewConverter creates a new Converter with the default memory allocator.

func NewConverterWithSchema

func NewConverterWithSchema(schema *arrow.Schema) *Converter

NewConverterWithSchema creates a Converter with a custom schema.

func (*Converter) ArrowBatchToJSON

func (c *Converter) ArrowBatchToJSON(record arrow.Record) ([]byte, error)

ArrowBatchToJSON converts an Arrow RecordBatch back to JSON bytes.

func (*Converter) EventsToArrowBatch

func (c *Converter) EventsToArrowBatch(events []EventJSON) (arrow.Record, error)

EventsToArrowBatch converts a slice of EventJSON to Arrow RecordBatch.

func (*Converter) JSONToArrowBatch

func (c *Converter) JSONToArrowBatch(jsonData []byte) (arrow.Record, error)

JSONToArrowBatch converts JSON bytes to Arrow RecordBatch.

type EventJSON

type EventJSON struct {
	EntityID  string            `json:"entity_id"`
	Event     string            `json:"event"`
	Timestamp float64           `json:"timestamp"`
	Details   map[string]string `json:"details,omitempty"`
	Data      []byte            `json:"data,omitempty"`
}

EventJSON represents an event in JSON format for conversion.

type IPCWriter

type IPCWriter struct {
	// contains filtered or unexported fields
}

IPCWriter writes Arrow RecordBatches to IPC format.

func NewIPCWriter

func NewIPCWriter() *IPCWriter

NewIPCWriter creates a new IPCWriter.

func (*IPCWriter) DeserializeAllFromIPC

func (w *IPCWriter) DeserializeAllFromIPC(data []byte) ([]arrow.Record, error)

DeserializeAllFromIPC deserializes IPC bytes to all Arrow Records.

func (*IPCWriter) DeserializeFromIPC

func (w *IPCWriter) DeserializeFromIPC(data []byte) (arrow.Record, error)

DeserializeFromIPC deserializes IPC bytes to an Arrow Record.

func (*IPCWriter) SerializeMultipleToIPC

func (w *IPCWriter) SerializeMultipleToIPC(records []arrow.Record) ([]byte, error)

SerializeMultipleToIPC serializes multiple records to IPC bytes.

func (*IPCWriter) SerializeToIPC

func (w *IPCWriter) SerializeToIPC(record arrow.Record) ([]byte, error)

SerializeToIPC serializes an Arrow Record to IPC bytes.

type TransactionJSON

type TransactionJSON struct {
	TxID      string            `json:"tx_id"`
	EntityID  string            `json:"entity_id"`
	EventType string            `json:"event_type"`
	Timestamp float64           `json:"timestamp"`
	Data      []byte            `json:"data,omitempty"`
	Signature string            `json:"signature,omitempty"`
	Details   map[string]string `json:"details,omitempty"`
}

TransactionJSON represents a transaction in JSON format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL