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

Method get_neworder

tables/index.py:1385–1427  ·  view source on GitHub ↗

Get sorted & indices values in new order.

(
        self,
        neworder: np.ndarray,
        src_disk: Array,
        tmp_disk: Array,
        lastrow: LastRowArray,
        nslices: int,
        offset: int,
        dtype: npt.DTypeLike,
    )

Source from the content-addressed store, hash-verified

1383 self.dirtycache = True
1384
1385 def get_neworder(
1386 self,
1387 neworder: np.ndarray,
1388 src_disk: Array,
1389 tmp_disk: Array,
1390 lastrow: LastRowArray,
1391 nslices: int,
1392 offset: int,
1393 dtype: npt.DTypeLike,
1394 ) -> None:
1395 """Get sorted & indices values in new order."""
1396 cs = self.chunksize
1397 ncs = ncs2 = self.nchunkslice
1398 self_nslices = self.nslices
1399 tmp = np.empty(shape=self.slicesize, dtype=dtype)
1400 for i in range(nslices):
1401 ns = offset + i
1402 if ns == self_nslices:
1403 # The number of complete chunks in the last row
1404 ncs2 = self.nelementsILR // cs
1405 # Get slices in new order
1406 for j in range(ncs2):
1407 idx = neworder[i * ncs + j]
1408 ins = idx // ncs
1409 inc = (idx - ins * ncs) * cs
1410 ins += offset
1411 nc = j * cs
1412 if ins == self_nslices:
1413 tmp[nc : nc + cs] = lastrow[inc : inc + cs]
1414 else:
1415 tmp[nc : nc + cs] = src_disk[ins, inc : inc + cs]
1416 if ns == self_nslices:
1417 # The number of complete chunks in the last row
1418 lastrow[: ncs2 * cs] = tmp[: ncs2 * cs]
1419 # The elements in the last chunk of the last row will
1420 # participate in the global reordering later on, during
1421 # the phase of sorting of *two* slices at a time
1422 # (including the last row slice, see
1423 # self.reorder_slices()). The caches for last row will
1424 # be updated in self.reorder_slices() too.
1425 # F. Altet 2008-08-25
1426 else:
1427 tmp_disk[ns] = tmp
1428
1429 def swap_chunks(
1430 self, mode: Literal["start", "stop", "median"] = "median"

Callers 1

swap_chunksMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected