Python · Documents

Documents

import ustorefrom ustore import Columns 1.0.0-rc.1 · d6d40961

docs_write, docs_read, docs_gist and docs_gather address JSON documents, whole or a field inside each, where a field is a top-level key or a JSON Pointer such as /user/name. A document is JSON text or bytes, a tape of them, or a dict, list or number the binding serializes, and Collection.docs takes and answers Python objects outright. A fixed-width type given a contiguous buffer writes a column of scalars, one per key, so a NumPy column of floats or integers reaches the store without being printed as JSON and parsed back. A gather answers the same shapes in reverse: an f16 column carries the e format, which NumPy reads as float16 without a copy, and a uuid column carries sixteen bytes per document. Table.to_pandas takes a page, converting that many rows at a time so only one page of gathered columns is ever live.

API

Types

FieldTypeHow a document or a field is spelled, or what a gather converts it into, valued as ustore_docs_field_type_t.
__init__.py:247 ↗
class FieldType(IntEnum)

Values

JSON0
NULL10
BOOL11
UUID12
I820
I1621
I3222
I6423
U830
U1631
U3232
U6433
F1640
F3241
F6442
BINARY50
STRING51
ModificationWhat a document write applies, valued as ustore_docs_modification_t.
__init__.py:268 ↗
class Modification(IntEnum)

Values

UPSERT0
UPDATE1
INSERT2
PATCH3
MERGE4
DocsViewThe JSON documents of a collection as Python objects, serialized and parsed in C.
__init__.py:581 ↗
class DocsView
DocsJSONViewThe JSON documents of a collection as their text: one key reads a copy as bytes, a batch a list of them.
__init__.py:592 ↗
class DocsJSONView
JSONValue
__init__.py:56 ↗
type JSONValue = dict[str, JSONValue] | list[JSONValue] | tuple[JSONValue, ...] | str | int | float | bool | None
DocumentLike
__init__.py:57 ↗
type DocumentLike = str | Buffer | dict[str, JSONValue] | list[JSONValue] | int | float | bool
ClassColumnsThe typed columns one gather wrote into an Arena, viewing it until it rewinds.5
lib.pyi:496 ↗
class Columns
validitiesThe bitmap of documents whose value was found and converted.
lib.pyi:504 ↗
def validities(field: int) -> memoryview
conversionsThe bitmap of values whose conversion changed their meaning.
lib.pyi:507 ↗
def conversions(field: int) -> memoryview
collisionsThe bitmap of values of a type no conversion reaches.
lib.pyi:510 ↗
def collisions(field: int) -> memoryview
types
lib.pyi:499 ↗
types: tuple[FieldType, ...]
rows
lib.pyi:500 ↗
rows: int