|
5 | 5 | import pyarrow as pa |
6 | 6 | import tiledb |
7 | 7 |
|
| 8 | +import tiledbsoma.libtiledbsoma as clib |
| 9 | + |
8 | 10 | from . import util, util_arrow, util_tiledb |
9 | 11 | from .logging import log_io |
| 12 | +from .query_condition import QueryCondition |
10 | 13 | from .soma_collection import SOMACollectionBase |
11 | 14 | from .tiledb_array import TileDBArray |
12 | 15 | from .types import Ids, NTuple |
@@ -157,6 +160,55 @@ def is_indexed(self) -> Literal[False]: |
157 | 160 | def get_index_column_names(self) -> Sequence[str]: |
158 | 161 | return [] |
159 | 162 |
|
| 163 | + def read_using_lib_temp( |
| 164 | + self, |
| 165 | + *, |
| 166 | + # TODO: find the right syntax to get the typechecker to accept args like ``ids=slice(0,10)`` |
| 167 | + # ids: Optional[Union[Sequence[int], Slice]] = None, |
| 168 | + ids: Optional[Any] = None, |
| 169 | + value_filter: Optional[str] = None, |
| 170 | + column_names: Optional[Sequence[str]] = None, |
| 171 | + result_order: Optional[str] = None, |
| 172 | + # TODO: batch_size |
| 173 | + # TODO: partition, |
| 174 | + # TODO: platform_config, |
| 175 | + ) -> Iterator[pa.Table]: |
| 176 | + """ |
| 177 | + TODO: copy the text |
| 178 | + """ |
| 179 | + |
| 180 | + with self._tiledb_open("r") as A: |
| 181 | + dim_names, attr_names = util_tiledb.split_column_names( |
| 182 | + A.schema, column_names |
| 183 | + ) |
| 184 | + |
| 185 | + query_condition = None |
| 186 | + if value_filter is not None: |
| 187 | + # query_condition = tiledb.QueryCondition(value_filter) |
| 188 | + query_condition = QueryCondition(value_filter) |
| 189 | + |
| 190 | + # As an arg to this method, `column_names` is optional-None. For the pybind11 |
| 191 | + # code it's optional-[]. |
| 192 | + lib_column_names = [] if column_names is None else column_names |
| 193 | + |
| 194 | + sr = clib.SOMAReader( |
| 195 | + self._uri, |
| 196 | + name=self.name, |
| 197 | + schema=A.schema, # query_condition needs this |
| 198 | + column_names=lib_column_names, |
| 199 | + query_condition=query_condition, |
| 200 | + ) |
| 201 | + |
| 202 | + # TODO: platform_config |
| 203 | + # TODO: batch_size |
| 204 | + # TODO: result_order |
| 205 | + |
| 206 | + sr.submit() |
| 207 | + |
| 208 | + while arrow_table := sr.read_next(): |
| 209 | + # yield util_arrow.ascii_to_unicode_pyarrow_readback(batch) |
| 210 | + yield arrow_table # XXX what other post-processing |
| 211 | + |
160 | 212 | def read( |
161 | 213 | self, |
162 | 214 | *, |
|
0 commit comments