
'''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


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   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE,						__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Any            =  pa.Table.from_pydict({"col": [0] * chunk_size}    )
    snake_case_	:      Union[str, Any]            =  pa.concat_tables([table] * (num_examples // chunk_size)    )
    return datasets.Dataset(__SCREAMING_SNAKE_CASE,						fingerprint="table_100B"    )






@dataclass
class 				UpperCAmelCase_			:
 UpperCAmelCase_						      =  42
 UpperCAmelCase_						      =  42
 UpperCAmelCase_						      =  42
 UpperCAmelCase_						      =  42





 def     snake_case__						(      self):
     snake_case_	:      Tuple            =  np.random.default_rng(self.seed)
     snake_case_	:      List[str]            =  rng.integers(low=self.low	,    high=self.high	,    size=self.size).tolist()





 def __iter__(      self):
     return iter(self._sampled_values)





 def __len__(      self):
     return self.size


@get_duration
def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      List[str]            =  dataset[0]

@get_duration
def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Optional[Any]            =  dataset[-1]

@get_duration
def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Any            =  dataset[range(len(__SCREAMING_SNAKE_CASE    ) // 2,						len(__SCREAMING_SNAKE_CASE    ) // 2 + 1_0_2_4    )]

@get_duration
def   UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      str            =  dataset[RandIter(0,						len(__SCREAMING_SNAKE_CASE    ),						1_0_2_4,						seed=4_2    )]

def   UpperCamelCase_       (		):
    """simple docstring"""






    snake_case_	:      Optional[Any]            =  {"num examples": SPEED_TEST_N_EXAMPLES}
    snake_case_	:      List[Any]            =  (get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
    print("generating dataset"    )
    snake_case_	:      Any            =  generate_100B_dataset(num_examples=__SCREAMING_SNAKE_CASE,						chunk_size=__SCREAMING_SNAKE_CASE    )
    print("Functions"    )
    for func in functions:
        print(func.__name__    )
        snake_case_	:      Any            =  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()






'''simple docstring'''
from __future__ import annotations

from typing import Any






class 				UpperCAmelCase_			:





 def __init__(      self	,    lowercase_	,    lowercase_):  # noqa: A002
     snake_case_	:      List[str]            =  item
     snake_case_	:      Dict            =  next






class 				UpperCAmelCase_			:





 def __init__(      self):
     snake_case_	:      Node | None            =  None
     snake_case_	:      List[str]            =  0





 def     snake_case__						(      self	,    lowercase_):
     snake_case_	:      List[Any]            =  Node(lowercase_	,    self.head)
     self.size += 1





 def     snake_case__						(      self):
     # Switched 'self.is_empty()' to 'self.head is None'
     # because mypy was considering the possibility that 'self.head'
     # can be None in below else part and giving error
     if self.head is None:
         return None
     else:
         snake_case_	:      List[Any]            =  self.head.item
         snake_case_	:      Any            =  self.head.next
         self.size -= 1
         return item





 def     snake_case__						(      self):
     return self.head is None





 def __str__(      self):
     if self.is_empty():
         return ""
     else:
         snake_case_	:      Dict            =  self.head
         snake_case_	:      Optional[Any]            =  ""
         snake_case_	:      list[str]            =  []
         while iterate:
             item_list.append(str(iterate.item))
             snake_case_	:      List[str]            =  iterate.next

         snake_case_	:      Optional[Any]            =  " --> ".join(lowercase_)

         return item_str





 def __len__(      self):
     return self.size




