Private part of Leaf.copy() for each kind of leaf.
(
self,
group: Group,
name: str,
start: int,
stop: int,
step: int,
title: str,
filters: Filters | None,
chunkshape: tuple[int, ...] | None,
_log: bool,
**kwargs,
)
| 852 | return rows |
| 853 | |
| 854 | def _g_copy_with_stats( |
| 855 | self, |
| 856 | group: Group, |
| 857 | name: str, |
| 858 | start: int, |
| 859 | stop: int, |
| 860 | step: int, |
| 861 | title: str, |
| 862 | filters: Filters | None, |
| 863 | chunkshape: tuple[int, ...] | None, |
| 864 | _log: bool, |
| 865 | **kwargs, |
| 866 | ) -> tuple[VLArray, int]: |
| 867 | """Private part of Leaf.copy() for each kind of leaf.""" |
| 868 | # Build the new VLArray object |
| 869 | obj = VLArray( |
| 870 | group, |
| 871 | name, |
| 872 | self.atom, |
| 873 | title=title, |
| 874 | filters=filters, |
| 875 | expectedrows=self._v_expectedrows, |
| 876 | chunkshape=chunkshape, |
| 877 | _log=_log, |
| 878 | ) |
| 879 | |
| 880 | # Now, fill the new vlarray with values from the old one |
| 881 | # This is not buffered because we cannot forsee the length |
| 882 | # of each record. So, the safest would be a copy row by row. |
| 883 | # In the future, some analysis can be done in order to buffer |
| 884 | # the copy process. |
| 885 | nrowsinbuf = 1 |
| 886 | start, stop, step = self._process_range_read(start, stop, step) |
| 887 | # Optimized version (no conversions, no type and shape checks, etc...) |
| 888 | nrowscopied = SizeType(0) |
| 889 | nbytes = 0 |
| 890 | if not hasattr(self.atom, "size"): # it is a pseudo-atom |
| 891 | atomsize = self.atom.base.size |
| 892 | else: |
| 893 | atomsize = self.atom.size |
| 894 | for start2 in range(start, stop, step * nrowsinbuf): |
| 895 | # Save the records on disk |
| 896 | stop2 = start2 + step * nrowsinbuf |
| 897 | if stop2 > stop: |
| 898 | stop2 = stop |
| 899 | nparr = self._read_array(start=start2, stop=stop2, step=step)[0] |
| 900 | nobjects = nparr.shape[0] |
| 901 | obj._append(nparr, nobjects) |
| 902 | nbytes += nobjects * atomsize |
| 903 | nrowscopied += 1 |
| 904 | obj.nrows = nrowscopied |
| 905 | return (obj, nbytes) |
| 906 | |
| 907 | def __repr__(self) -> str: |
| 908 | """`VLArray` string representation. |
nothing calls this directly
no test coverage detected