

import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


_a:      List[str]								=     1000_0000_0000
_a:      Dict								=     1_0000

_a							,     _a:      Any								=     os.path.split(__file__)
_a:      List[str]								=     os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))



def  __lowerCAmelCase (  A    ,       A      ):
	UpperCAmelCase_    			=     pa.Table.from_pydict({"col": [0] * chunk_size}      )
	UpperCAmelCase_    			=     pa.concat_tables([table] * (num_examples // chunk_size)      )
	return datasets.Dataset(A    ,       fingerprint="table_100B"      )

@dataclass
class   __UpperCamelCase      :
	SCREAMING_SNAKE_CASE__      			=       42
	SCREAMING_SNAKE_CASE__      			=       42
	SCREAMING_SNAKE_CASE__      			=       42
	SCREAMING_SNAKE_CASE__      			=       42




	def  __A   (						self		:  Optional[Any]							):


		'''simple docstring'''







		UpperCAmelCase_    			=     np.random.default_rng(self.seed							)
		UpperCAmelCase_    			=     rng.integers(low=self.low						,		high=self.high						,		size=self.size							).tolist()




	def __iter__(						self		:  Dict							):


		'''simple docstring'''







		return iter(self._sampled_values							)




	def __len__(						self		:  Any							):


		'''simple docstring'''







		return self.size



@get_duration
def  __lowerCAmelCase (  A      ):
	UpperCAmelCase_    			=     dataset[0]



@get_duration
def  __lowerCAmelCase (  A      ):
	UpperCAmelCase_    			=     dataset[-1]



@get_duration
def  __lowerCAmelCase (  A      ):
	UpperCAmelCase_    			=     dataset[range(len(A      ) // 2    ,       len(A      ) // 2 + 1024      )]



@get_duration
def  __lowerCAmelCase (  A      ):
	UpperCAmelCase_    			=     dataset[RandIter(0    ,       len(A      )    ,       1024    ,       seed=42      )]



def  __lowerCAmelCase (  ):
	UpperCAmelCase_    			=     {"num examples": SPEED_TEST_N_EXAMPLES}
	UpperCAmelCase_    			=     (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
	print("generating dataset"      )
	UpperCAmelCase_    			=     generate_100B_dataset(num_examples=A    ,       chunk_size=A      )
	print("Functions"      )
	for func in functions:
		print(func.__name__      )
		UpperCAmelCase_    			=     func(A      )

	with open(A    ,       "wb"      ) as f:
		f.write(json.dumps(A      ).encode("utf-8"      )      )


if __name__ == "__main__":  # useful to run the profiler
				benchmark_table_100B()


def  __lowerCAmelCase (  A      ):
	UpperCAmelCase_    			=     len(A      )

	# Set the gap value to be decreased by a factor of 1.3
	# after each iteration
	UpperCAmelCase_    			=     1.3

	# Continue sorting until the gap is 1
	while gap > 1:
		# Decrease the gap value
		UpperCAmelCase_    			=     int(gap / shrink      )

		# Sort the elements using insertion sort
		for i in range(A    ,       len(A      )      ):
			UpperCAmelCase_    			=     collection[i]
			UpperCAmelCase_    			=     i
			while j >= gap and collection[j - gap] > temp:
				UpperCAmelCase_    			=     collection[j - gap]
				j -= gap
			UpperCAmelCase_    			=     temp

	return collection


if __name__ == "__main__":
				import doctest

				doctest.testmod()