



import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


UpperCAmelCase__			:   str      			=    100000000000
UpperCAmelCase__			:   Union[str, Any]      			=    10000

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


def 	_A	(   _UpperCamelCase      ,					_UpperCamelCase			):
				_UpperCAmelCase						:  Union[str, Any]     					=	pa.Table.from_pydict({'''col''': [0] * chunk_size}			)
				_UpperCAmelCase						:  Tuple     					=	pa.concat_tables([table] * (num_examples // chunk_size)			)
				return datasets.Dataset(lowerCAmelCase_      ,					fingerprint='''table_100B'''			)





@dataclass
class 							lowerCAmelCase_		:
		SCREAMING_SNAKE_CASE_       :			int
		SCREAMING_SNAKE_CASE_       :			int
		SCREAMING_SNAKE_CASE_       :			int
		SCREAMING_SNAKE_CASE_       :			int







		def 					a_  (    self  :   List[str]					)       ->		Any:


						'''simple docstring'''







						_UpperCAmelCase						:  Dict     					=	np.random.default_rng(self.seed					)
						_UpperCAmelCase						:  Any     					=	rng.integers(low=self.low       ,		high=self.high       ,		size=self.size					).tolist()







		def __iter__(    self  :   Any					)       ->		List[Any]:


						'''simple docstring'''







						return iter(self._sampled_values					)







		def __len__(    self  :   Union[str, Any]					)       ->		List[str]:


						'''simple docstring'''







						return self.size


@get_duration
def 	_A	(   _UpperCamelCase			):
				_UpperCAmelCase						:  Any     					=	dataset[0]


@get_duration
def 	_A	(   _UpperCamelCase			):
				_UpperCAmelCase						:  Any     					=	dataset[-1]


@get_duration
def 	_A	(   _UpperCamelCase			):
				_UpperCAmelCase						:  Optional[Any]     					=	dataset[range(len(lowerCAmelCase_			) // 2      ,					len(lowerCAmelCase_			) // 2 + 1_024			)]


@get_duration
def 	_A	(   _UpperCamelCase			):
				_UpperCAmelCase						:  Tuple     					=	dataset[RandIter(0      ,					len(lowerCAmelCase_			)      ,					1_024      ,					seed=42			)]


def 	_A	(   ):
				_UpperCAmelCase						:  Union[str, Any]     					=	{'''num examples''': SPEED_TEST_N_EXAMPLES}
				_UpperCAmelCase						:  int     					=	(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
				print('''generating dataset'''			)
				_UpperCAmelCase						:  List[str]     					=	generate_100B_dataset(num_examples=lowerCAmelCase_      ,					chunk_size=lowerCAmelCase_			)
				print('''Functions'''			)
				for func in functions:
								print(func.__name__			)
								_UpperCAmelCase						:  str     					=	func(lowerCAmelCase_			)

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


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




def       lowerCAmelCase			(		lowerCAmelCase_			, lowerCAmelCase_			)->			set:
				assert isinstance(lowerCAmelCase_			, lowerCAmelCase_			), f"""The input value of [set_a={set_a}] is not a set"""
				assert isinstance(lowerCAmelCase_			, lowerCAmelCase_			), f"""The input value of [set_b={set_b}] is not a set"""

				return {a + b for a in set_a for b in set_b}


if __name__ == "__main__":
						from doctest import testmod

						testmod()