DataReelDataReelC++ Toolkit Documentation

datareel for Python (DataReel 7.5 beta 3)

Read and write the object databases of the DataReel C++ library from Python, without a C++ helper or an export file. Beta 2 adds writes: a Python program can be a gxObjRepl primary that replicates to a C++ copy.

pip install datareel-7.5b3.post2-cp312-cp312-linux_x86_64.whl
import struct
import datareel

# A gxObjRepl node folder, while the node runs in another process (or none runs).
# index: the node's index spec, for find_key() and nearest().
with datareel.Reader("/data/osa/news", "k0:events:B:0:8,v0:events:V:8:96") as r:
    print(r.role, r.seq, r.databases())
    for oid in r.ids("events")[:10]:
        rec = r.get("events", oid)            # bytes, exactly as the C++ program stored them
    ids = r.find_key("k0", struct.pack("<Q", 20261120))
    hits = r.nearest("v0", query_vector, k=10) # [(id, distance)], closest first

# A .vix vector index file that no process is writing (a day file, a merged month)
with datareel.VectorIndex("/data/news_202611.vix") as v:
    hits = v.search(query_vector, k=20, tags={0: 3, 2: (20261101, 20261130)})

# A .gxd block file that no process is writing
with datareel.BlockFile("/data/old_day.gxd") as f:
    for a in f.addresses():
        rec = f.read(a)

Documentation

What it does

Objects come back as the bytes the C++ program stored. Decode them with struct or numpy using that program's record layout. In a gxObjRepl node, Reader.get() returns the object's own bytes; BlockFile.read() returns the whole block, with gxObjRepl's 40-byte record head in front.

Limits (beta 2)

Building

From the repository top, with a C++17 compiler, CMake 3.16+, the OpenSSL headers and the Python headers (python3.12-devel):

python3.12 -m pip wheel python/ --no-build-isolation --no-deps -w dist/
python/tests/run_python_tests.sh /tmp/drpy      # builds, installs in a venv, runs the tests

DATAREEL_JOBS=N sets the build's parallel jobs (default 2).

License

LGPL 3 or later, as the DataReel library (see LICENSE at the repository top).