nx_shard_writer.nx
buildroot/runtime/nx_shard_writer.nx
about
nx_shard_writer.nx -- size-rotating sharded output writer.
When the current shard would exceed `rotate_bytes`, closes it and
opens the next. Shards named <prefix>-shard-NNNN.jsonl (4-digit
zero-padded for sortability).
genealogy_id: log4j_size_rolling_policy
lineage_id: output_rotation
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_tier.nxnx_str.nxnx_strconv.nx
imported by: nx_ingest_runner.nxnx_ingest_runner_test.nxnx_shard_writer_test.nx
structs
| 29 | struct NxShardWriter |
consts
| 21 | const NX_SHARDW_OK: nx_int = 0 |
| 22 | const NX_SHARDW_OPEN_FAIL: nx_int = -1 |
| 23 | const NX_SHARDW_WRITE_FAIL: nx_int = -2 |
| 24 | const NX_SHARDW_CLOSED: nx_int = -3 |
| 26 | const NX_SHARDW_PATH_BUF: nx_size = 512 |
| 27 | const NX_SHARDW_NEWLINE: nx_int = 10 |
| 41 | const NX_SHARDW_STRUCT_BYTES: nx_size = 80 |
functions
| 43 | func nx_shardw_format_4d(n: nx_int, buf: *u8) -> nx_int called by 1: nx_shardw_path |
| 54 | func nx_shardw_path(w: *NxShardWriter, idx: nx_int, out: *u8) -> nx_size |
| 76 | func nx_shardw_open_shard(w: *NxShardWriter, idx: nx_int) -> nx_fd |
| 83 | func nx_shard_writer_open(prefix: *u8, rotate_bytes: nx_size) -> *NxShardWriter |
| 105 | func nx_shard_writer_set_raw(w: *NxShardWriter) -> nx_int |
| 110 | func nx_shard_writer_close(w: *NxShardWriter) -> nx_int |
| 118 | func nx_shardw_rotate(w: *NxShardWriter) -> nx_int |
| 128 | func nx_shardw_write_all(fd: nx_fd, buf: *u8, len: nx_size) -> nx_size |
| 139 | func nx_shard_writer_emit(w: *NxShardWriter, rec: *u8, len: nx_size) -> nx_int |
| 168 | func nx_shard_writer_shard_index(w: *NxShardWriter) -> nx_int { return w.shard_index } called by 1: main |
| 169 | func nx_shard_writer_total_records(w: *NxShardWriter) -> nx_int { return w.total_records } called by 1: main |
| 170 | func nx_shard_writer_total_bytes(w: *NxShardWriter) -> nx_size { return w.total_bytes } called by 1: main |
| 171 | func nx_shard_writer_current_bytes(w: *NxShardWriter) -> nx_size { return w.current_bytes } called by 1: main |
| 172 | func nx_shard_writer_n_shards(w: *NxShardWriter) -> nx_int { return w.shard_index + 1 } |