pyspiral 0.4.4__cp310-abi3-macosx_11_0_arm64.whl → 0.6.0__cp310-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.
- {pyspiral-0.4.4.dist-info → pyspiral-0.6.0.dist-info}/METADATA +10 -5
- pyspiral-0.6.0.dist-info/RECORD +99 -0
- {pyspiral-0.4.4.dist-info → pyspiral-0.6.0.dist-info}/WHEEL +1 -1
- spiral/__init__.py +10 -3
- spiral/_lib.abi3.so +0 -0
- spiral/adbc.py +29 -11
- spiral/api/__init__.py +14 -0
- spiral/api/client.py +5 -1
- spiral/api/key_space_indexes.py +23 -0
- spiral/api/projects.py +17 -2
- spiral/api/text_indexes.py +56 -0
- spiral/api/types.py +2 -0
- spiral/api/workers.py +40 -0
- spiral/cli/__init__.py +15 -6
- spiral/cli/admin.py +2 -4
- spiral/cli/app.py +4 -2
- spiral/cli/fs.py +5 -6
- spiral/cli/iceberg.py +97 -0
- spiral/cli/key_spaces.py +68 -0
- spiral/cli/login.py +6 -7
- spiral/cli/orgs.py +7 -8
- spiral/cli/printer.py +3 -3
- spiral/cli/projects.py +5 -6
- spiral/cli/tables.py +131 -0
- spiral/cli/telemetry.py +3 -4
- spiral/cli/text.py +115 -0
- spiral/cli/types.py +3 -4
- spiral/cli/workloads.py +7 -8
- spiral/client.py +111 -8
- spiral/core/authn/__init__.pyi +27 -0
- spiral/core/client/__init__.pyi +135 -63
- spiral/core/table/__init__.pyi +36 -26
- spiral/core/table/metastore/__init__.pyi +0 -4
- spiral/core/table/spec/__init__.pyi +0 -2
- spiral/{tables/dataset.py → dataset.py} +13 -7
- spiral/{tables/debug → debug}/manifests.py +17 -6
- spiral/{tables/debug → debug}/scan.py +7 -7
- spiral/expressions/base.py +3 -3
- spiral/expressions/udf.py +1 -1
- spiral/{iceberg/client.py → iceberg.py} +1 -3
- spiral/key_space_index.py +44 -0
- spiral/project.py +171 -18
- spiral/protogen/_/arrow/flight/protocol/sql/__init__.py +1668 -1110
- spiral/protogen/_/google/protobuf/__init__.py +2190 -0
- spiral/protogen/_/message_pool.py +3 -0
- spiral/protogen/_/py.typed +0 -0
- spiral/protogen/_/scandal/__init__.py +138 -126
- spiral/protogen/_/spfs/__init__.py +72 -0
- spiral/protogen/_/spql/__init__.py +61 -0
- spiral/protogen/_/substrait/__init__.py +5256 -2459
- spiral/protogen/_/substrait/extensions/__init__.py +103 -49
- spiral/{tables/scan.py → scan.py} +37 -44
- spiral/settings.py +14 -3
- spiral/snapshot.py +55 -0
- spiral/streaming_/__init__.py +3 -0
- spiral/streaming_/reader.py +117 -0
- spiral/streaming_/stream.py +146 -0
- spiral/substrait_.py +9 -9
- spiral/table.py +257 -0
- spiral/text_index.py +17 -0
- spiral/{tables/transaction.py → transaction.py} +11 -15
- pyspiral-0.4.4.dist-info/RECORD +0 -98
- spiral/cli/iceberg/__init__.py +0 -7
- spiral/cli/iceberg/namespaces.py +0 -47
- spiral/cli/iceberg/tables.py +0 -60
- spiral/cli/indexes/__init__.py +0 -19
- spiral/cli/tables/__init__.py +0 -121
- spiral/core/index/__init__.pyi +0 -15
- spiral/iceberg/__init__.py +0 -3
- spiral/indexes/__init__.py +0 -5
- spiral/indexes/client.py +0 -137
- spiral/indexes/index.py +0 -34
- spiral/indexes/scan.py +0 -22
- spiral/protogen/_/spiral/table/__init__.py +0 -22
- spiral/protogen/substrait/__init__.py +0 -3399
- spiral/protogen/substrait/extensions/__init__.py +0 -115
- spiral/tables/__init__.py +0 -12
- spiral/tables/client.py +0 -130
- spiral/tables/maintenance.py +0 -12
- spiral/tables/snapshot.py +0 -78
- spiral/tables/table.py +0 -145
- {pyspiral-0.4.4.dist-info → pyspiral-0.6.0.dist-info}/entry_points.txt +0 -0
- /spiral/{protogen/_/spiral → debug}/__init__.py +0 -0
- /spiral/{tables/debug → debug}/metrics.py +0 -0
- /spiral/{tables/debug → protogen/_/google}/__init__.py +0 -0
spiral/cli/iceberg/namespaces.py
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
import sys
|
2
|
-
from typing import Annotated
|
3
|
-
|
4
|
-
import pyiceberg.exceptions
|
5
|
-
import rich
|
6
|
-
import typer
|
7
|
-
from typer import Argument
|
8
|
-
|
9
|
-
from spiral.cli import AsyncTyper, state
|
10
|
-
from spiral.cli.types import ProjectArg
|
11
|
-
|
12
|
-
app = AsyncTyper(short_help="Apache Iceberg Namespaces.")
|
13
|
-
|
14
|
-
|
15
|
-
@app.command(help="List namespaces.")
|
16
|
-
def ls(
|
17
|
-
project: ProjectArg,
|
18
|
-
namespace: Annotated[str | None, Argument(help="List only namespaces under this namespace.")] = None,
|
19
|
-
):
|
20
|
-
"""List Iceberg namespaces."""
|
21
|
-
catalog = state.spiral.iceberg.catalog()
|
22
|
-
|
23
|
-
if namespace is None:
|
24
|
-
try:
|
25
|
-
namespaces = catalog.list_namespaces(project)
|
26
|
-
except pyiceberg.exceptions.ForbiddenError:
|
27
|
-
print(
|
28
|
-
f"The project, {repr(project)}, does not exist or you lack the "
|
29
|
-
f"`iceberg:view` permission to list namespaces in it.",
|
30
|
-
file=sys.stderr,
|
31
|
-
)
|
32
|
-
raise typer.Exit(code=1)
|
33
|
-
else:
|
34
|
-
try:
|
35
|
-
namespaces = catalog.list_namespaces((project, namespace))
|
36
|
-
except pyiceberg.exceptions.ForbiddenError:
|
37
|
-
print(
|
38
|
-
f"The namespace, {repr(project)}.{repr(namespace)}, does not exist or you lack the "
|
39
|
-
f"`iceberg:view` permission to list namespaces in it.",
|
40
|
-
file=sys.stderr,
|
41
|
-
)
|
42
|
-
raise typer.Exit(code=1)
|
43
|
-
|
44
|
-
table = rich.table.Table("Namespace ID", title="Iceberg namespaces")
|
45
|
-
for ns in namespaces:
|
46
|
-
table.add_row(".".join(ns))
|
47
|
-
rich.print(table)
|
spiral/cli/iceberg/tables.py
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
import sys
|
2
|
-
from typing import Annotated
|
3
|
-
|
4
|
-
import pyiceberg.exceptions
|
5
|
-
import rich
|
6
|
-
import typer
|
7
|
-
from typer import Argument
|
8
|
-
|
9
|
-
from spiral.cli import AsyncTyper, state
|
10
|
-
from spiral.cli.types import ProjectArg
|
11
|
-
|
12
|
-
app = AsyncTyper(short_help="Apache Iceberg Tables.")
|
13
|
-
|
14
|
-
|
15
|
-
@app.command(help="List tables.")
|
16
|
-
def ls(
|
17
|
-
project: ProjectArg,
|
18
|
-
namespace: Annotated[str | None, Argument(help="Show only tables in the given namespace.")] = None,
|
19
|
-
):
|
20
|
-
catalog = state.spiral.iceberg.catalog()
|
21
|
-
|
22
|
-
try:
|
23
|
-
if namespace is None:
|
24
|
-
tables = catalog.list_tables(project)
|
25
|
-
else:
|
26
|
-
tables = catalog.list_tables((project, namespace))
|
27
|
-
except pyiceberg.exceptions.ForbiddenError:
|
28
|
-
print(
|
29
|
-
f"The namespace, {repr(project)}.{repr(namespace)}, does not exist or you lack the "
|
30
|
-
f"`iceberg:view` permission to list tables in it.",
|
31
|
-
file=sys.stderr,
|
32
|
-
)
|
33
|
-
raise typer.Exit(code=1)
|
34
|
-
|
35
|
-
rich_table = rich.table.Table("table id", title="Iceberg tables")
|
36
|
-
for table in tables:
|
37
|
-
rich_table.add_row(".".join(table))
|
38
|
-
rich.print(rich_table)
|
39
|
-
|
40
|
-
|
41
|
-
@app.command(help="Show the table schema.")
|
42
|
-
def schema(
|
43
|
-
project: ProjectArg,
|
44
|
-
namespace: Annotated[str, Argument(help="Table namespace.")],
|
45
|
-
table: Annotated[str, Argument(help="Table name.")],
|
46
|
-
):
|
47
|
-
catalog = state.spiral.iceberg.catalog()
|
48
|
-
|
49
|
-
try:
|
50
|
-
tbl = catalog.load_table((project, namespace, table))
|
51
|
-
except pyiceberg.exceptions.NoSuchTableError:
|
52
|
-
print(f"No table {repr(table)} found in {repr(project)}.{repr(namespace)}", file=sys.stderr)
|
53
|
-
raise typer.Exit(code=1)
|
54
|
-
|
55
|
-
rich_table = rich.table.Table(
|
56
|
-
"Field ID", "Field name", "Type", "Required", "Doc", title=f"{project}.{namespace}.{table}"
|
57
|
-
)
|
58
|
-
for col in tbl.schema().columns:
|
59
|
-
rich_table.add_row(str(col.field_id), col.name, str(col.field_type), str(col.required), col.doc)
|
60
|
-
rich.print(rich_table)
|
spiral/cli/indexes/__init__.py
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import rich
|
2
|
-
|
3
|
-
from spiral.cli import AsyncTyper, state
|
4
|
-
from spiral.cli.types import ProjectArg
|
5
|
-
|
6
|
-
app = AsyncTyper(short_help="Indexes.")
|
7
|
-
|
8
|
-
|
9
|
-
@app.command(help="List indexes.")
|
10
|
-
def ls(
|
11
|
-
project: ProjectArg,
|
12
|
-
):
|
13
|
-
"""List indexes."""
|
14
|
-
indexes = state.spiral.project(project).indexes.list_indexes()
|
15
|
-
|
16
|
-
rich_table = rich.table.Table("id", "name", title="Indexes")
|
17
|
-
for index in indexes:
|
18
|
-
rich_table.add_row(index.id, index.name)
|
19
|
-
rich.print(rich_table)
|
spiral/cli/tables/__init__.py
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
from typing import Annotated
|
2
|
-
|
3
|
-
import questionary
|
4
|
-
import rich
|
5
|
-
import typer
|
6
|
-
from questionary import Choice
|
7
|
-
from typer import Argument, Option
|
8
|
-
|
9
|
-
from spiral import Spiral
|
10
|
-
from spiral.cli import AsyncTyper, state
|
11
|
-
from spiral.cli.types import ProjectArg
|
12
|
-
from spiral.tables import Table
|
13
|
-
|
14
|
-
app = AsyncTyper(short_help="Spiral Tables.")
|
15
|
-
|
16
|
-
|
17
|
-
def ask_table(project_id, title="Select a table"):
|
18
|
-
tables = list(state.spiral.project(project_id).tables.list_tables())
|
19
|
-
|
20
|
-
if not tables:
|
21
|
-
rich.print("[red]No tables found[/red]")
|
22
|
-
raise typer.Exit(1)
|
23
|
-
|
24
|
-
return questionary.select(
|
25
|
-
title,
|
26
|
-
choices=[
|
27
|
-
Choice(title=f"{table.dataset}.{table.table}", value=f"{table.project_id}.{table.dataset}.{table.table}")
|
28
|
-
for table in tables
|
29
|
-
],
|
30
|
-
).ask()
|
31
|
-
|
32
|
-
|
33
|
-
@app.command(help="List tables.")
|
34
|
-
def ls(
|
35
|
-
project: ProjectArg,
|
36
|
-
):
|
37
|
-
tables = Spiral().project(project).tables.list_tables()
|
38
|
-
|
39
|
-
rich_table = rich.table.Table("id", "dataset", "name", title="Spiral tables")
|
40
|
-
for table in tables:
|
41
|
-
rich_table.add_row(table.id, table.dataset, table.table)
|
42
|
-
rich.print(rich_table)
|
43
|
-
|
44
|
-
|
45
|
-
@app.command(help="Show the table key schema.")
|
46
|
-
def key_schema(
|
47
|
-
project: ProjectArg,
|
48
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
49
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
50
|
-
):
|
51
|
-
_, table = _get_table(project, table, dataset)
|
52
|
-
rich.print(table.key_schema)
|
53
|
-
|
54
|
-
|
55
|
-
@app.command(help="Compute the full table schema.")
|
56
|
-
def schema(
|
57
|
-
project: ProjectArg,
|
58
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
59
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
60
|
-
):
|
61
|
-
_, table = _get_table(project, table, dataset)
|
62
|
-
rich.print(table.schema)
|
63
|
-
|
64
|
-
|
65
|
-
@app.command(help="Flush Write-Ahead-Log.")
|
66
|
-
def flush(
|
67
|
-
project: ProjectArg,
|
68
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
69
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
70
|
-
):
|
71
|
-
identifier, table = _get_table(project, table, dataset)
|
72
|
-
table.maintenance().flush_wal()
|
73
|
-
print(f"Flushed WAL for table {identifier} in project {project}.")
|
74
|
-
|
75
|
-
|
76
|
-
@app.command(help="Display scan.")
|
77
|
-
def debug(
|
78
|
-
project: ProjectArg,
|
79
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
80
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
81
|
-
column_group: Annotated[str, Argument(help="Dot-separated column group path.")] = ".",
|
82
|
-
):
|
83
|
-
_, table = _get_table(project, table, dataset)
|
84
|
-
if column_group != ".":
|
85
|
-
projection = table[column_group]
|
86
|
-
else:
|
87
|
-
projection = table
|
88
|
-
scan = table.scan(projection)
|
89
|
-
|
90
|
-
scan._debug()
|
91
|
-
|
92
|
-
|
93
|
-
@app.command(help="Display manifests.")
|
94
|
-
def manifests(
|
95
|
-
project: ProjectArg,
|
96
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
97
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
98
|
-
column_group: Annotated[str, Argument(help="Dot-separated column group path.")] = ".",
|
99
|
-
):
|
100
|
-
_, table = _get_table(project, table, dataset)
|
101
|
-
if column_group != ".":
|
102
|
-
projection = table[column_group]
|
103
|
-
else:
|
104
|
-
projection = table
|
105
|
-
scan = projection.scan()
|
106
|
-
|
107
|
-
scan._dump_manifests()
|
108
|
-
|
109
|
-
|
110
|
-
def _get_table(
|
111
|
-
project: ProjectArg,
|
112
|
-
table: Annotated[str | None, Option(help="Table name.")] = None,
|
113
|
-
dataset: Annotated[str | None, Option(help="Dataset name.")] = None,
|
114
|
-
) -> (str, Table):
|
115
|
-
if table is None:
|
116
|
-
identifier = ask_table(project)
|
117
|
-
else:
|
118
|
-
identifier = table
|
119
|
-
if dataset is not None:
|
120
|
-
identifier = f"{dataset}.{table}"
|
121
|
-
return identifier, state.spiral.project(project).tables.table(identifier)
|
spiral/core/index/__init__.pyi
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import pyarrow as pa
|
2
|
-
|
3
|
-
class IndexStatus:
|
4
|
-
status: str
|
5
|
-
staleness_s: int | None
|
6
|
-
# An extent of keys that are indexed.
|
7
|
-
# key_extent: KeyExtent | None
|
8
|
-
|
9
|
-
class TextIndex:
|
10
|
-
id: str
|
11
|
-
|
12
|
-
def status(self) -> IndexStatus: ...
|
13
|
-
|
14
|
-
class SearchScan:
|
15
|
-
def to_record_batches(self) -> pa.RecordBatchReader: ...
|
spiral/iceberg/__init__.py
DELETED
spiral/indexes/__init__.py
DELETED
spiral/indexes/client.py
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
import datetime
|
2
|
-
|
3
|
-
from spiral.api import SpiralAPI
|
4
|
-
from spiral.api.projects import TextIndexResource
|
5
|
-
from spiral.core.client import Spiral as CoreSpiral
|
6
|
-
from spiral.expressions.base import ExprLike
|
7
|
-
from spiral.indexes.index import TextIndex
|
8
|
-
from spiral.indexes.scan import SearchScan
|
9
|
-
from spiral.types_ import Uri
|
10
|
-
|
11
|
-
|
12
|
-
class Indexes:
|
13
|
-
def __init__(self, api: SpiralAPI, spiral: CoreSpiral, *, project_id: str | None = None):
|
14
|
-
self._api = api
|
15
|
-
self._spiral = spiral
|
16
|
-
self._project_id = project_id
|
17
|
-
|
18
|
-
def index(self, identifier: str) -> TextIndex:
|
19
|
-
"""Returns the index with the given identifier."""
|
20
|
-
project_id, index_name = self._parse_identifier(identifier)
|
21
|
-
if project_id is None:
|
22
|
-
raise ValueError("Must provide a fully qualified index identifier.")
|
23
|
-
|
24
|
-
res = list(self._api.project.list_text_indexes(project_id, name=index_name))
|
25
|
-
if len(res) == 0:
|
26
|
-
raise ValueError(f"Index not found: {project_id}.{index_name}")
|
27
|
-
res = res[0]
|
28
|
-
|
29
|
-
return TextIndex(self, self._spiral.get_text_index(res.id), index_name)
|
30
|
-
|
31
|
-
def list_indexes(self) -> list[TextIndexResource]:
|
32
|
-
project_id = self._project_id
|
33
|
-
if project_id is None:
|
34
|
-
raise ValueError("Must provide a project ID to list indexes.")
|
35
|
-
return list(self._api.project.list_text_indexes(project_id))
|
36
|
-
|
37
|
-
def create_text_index(
|
38
|
-
self,
|
39
|
-
identifier: str,
|
40
|
-
# At least one projection is required. All projections must reference the same table!
|
41
|
-
# NOTE(marko): Indexes are currently independent of tables.
|
42
|
-
# That will likely change with the new root resource such as documents.
|
43
|
-
*projections: ExprLike,
|
44
|
-
where: ExprLike | None = None,
|
45
|
-
root_uri: Uri | None = None,
|
46
|
-
exist_ok: bool = False,
|
47
|
-
) -> TextIndex:
|
48
|
-
"""Creates a text index over the table projection.
|
49
|
-
|
50
|
-
See `se.text.field` for how to create and configure indexable fields.
|
51
|
-
|
52
|
-
Args:
|
53
|
-
identifier: The index identifier, in the form `project.index` or `index`.
|
54
|
-
projections: At least one projection expression is required.
|
55
|
-
All projections must reference the same table.
|
56
|
-
where: An optional filter expression to apply to the index.
|
57
|
-
root_uri: The root URI for the index.
|
58
|
-
exist_ok: If True, do not raise an error if the index already exists.
|
59
|
-
"""
|
60
|
-
from spiral import expressions as se
|
61
|
-
|
62
|
-
project_id, index_name = self._parse_identifier(identifier)
|
63
|
-
if project_id is None:
|
64
|
-
raise ValueError("Must provide a fully qualified index identifier.")
|
65
|
-
|
66
|
-
if not projections:
|
67
|
-
raise ValueError("At least one projection is required.")
|
68
|
-
projection = se.merge(*projections)
|
69
|
-
if where is not None:
|
70
|
-
where = se.lift(where)
|
71
|
-
|
72
|
-
core_index = self._spiral.create_text_index(
|
73
|
-
project_id,
|
74
|
-
index_name,
|
75
|
-
projection.__expr__,
|
76
|
-
where.__expr__ if where else None,
|
77
|
-
root_uri=root_uri,
|
78
|
-
# TODO(marko): Validate that if an index exists, it's the same?
|
79
|
-
exist_ok=exist_ok,
|
80
|
-
)
|
81
|
-
|
82
|
-
return TextIndex(self, core_index, index_name)
|
83
|
-
|
84
|
-
def _parse_identifier(self, identifier: str) -> tuple[str | None, str]:
|
85
|
-
parts = identifier.split(".")
|
86
|
-
if len(parts) == 1:
|
87
|
-
return self._project_id, parts[0]
|
88
|
-
elif len(parts) == 2:
|
89
|
-
return parts[0], parts[1]
|
90
|
-
else:
|
91
|
-
raise ValueError(f"Invalid index identifier: {identifier}")
|
92
|
-
|
93
|
-
def search(
|
94
|
-
self,
|
95
|
-
*rank_by: ExprLike,
|
96
|
-
where: ExprLike | None = None,
|
97
|
-
top_k: int = 10,
|
98
|
-
# Do not refresh the index if freshness does not exceed the freshness window.
|
99
|
-
# NOTE(marko): The current implementation fails the query if the index is stale.
|
100
|
-
freshness_window: datetime.timedelta | None = None,
|
101
|
-
) -> SearchScan:
|
102
|
-
"""Queries the index with the given rank by and where clauses.
|
103
|
-
|
104
|
-
Rank by expressions are combined for scoring.
|
105
|
-
See `se.text.find` and `se.text.boost` for scoring expressions.
|
106
|
-
The `where` expression is used to filter the results.
|
107
|
-
It must return a boolean value and use only conjunctions (ANDs). Expressions in where statement
|
108
|
-
are considered either a `must` or `must_not` clause in search terminology.
|
109
|
-
|
110
|
-
Args:
|
111
|
-
rank_by: At least one rank by expression is required.
|
112
|
-
These expressions are used to score the results.
|
113
|
-
where: An optional filter expression to apply to the index.
|
114
|
-
It must return a boolean value and use only conjunctions (ANDs).
|
115
|
-
top_k: The number of top results to return.
|
116
|
-
freshness_window: If provided, the index will not be refreshed if its freshness does not exceed this window.
|
117
|
-
"""
|
118
|
-
from spiral import expressions as se
|
119
|
-
|
120
|
-
if not rank_by:
|
121
|
-
raise ValueError("At least one rank by expression is required.")
|
122
|
-
rank_by = se.or_(*rank_by)
|
123
|
-
if where is not None:
|
124
|
-
where = se.lift(where)
|
125
|
-
|
126
|
-
if freshness_window is None:
|
127
|
-
freshness_window = datetime.timedelta(seconds=0)
|
128
|
-
freshness_window_s = int(freshness_window.total_seconds())
|
129
|
-
|
130
|
-
return SearchScan(
|
131
|
-
self._spiral.open_search_scan(
|
132
|
-
rank_by.__expr__,
|
133
|
-
top_k=top_k,
|
134
|
-
freshness_window_s=freshness_window_s,
|
135
|
-
filter=where.__expr__ if where else None,
|
136
|
-
)
|
137
|
-
)
|
spiral/indexes/index.py
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import datetime
|
2
|
-
from typing import TYPE_CHECKING
|
3
|
-
|
4
|
-
from spiral.core.index import TextIndex as CoreTextIndex
|
5
|
-
from spiral.expressions import Expr
|
6
|
-
|
7
|
-
if TYPE_CHECKING:
|
8
|
-
from spiral.indexes import Indexes
|
9
|
-
|
10
|
-
|
11
|
-
class TextIndex(Expr):
|
12
|
-
def __init__(self, indexes: "Indexes", index: CoreTextIndex, name: str):
|
13
|
-
super().__init__(index.__expr__)
|
14
|
-
|
15
|
-
self._indexes = indexes
|
16
|
-
self._index = index
|
17
|
-
self._name = name
|
18
|
-
|
19
|
-
@property
|
20
|
-
def client(self) -> "Indexes":
|
21
|
-
return self._indexes
|
22
|
-
|
23
|
-
@property
|
24
|
-
def index_id(self) -> str:
|
25
|
-
return self._index.id
|
26
|
-
|
27
|
-
@property
|
28
|
-
def name(self) -> str:
|
29
|
-
return self._name
|
30
|
-
|
31
|
-
def status(self) -> (str, datetime.timedelta | None):
|
32
|
-
"""Fetch the status of the index. If status is ready, returns the staleness of the index."""
|
33
|
-
status = self._index.status()
|
34
|
-
return status.status, datetime.timedelta(seconds=status.staleness_s) if status.staleness_s is not None else None
|
spiral/indexes/scan.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import pyarrow as pa
|
2
|
-
|
3
|
-
from spiral.core.index import SearchScan as CoreSearchScan
|
4
|
-
from spiral.settings import CI, DEV
|
5
|
-
|
6
|
-
|
7
|
-
class SearchScan:
|
8
|
-
def __init__(self, scan: CoreSearchScan):
|
9
|
-
self._scan = scan
|
10
|
-
|
11
|
-
def to_record_batches(self) -> pa.RecordBatchReader:
|
12
|
-
"""Read all results as a record batch reader."""
|
13
|
-
return self._scan.to_record_batches()
|
14
|
-
|
15
|
-
def to_table(self) -> pa.Table:
|
16
|
-
"""Read all results as a table."""
|
17
|
-
# NOTE: Evaluates fully on Rust side which improved debuggability.
|
18
|
-
if DEV and not CI:
|
19
|
-
rb = self._scan.to_record_batch()
|
20
|
-
return pa.Table.from_batches([rb])
|
21
|
-
|
22
|
-
return self.to_record_batches().read_all()
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
-
# sources: spiral/table/statistics.proto
|
3
|
-
# plugin: python-betterproto
|
4
|
-
# This file has been @generated
|
5
|
-
|
6
|
-
from dataclasses import dataclass
|
7
|
-
|
8
|
-
import betterproto
|
9
|
-
|
10
|
-
|
11
|
-
@dataclass(eq=False, repr=False)
|
12
|
-
class ApproximateSetMembership(betterproto.Message):
|
13
|
-
bloom_filter: "BloomFilter" = betterproto.message_field(
|
14
|
-
2, group="membership_strategy"
|
15
|
-
)
|
16
|
-
|
17
|
-
|
18
|
-
@dataclass(eq=False, repr=False)
|
19
|
-
class BloomFilter(betterproto.Message):
|
20
|
-
bit_vec: bytes = betterproto.bytes_field(1)
|
21
|
-
bitmap_bits: int = betterproto.uint64_field(2)
|
22
|
-
k_num: int = betterproto.uint32_field(3)
|