Skip to content

Commit 3420a7f

Browse files
kounelisagisypatia
andauthored
Wrap data_protocol API (#2287)
Co-authored-by: Ypatia Tsavliri <ypatia.tsav@gmail.com>
1 parent d57d517 commit 3420a7f

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Fix double-offset bug in chunked sparse CSV row indices by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2279
77

88
## Improvements
9+
* Wrap `data_protocol` API by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2287
910
* Expose overwrite parameter for saving a profile by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2277
1011
* Add label index support for aggregation by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2272
1112
* Expose the fill value setter at the Python layer by @kounelisagis in https://github.com/TileDB-Inc/TileDB-Py/pull/2274

tiledb/ctx.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,18 @@ def get_stats(self, print_out: bool = True, json: bool = False):
452452
else:
453453
return output
454454

455+
def data_protocol(self, uri: str):
456+
"""Returns the data protocol version for the given URI.
457+
458+
:param uri: URI to check for data protocol version
459+
:return: DataProtocol enum value (DATA_PROTOCOL_V2 or DATA_PROTOCOL_V3)
460+
:rtype: tiledb.DataProtocol
461+
462+
For TileDB Cloud URIs (tiledb://), returns either v2 (legacy) or v3 (TileDB 3.0+).
463+
For non-TileDB URIs (S3, Azure, GCS, etc.), returns v2.
464+
"""
465+
return super().data_protocol(uri)
466+
455467

456468
class CtxMixin:
457469
"""

tiledb/libtiledb/context.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ void init_context(py::module& m) {
2424
.def("config", &Context::config)
2525
.def("set_tag", &Context::set_tag)
2626
.def("get_stats", &Context::stats)
27-
.def("is_supported_fs", &Context::is_supported_fs);
27+
.def("is_supported_fs", &Context::is_supported_fs)
28+
#if TILEDB_VERSION_MAJOR >= 3 || \
29+
(TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR >= 30)
30+
.def("data_protocol", &Context::data_protocol)
31+
#endif
32+
;
2833
}
2934

3035
void init_config(py::module& m) {

tiledb/libtiledb/enum.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ void init_enums(py::module& m) {
182182
py::enum_<tiledb_current_domain_type_t>(m, "CurrentDomainType")
183183
.value("NDRECTANGLE", TILEDB_NDRECTANGLE);
184184
#endif
185+
186+
#if TILEDB_VERSION_MAJOR >= 3 || \
187+
(TILEDB_VERSION_MAJOR == 2 && TILEDB_VERSION_MINOR >= 30)
188+
py::enum_<tiledb::Context::DataProtocol>(m, "DataProtocol")
189+
.value("DATA_PROTOCOL_V2", tiledb::Context::DataProtocol::v2)
190+
.value("DATA_PROTOCOL_V3", tiledb::Context::DataProtocol::v3);
191+
#endif
185192
// test helpers to check enum name against typed value
186193
m.def("_enum_string", &tiledb::impl::type_to_str);
187194
m.def(

0 commit comments

Comments
 (0)