




'''simple docstring'''







import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


lowerCAmelCase_    	=							1_0_0_0_0_0_0_0_0_0_0_0
lowerCAmelCase_    	=							1_0_0_0_0

lowerCAmelCase_	,					lowerCAmelCase_    	=							os.path.split(__file__)
lowerCAmelCase_    	=							os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))







def 	_A			(   UpperCAmelCase			,UpperCAmelCase	):






   '''simple docstring'''







   A__         =    pa.Table.from_pydict({'col': [0] * chunk_size}	)
   A__         =    pa.concat_tables([table] * (num_examples // chunk_size)	)
   return datasets.Dataset(UpperCAmelCase			,fingerprint='table_100B'	)

@dataclass
class   _snake_case:
 __snake_case:       int
 __snake_case:       int
 __snake_case:       int
 __snake_case:       int






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






    """simple docstring"""


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






 def __iter__(self					:     Union[str, Any]						)					->      Optional[Any]:






    """simple docstring"""


    return iter(self._sampled_values						)






 def __len__(self					:     int						)					->      Optional[Any]:






    """simple docstring"""


    return self.size







@get_duration
def 	_A			(   UpperCAmelCase	):






   '''simple docstring'''







   A__         =    dataset[0]







@get_duration
def 	_A			(   UpperCAmelCase	):






   '''simple docstring'''







   A__         =    dataset[-1]







@get_duration
def 	_A			(   UpperCAmelCase	):






   '''simple docstring'''







   A__         =    dataset[range(len(UpperCAmelCase	) // 2			,len(UpperCAmelCase	) // 2 + 1024	)]







@get_duration
def 	_A			(   UpperCAmelCase	):






   '''simple docstring'''







   A__         =    dataset[RandIter(0			,len(UpperCAmelCase	)			,1024			,seed=42	)]







def 	_A			(   ):






   '''simple docstring'''







   A__         =    {'num examples': SPEED_TEST_N_EXAMPLES}
   A__         =    (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
   print('generating dataset'	)
   A__         =    generate_100B_dataset(num_examples=UpperCAmelCase			,chunk_size=UpperCAmelCase	)
   print('Functions'	)
   for func in functions:
      print(func.__name__	)
      A__         =    func(UpperCAmelCase	)

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


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








'''simple docstring'''







def 	_A			(   UpperCAmelCase	):






   '''simple docstring'''







   if not isinstance(UpperCAmelCase			,UpperCAmelCase	) or not all(
       isinstance(UpperCAmelCase			,UpperCAmelCase	) and item >= 0 for item in citations	):
      raise ValueError('The citations should be a list of non negative integers.'	)

   citations.sort()
   A__         =    len(UpperCAmelCase	)

   for i in range(UpperCAmelCase	):
      if citations[len_citations - 1 - i] <= i:
         return i

   return len_citations


if __name__ == "__main__":
    import doctest

    doctest.testmod()


