motedb-python 0.12.0__cp39-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
motedb/__init__.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""MoteDB — AI-native embedded multimodal database.
|
|
2
|
+
|
|
3
|
+
Rust-native engine (vectors / full-text / spatial / time-series in one ACID
|
|
4
|
+
store) with a Python-first surface. This wrapper adds Arrow/pandas interop
|
|
5
|
+
on top of the native extension.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from ._native import * # noqa: F401,F403
|
|
9
|
+
from ._native import Database as _Database
|
|
10
|
+
|
|
11
|
+
__version__ = __import__("_native_version_hack", fromlist=[""]) if False else None
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _native_version():
|
|
15
|
+
import motedb._native as _n
|
|
16
|
+
|
|
17
|
+
return getattr(_n, "__version__", "0.12.0")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
__version__ = _native_version()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def query_arrow(self, sql, params=None):
|
|
24
|
+
"""Run a SELECT and return a pyarrow.Table.
|
|
25
|
+
|
|
26
|
+
Columnar columns ride numpy (zero-copy where the engine already built
|
|
27
|
+
arrays); VECTOR columns become FixedSizeListArray(float32). Requires
|
|
28
|
+
pyarrow (`pip install pyarrow`).
|
|
29
|
+
"""
|
|
30
|
+
import pyarrow as pa
|
|
31
|
+
|
|
32
|
+
cols, data = self.fetch_arrays(sql, params=params)
|
|
33
|
+
arrays = []
|
|
34
|
+
for c in cols:
|
|
35
|
+
v = data[c]
|
|
36
|
+
# VECTOR columns: 2D numpy (fast path) or a list of equal-length
|
|
37
|
+
# lists → FixedSizeListArray(float32), the canonical Arrow vector
|
|
38
|
+
# representation.
|
|
39
|
+
try:
|
|
40
|
+
import numpy as _np
|
|
41
|
+
|
|
42
|
+
if isinstance(v, _np.ndarray) and v.ndim == 2:
|
|
43
|
+
flat = _np.ascontiguousarray(v, dtype=_np.float32).reshape(-1)
|
|
44
|
+
arrays.append(
|
|
45
|
+
pa.FixedSizeListArray.from_arrays(pa.array(flat), v.shape[1])
|
|
46
|
+
)
|
|
47
|
+
continue
|
|
48
|
+
except ImportError:
|
|
49
|
+
pass
|
|
50
|
+
if isinstance(v, list) and v and isinstance(v[0], (list, tuple)):
|
|
51
|
+
dim = len(v[0])
|
|
52
|
+
if all(len(x) == dim for x in v):
|
|
53
|
+
flat = [f for row in v for f in row]
|
|
54
|
+
arrays.append(
|
|
55
|
+
pa.FixedSizeListArray.from_arrays(pa.array(flat, type=pa.float32()), dim)
|
|
56
|
+
)
|
|
57
|
+
continue
|
|
58
|
+
arrays.append(pa.array(v))
|
|
59
|
+
return pa.Table.from_arrays(arrays, names=list(cols))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def query_pandas(self, sql, params=None):
|
|
63
|
+
"""Run a SELECT and return a pandas.DataFrame (via Arrow)."""
|
|
64
|
+
try:
|
|
65
|
+
import pandas as pd
|
|
66
|
+
except ImportError as e: # pragma: no cover
|
|
67
|
+
raise ImportError("query_pandas requires pandas (`pip install pandas`)") from e
|
|
68
|
+
return self.query_arrow(sql, params=params).to_pandas()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Attach the interop methods to the pyo3 Database class (heap type — setattr
|
|
72
|
+
# on the class works; verified in test).
|
|
73
|
+
_Database.query_arrow = query_arrow
|
|
74
|
+
_Database.query_pandas = query_pandas
|
|
75
|
+
|
|
76
|
+
__all__ = [n for n in dir() if not n.startswith("_")]
|
motedb/_native.abi3.so
ADDED
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: motedb-python
|
|
3
|
+
Version: 0.12.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Topic :: Database
|
|
7
|
+
Summary: AI-native embedded multimodal database — vectors, full-text, spatial, time-series in one ACID engine.
|
|
8
|
+
License: MIT
|
|
9
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
motedb/__init__.py,sha256=Y7OIzi2jUuo66Q3ARFpgVKoASi4JR7V4_Jjv6rBLGH8,2589
|
|
2
|
+
motedb/_native.abi3.so,sha256=gDVdtnBUMSETwfrpI0t8dqmmOW9n0VO3b2VAyoP5EH8,9671216
|
|
3
|
+
motedb_python-0.12.0.dist-info/METADATA,sha256=COi68c6nu5e3d1dPEX_jlH44bnyXAsfdohNkn0x5tRM,326
|
|
4
|
+
motedb_python-0.12.0.dist-info/WHEEL,sha256=J01xQb0tX_fb6iLatmwdxtTNhze3oGZ-ZcyWZ82gg8Q,103
|
|
5
|
+
motedb_python-0.12.0.dist-info/sboms/motedb-python.cyclonedx.json,sha256=tCkMiONSyjCBUwfX6oPGZMBkE6KGTGYm4yXwvwCV3pg,118664
|
|
6
|
+
motedb_python-0.12.0.dist-info/RECORD,,
|