






import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__snake_case							 =  10_00_00_00_00_00
__snake_case							 =  1_00_00

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


def   _A       (    SCREAMING_SNAKE_CASE__  :     int					,  SCREAMING_SNAKE_CASE__  :     int	):
    UpperCamelCase	:Optional[Any]     							=       pa.Table.from_pydict({'''col''': [0] * chunk_size}	)
    UpperCamelCase	:Optional[int]     							=       pa.concat_tables([table] * (num_examples // chunk_size)	)
    return datasets.Dataset(SCREAMING_SNAKE_CASE__					,  fingerprint='''table_100B'''	)







@dataclass
class       UpperCAmelCase_						:



      """simple docstring"""
      UpperCamelCase_    : int
      UpperCamelCase_    : int
      UpperCamelCase_    : int
      UpperCamelCase_    : int
      def    UpperCAmelCase						(    self			)    ->				Any:
          UpperCamelCase	:List[str]     							=       np.random.default_rng(self.seed			)
          UpperCamelCase	:Dict     							=       rng.integers(low=self.low   ,    high=self.high   ,    size=self.size			).tolist()
      def __iter__(    self			)    ->				Optional[Any]:
          return iter(self._sampled_values			)




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







@get_duration
def   _A       (    SCREAMING_SNAKE_CASE__  :     datasets.Dataset	):
    UpperCamelCase	:Any     							=       dataset[0]


@get_duration
def   _A       (    SCREAMING_SNAKE_CASE__  :     datasets.Dataset	):
    UpperCamelCase	:Any     							=       dataset[-1]


@get_duration
def   _A       (    SCREAMING_SNAKE_CASE__  :     datasets.Dataset	):
    UpperCamelCase	:List[str]     							=       dataset[range(len(SCREAMING_SNAKE_CASE__	) // 2					,  len(SCREAMING_SNAKE_CASE__	) // 2 + 1024	)]


@get_duration
def   _A       (    SCREAMING_SNAKE_CASE__  :     datasets.Dataset	):
    UpperCamelCase	:int     							=       dataset[RandIter(0					,  len(SCREAMING_SNAKE_CASE__	)					,  1024					,  seed=42	)]


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

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


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













def   _A       (    SCREAMING_SNAKE_CASE__  :     int = 998001	):

    # fetches the next number
    for number in range(n - 1					,  9999					,  -1	):
        UpperCamelCase	:Union[str, Any]     							=       str(SCREAMING_SNAKE_CASE__	)

        # checks whether 'str_number' is a palindrome.
        if str_number == str_number[::-1]:
            UpperCamelCase	:Dict     							=       999

            # if 'number' is a product of two 3-digit numbers
            # then number is the answer otherwise fetch next number.
            while divisor != 99:
                if (number % divisor == 0) and (len(str(number // divisor	)	) == 3.0):
                    return number
                divisor -= 1
    raise ValueError('''That number is larger than our acceptable range.'''	)


if __name__ == "__main__":
 print(f'''{solution() = }''')





