






import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


lowercase     :							Union[str, Any]	     =			10_00_00_00_00_00
lowercase     :							Any	     =			1_00_00

lowercase     ,lowercase     :							str	     =			os.path.split(__file__)
lowercase     :							Optional[int]	     =			os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))

def    lowerCAmelCase__		(			_a				:	int     ,					_a				:	int			):
		snake_case_ :							Optional[int]         =				pa.Table.from_pydict({"col": [0] * chunk_size}			)
		snake_case_ :							Tuple         =				pa.concat_tables([table] * (num_examples // chunk_size)			)
		return datasets.Dataset(_a     ,					fingerprint="table_100B"			)




@dataclass
class 						UpperCAmelCase_  :


						'''simple docstring'''




						A   :      int
						A   :      int
						A   :      int
						A   :      int






						def 					_lowerCAmelCase				(		self )       -> Optional[int]:
								snake_case_ :							Optional[int]         =				np.random.default_rng(self.seed )
								snake_case_ :							Any         =				rng.integers(low=self.low						, high=self.high						, size=self.size ).tolist()






						def __iter__(		self )       -> str:
								return iter(self._sampled_values )






						def __len__(		self )       -> Dict:
								return self.size




@get_duration
def    lowerCAmelCase__		(			_a				:	datasets.Dataset			):
		snake_case_ :							Union[str, Any]         =				dataset[0]

@get_duration
def    lowerCAmelCase__		(			_a				:	datasets.Dataset			):
		snake_case_ :							Any         =				dataset[-1]

@get_duration
def    lowerCAmelCase__		(			_a				:	datasets.Dataset			):
		snake_case_ :							Optional[Any]         =				dataset[range(len(_a			) // 2     ,					len(_a			) // 2 + 10_24			)]

@get_duration
def    lowerCAmelCase__		(			_a				:	datasets.Dataset			):
		snake_case_ :							Union[str, Any]         =				dataset[RandIter(0     ,					len(_a			)     ,					10_24     ,					seed=42			)]

def    lowerCAmelCase__		(			):
		snake_case_ :							Optional[int]         =				{"num examples": SPEED_TEST_N_EXAMPLES}
		snake_case_ :							Union[str, Any]         =				(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
		print("generating dataset"			)
		snake_case_ :							List[str]         =				generate_100B_dataset(num_examples=_a     ,					chunk_size=_a			)
		print("Functions"			)
		for func in functions:
				print(func.__name__			)
				snake_case_ :							Tuple         =				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				:	int			):
		if not isinstance(_a     ,					_a			):
				snake_case_ :							Optional[int]         =				F'''Input value of [number={number}] must be an integer'''
				raise TypeError(_a			)
		if number < 1:
				raise ValueError("Input must be a positive integer"			)
		return number * (2 * number - 1)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
