wp-connector-utils
Shared utilities for WP connector implementations — Arrow IPC encode/decode, WireFormat, NDJSON conversion, and batch metadata processing.
Modules
arrow — Arrow IPC Utilities
Arrow IPC encode/decode and data conversion helpers, shared across wp-core-connectors and wp-connectors.
arrow/
├── format.rs # WireFormat enum + parse_strict / from_data_format / is_arrow
├── encode.rs # encode_batch_ipc_stream / encode_ipc_frame / encode_ipc_frame_multi
├── decode.rs # decode_arrow_ipc_batches / decode_arrow_framed_batches
├── schema.rs # infer_arrow_schema / infer_schema_from_record
└── record.rs # data_record_to_batch / data_records_to_batch + typed column builders
WireFormat
use WireFormat;
// Strict parsing for factory validation
let fmt = parse_strict?;
// Lenient parsing (unknown → Ndjson)
let fmt = from_data_format;
// Is this an Arrow binary format?
assert!;
Encoding (Sink Direction)
use ;
// Bare Arrow IPC Stream
let ipc_bytes = encode_batch_ipc_stream?;
// wp_arrow frame: [4B tag_len][tag][Arrow IPC Stream]
let framed_bytes = encode_ipc_frame?;
Decoding (Source Direction)
use ;
// Decode raw Arrow IPC Stream bytes
let batches: = decode_arrow_ipc_batches?;
// Decode wp_arrow frame (skips tag header)
let batches: = decode_arrow_framed_batches?;
DataRecord → RecordBatch
use ;
// Infer schema from typed DataRecord fields
let schema = new;
// Convert single record
let batch = data_record_to_batch?;
// Convert batch of records
let batch = data_records_to_batch?;
batch — Batch Metadata Processing
use ;
use BatchMeta;
// Inject wp_oml_name field into each DataRecord (text sinks: JSON, CSV, syslog)
let meta = with_oml_name;
let records = inject_oml_name;
// Resolve Arrow frame tag: meta.oml_name > connector config tag
let tag = resolve_frame_tag;
ndjson — NDJSON Conversion
use ndjson_to_record_batch;
let lines = vec!;
let batch = ndjson_to_record_batch?
.expect;
Features
- Arrow IPC v59 — Full Arrow IPC Stream encode/decode (schema + batches + EOS)
- wp_arrow frame — Custom frame format
[tag_len][tag][IPC]for stream routing - WireFormat — Centralised
data_formatenum with strict & lenient parsing - Typed RecordBatch —
DataRecord→RecordBatchwith Bool/Int32/Int64/Float64/Timestamp/Binary/Utf8 - NDJSON — Line-oriented JSON to Arrow columnar conversion
- Batch metadata — OML name injection for text sinks, frame tag resolution for Arrow sinks
License
Apache-2.0