@@ -18,7 +18,7 @@ from json import loads as json_loads
18
18
from ._generated_version import version_tuple as tiledbpy_version
19
19
from .array_schema import ArraySchema
20
20
from .enumeration import Enumeration
21
- from .cc import TileDBError
21
+ from .cc import TileDBError
22
22
from .ctx import Config , Ctx , default_ctx
23
23
from .vfs import VFS
24
24
@@ -1263,8 +1263,7 @@ cdef class Array(object):
1263
1263
_raise_ctx_err (ctx_ptr , rc )
1264
1264
return Enumeration .from_capsule (self .ctx , PyCapsule_New (enum_ptr , "enum" , NULL ))
1265
1265
1266
- @staticmethod
1267
- def delete_fragments (uri , timestamp_start , timestamp_end , ctx = None ):
1266
+ def delete_fragments (self_or_uri , timestamp_start , timestamp_end , ctx = None ):
1268
1267
"""
1269
1268
Delete a range of fragments from timestamp_start to timestamp_end.
1270
1269
The array needs to be opened in 'm' mode as shown in the example below.
@@ -1295,28 +1294,43 @@ cdef class Array(object):
1295
1294
array([0., 0., 0., 0.])
1296
1295
1297
1296
"""
1298
- # If uri is an instance of Array (user calls the old instance method), issue a warning
1299
- if isinstance (uri , Array ):
1297
+ cdef tiledb_ctx_t * ctx_ptr
1298
+ cdef tiledb_array_t * array_ptr
1299
+ cdef tiledb_query_t * query_ptr
1300
+ cdef bytes buri
1301
+ cdef int rc = TILEDB_OK
1302
+
1303
+ if isinstance (self_or_uri , str ):
1304
+ uri = self_or_uri
1305
+ if not ctx :
1306
+ ctx = default_ctx ()
1307
+
1308
+ ctx_ptr = safe_ctx_ptr (ctx )
1309
+ buri = uri .encode ('UTF-8' )
1310
+
1311
+ rc = tiledb_array_delete_fragments_v2 (
1312
+ ctx_ptr ,
1313
+ buri ,
1314
+ timestamp_start ,
1315
+ timestamp_end
1316
+ )
1317
+ else :
1318
+ array_instance = self_or_uri
1300
1319
warnings .warn (
1301
1320
"The `tiledb.Array.delete_fragments` instance method is deprecated. Use the static method with the same name instead." ,
1302
1321
DeprecationWarning ,
1303
1322
)
1304
- uri = uri .uri
1305
-
1306
- if not ctx :
1307
- ctx = default_ctx ()
1308
-
1309
- cdef tiledb_ctx_t * ctx_ptr = safe_ctx_ptr (ctx )
1310
- cdef bytes buri = uri .encode ('UTF-8' )
1323
+ ctx_ptr = safe_ctx_ptr (array_instance .ctx )
1324
+ array_ptr = < tiledb_array_t * > array_instance .ptr
1325
+ buri = array_instance .uri .encode ('UTF-8' )
1311
1326
1312
- cdef int rc = TILEDB_OK
1313
-
1314
- rc = tiledb_array_delete_fragments_v2 (
1315
- ctx_ptr ,
1316
- buri ,
1317
- timestamp_start ,
1318
- timestamp_end
1319
- )
1327
+ rc = tiledb_array_delete_fragments (
1328
+ ctx_ptr ,
1329
+ array_ptr ,
1330
+ buri ,
1331
+ timestamp_start ,
1332
+ timestamp_end
1333
+ )
1320
1334
if rc != TILEDB_OK :
1321
1335
_raise_ctx_err (ctx_ptr , rc )
1322
1336
0 commit comments