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

Method optimize

tables/index.py:868–942  ·  view source on GitHub ↗

Optimize an index so as to allow faster searches. verbose If True, messages about the progress of the optimization process are printed out.

(self, verbose: bool = False)

Source from the content-addressed store, hash-verified

866 show_stats("Exiting appendLR", tref)
867
868 def optimize(self, verbose: bool = False) -> None:
869 """Optimize an index so as to allow faster searches.
870
871 verbose
872 If True, messages about the progress of the
873 optimization process are printed out.
874
875 """
876 if not self.temp_required:
877 return
878
879 if verbose:
880 self.verbose = True
881 else:
882 self.verbose = debug
883
884 # Initialize last_tover and last_nover
885 self.last_tover = 0
886 self.last_nover = 0
887
888 # Compute the correct optimizations for current optim level
889 opts = calcoptlevels(self.nblocks, self.optlevel, self.indsize)
890 optmedian, optstarts, optstops, optfull = opts
891
892 if debug:
893 print("optvalues:", opts)
894
895 self.create_temp2()
896 # Start the optimization process
897 while True:
898 if optfull:
899 for niter in range(optfull):
900 if self.swap("chunks", "median"):
901 break
902 if self.nblocks > 1:
903 # Swap slices only in the case that we have
904 # several blocks
905 if self.swap("slices", "median"):
906 break
907 if self.swap("chunks", "median"):
908 break
909 if self.swap("chunks", "start"):
910 break
911 if self.swap("chunks", "stop"):
912 break
913 else:
914 if optmedian:
915 if self.swap("chunks", "median"):
916 break
917 if optstarts:
918 if self.swap("chunks", "start"):
919 break
920 if optstops:
921 if self.swap("chunks", "stop"):
922 break
923 break # If we reach this, exit the loop
924
925 # Check if we require a complete sort. Important: this step

Callers 1

_column__create_indexFunction · 0.95

Calls 5

create_temp2Method · 0.95
swapMethod · 0.95
do_complete_sortMethod · 0.95
cleanup_tempMethod · 0.95
calcoptlevelsFunction · 0.85

Tested by

no test coverage detected