Create an index for this column. .. warning:: In some situations it is useful to get a completely sorted index (CSI). For those cases, it is best to use the :meth:`Column.create_csindex` method instead. Parameters ---------- opt
(
self,
optlevel: int = 6,
kind: str = "medium",
filters: Filters | None = None,
tmp_dir: str | None = None,
_blocksizes: tuple[int, int, int, int] | None = None,
_testmode: bool = False,
_verbose: bool = False,
)
| 3774 | raise ValueError("Non-valid index or slice: %s" % key) |
| 3775 | |
| 3776 | def create_index( |
| 3777 | self, |
| 3778 | optlevel: int = 6, |
| 3779 | kind: str = "medium", |
| 3780 | filters: Filters | None = None, |
| 3781 | tmp_dir: str | None = None, |
| 3782 | _blocksizes: tuple[int, int, int, int] | None = None, |
| 3783 | _testmode: bool = False, |
| 3784 | _verbose: bool = False, |
| 3785 | ) -> int: |
| 3786 | """Create an index for this column. |
| 3787 | |
| 3788 | .. warning:: |
| 3789 | |
| 3790 | In some situations it is useful to get a completely sorted |
| 3791 | index (CSI). For those cases, it is best to use the |
| 3792 | :meth:`Column.create_csindex` method instead. |
| 3793 | |
| 3794 | Parameters |
| 3795 | ---------- |
| 3796 | optlevel : int |
| 3797 | The optimization level for building the index. The levels range |
| 3798 | from 0 (no optimization) up to 9 (maximum optimization). Higher |
| 3799 | levels of optimization mean better chances for reducing the entropy |
| 3800 | of the index at the price of using more CPU, memory and I/O |
| 3801 | resources for creating the index. |
| 3802 | kind : str |
| 3803 | The kind of the index to be built. It can take the 'ultralight', |
| 3804 | 'light', 'medium' or 'full' values. Lighter kinds ('ultralight' |
| 3805 | and 'light') mean that the index takes less space on disk, but will |
| 3806 | perform queries slower. Heavier kinds ('medium' and 'full') mean |
| 3807 | better chances for reducing the entropy of the index (increasing |
| 3808 | the query speed) at the price of using more disk space as well as |
| 3809 | more CPU, memory and I/O resources for creating the index. |
| 3810 | |
| 3811 | Note that selecting a full kind with an optlevel of 9 (the maximum) |
| 3812 | guarantees the creation of an index with zero entropy, that is, a |
| 3813 | completely sorted index (CSI) - provided that the number of rows in |
| 3814 | the table does not exceed the 2**48 figure (that is more than 100 |
| 3815 | trillions of rows). See :meth:`Column.create_csindex` method for a |
| 3816 | more direct way to create a CSI index. |
| 3817 | filters : Filters |
| 3818 | Specify the Filters instance used to compress the index. If None, |
| 3819 | default index filters will be used (currently, zlib level 1 with |
| 3820 | shuffling). |
| 3821 | tmp_dir |
| 3822 | When kind is other than 'ultralight', a temporary file is created |
| 3823 | during the index build process. You can use the tmp_dir argument |
| 3824 | to specify the directory for this temporary file. The default is |
| 3825 | to create it in the same directory as the file containing the |
| 3826 | original table. |
| 3827 | |
| 3828 | """ |
| 3829 | kinds = ["ultralight", "light", "medium", "full"] |
| 3830 | if kind not in kinds: |
| 3831 | raise ValueError("Kind must have any of these values: %s" % kinds) |
| 3832 | if not isinstance(optlevel, int) or (optlevel < 0 or optlevel > 9): |
| 3833 | raise ValueError( |