MCPcopy Create free account
hub / github.com/PyTables/PyTables / _column__create_index

Function _column__create_index

tables/table.py:267–372  ·  view source on GitHub ↗
(
    self: Column,
    optlevel: int,
    kind: str,
    filters: Filters | None,
    tmp_dir: str,
    blocksizes: tuple[int, int, int, int],
    verbose: bool,
)

Source from the content-addressed store, hash-verified

265
266
267def _column__create_index(
268 self: Column,
269 optlevel: int,
270 kind: str,
271 filters: Filters | None,
272 tmp_dir: str,
273 blocksizes: tuple[int, int, int, int],
274 verbose: bool,
275) -> int:
276 name = self.name
277 table = self.table
278 dtype = self.dtype
279 descr = self.descr
280 index = self.index
281 get_node = table._v_file._get_node
282
283 # Warn if the index already exists
284 if index:
285 raise ValueError(
286 "%s for column '%s' already exists. If you want to "
287 "re-create it, please, try with reindex() method "
288 "better" % (str(index), str(self.pathname))
289 )
290
291 # Check that the datatype is indexable.
292 if dtype.str[1:] == "u8":
293 raise NotImplementedError(
294 "indexing 64-bit unsigned integer columns "
295 "is not supported yet, sorry"
296 )
297 if dtype.kind == "c":
298 raise TypeError("complex columns can not be indexed")
299 if dtype.shape != ():
300 raise TypeError("multidimensional columns can not be indexed")
301
302 # Get the indexes group for table, and if not exists, create it
303 try:
304 itgroup = get_node(_index_pathname_of(table))
305 except NoSuchNodeError:
306 itgroup = create_indexes_table(table)
307
308 # Create the necessary intermediate groups for descriptors
309 idgroup = itgroup
310 dname = ""
311 pathname = descr._v_pathname
312 if pathname != "":
313 inames = pathname.split("/")
314 for iname in inames:
315 if dname == "":
316 dname = iname
317 else:
318 dname += "/" + iname
319 try:
320 idgroup = get_node(f"{itgroup._v_pathname}/{dname}")
321 except NoSuchNodeError:
322 idgroup = create_indexes_descr(idgroup, dname, iname, filters)
323
324 # Create the atom

Callers 1

create_indexMethod · 0.85

Calls 9

optimizeMethod · 0.95
_index_pathname_ofFunction · 0.85
create_indexes_tableFunction · 0.85
create_indexes_descrFunction · 0.85
IndexClass · 0.85
_set_column_indexingMethod · 0.80
_add_rows_to_indexMethod · 0.80
from_dtypeMethod · 0.45
dtypeMethod · 0.45

Tested by

no test coverage detected