colstore.ColStoreWriter¶
- class colstore.ColStoreWriter(path, mode, *, statistics=False)[source]¶
Bases:
objectAppend-only writer for a colstore file. See module docstring.
Use
colstore.create(),colstore.recreate(), orcolstore.update()rather than constructing directly.statistics=Truerecords per-column statistics so later filters can skip data that cannot match; off by default.- Parameters:
path (str | os.PathLike[str])
mode (str)
statistics (bool)
- write(columns)[source]¶
Append one record. Schema is locked on the first non-empty call.
- Parameters:
columns (dict[str, numpy.ndarray]) – Column-major data. Names must match (and dtypes match) the schema captured on the first
write()(or loaded from the existing file in update mode). All columns must share the same length; that length is the new record’s row count.written (Empty dicts are a no-op (no record)
yet (schema not locked)
record (in create/recreate mode). To write a zero-row)
pass
``{name –
empty_array_of_dtype:
explicitly. (...}``)
- Raises:
ValueError – On empty schema (first call after empty dicts), ragged columns, or schema mismatch on a non-first call.
TypeError – On unsupported column dtypes.
- Return type:
None
- close()[source]¶
Commit counters, fsync, release the lock, close the file.
Idempotent: calling close() on an already-closed writer is a no-op.
In create/recreate mode, if nothing was ever written, the (zero- byte) file is removed: there’s no manifest to commit, and a zero-byte
.cstorewould fail every reader. In update mode, nothing-written means no counter change is needed.- Return type:
None