




import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


_A							    =	1000_0000_0000
_A							    =	1_0000

_A    , _A							    =	os.path.split(__file__)
_A							    =	os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))
def 						lowerCAmelCase_       (	__a	,	__a )       ->			datasets.Dataset:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: List[str]	     =pa.Table.from_pydict({'''col''': [0] * chunk_size} )
							SCREAMING_SNAKE_CASE			: Optional[Any]	     =pa.concat_tables([table] * (num_examples // chunk_size) )
							return datasets.Dataset(__a	,	fingerprint='''table_100B''' )


@dataclass
class 							_lowerCAmelCase		:
				lowerCamelCase__									=    42
				lowerCamelCase__									=    42
				lowerCamelCase__									=    42
				lowerCamelCase__									=    42




				def     __a		( self							)    ->      List[Any]:
											SCREAMING_SNAKE_CASE			: Optional[Any]	     =np.random.default_rng(self.seed							)
											SCREAMING_SNAKE_CASE			: str	     =rng.integers(low=self.low		,		high=self.high		,		size=self.size							).tolist()




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







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







@get_duration
def 						lowerCAmelCase_       (	__a )       ->			Tuple:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: Optional[int]	     =dataset[0]
@get_duration
def 						lowerCAmelCase_       (	__a )       ->			Union[str, Any]:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: str	     =dataset[-1]
@get_duration
def 						lowerCAmelCase_       (	__a )       ->			List[Any]:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: int	     =dataset[range(len(__a ) // 2	,	len(__a ) // 2 + 1024 )]
@get_duration
def 						lowerCAmelCase_       (	__a )       ->			List[Any]:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: int	     =dataset[RandIter(0	,	len(__a )	,	1024	,	seed=42 )]
def 						lowerCAmelCase_       (	)       ->			Tuple:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: Tuple	     ={'''num examples''': SPEED_TEST_N_EXAMPLES}
							SCREAMING_SNAKE_CASE			: Dict	     =(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
							print('''generating dataset''' )
							SCREAMING_SNAKE_CASE			: Dict	     =generate_100B_dataset(num_examples=__a	,	chunk_size=__a )
							print('''Functions''' )
							for func in functions:
														print(func.__name__ )
														SCREAMING_SNAKE_CASE			: List[str]	     =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()












from __future__ import annotations
def 						lowerCAmelCase_       (	__a	,	__a	,	__a	,	__a )       ->			None:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE     ,							SCREAMING_SNAKE_CASE			: Any	     =m - 1, 0
							while i >= 0 and j < n:
														if key == mat[i][j]:
																					print(f'Key {key} found at row- {i + 1} column- {j + 1}' )
																					return
														if key < mat[i][j]:
																					i -= 1
														else:
																					j += 1
							print(f'Key {key} not found' )
def 						lowerCAmelCase_       (	)       ->			None:





							"""simple docstring"""





							SCREAMING_SNAKE_CASE			: int	     =[[2, 5, 7], [4, 8, 13], [9, 11, 15], [12, 17, 20]]
							SCREAMING_SNAKE_CASE			: List[str]	     =int(input('''Enter the element to be searched:''' ) )
							print(__a )
							search_in_a_sorted_matrix(__a	,	len(__a )	,	len(mat[0] )	,	__a )


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							main()






