





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


__magic_name__					:				List[str]	= 1_0_0_0_0_0_0_0_0_0_0_0
__magic_name__					:				List[str]	= 1_0_0_0_0

__magic_name__	,       __magic_name__					:				str	= os.path.split(__file__)
__magic_name__					:				Optional[Any]	= os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))

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






@dataclass
class        lowercase__ :

			"""simple docstring"""
			__lowerCAmelCase    :							int
			__lowerCAmelCase    :							int
			__lowerCAmelCase    :							int
			__lowerCAmelCase    :							int







			def      _a			(			self						):






									'''simple docstring'''







									UpperCamelCase							:		str							      = np.random.default_rng(self.seed						)
									UpperCamelCase							:		Optional[Any]							      = rng.integers(low=self.low	,      high=self.high	,      size=self.size						).tolist()







			def __iter__(			self						):






									'''simple docstring'''







									return iter(self._sampled_values						)







			def __len__(			self						):






									'''simple docstring'''







									return self.size


@get_duration
def     UpperCamelCase       (SCREAMING_SNAKE_CASE    ):
						UpperCamelCase							:		Dict							      = dataset[0]

@get_duration
def     UpperCamelCase       (SCREAMING_SNAKE_CASE    ):
						UpperCamelCase							:		str							      = dataset[-1]

@get_duration
def     UpperCamelCase       (SCREAMING_SNAKE_CASE    ):
						UpperCamelCase							:		List[Any]							      = dataset[range(len(SCREAMING_SNAKE_CASE    ) // 2       ,    len(SCREAMING_SNAKE_CASE    ) // 2 + 1024    )]

@get_duration
def     UpperCamelCase       (SCREAMING_SNAKE_CASE    ):
						UpperCamelCase							:		Dict							      = dataset[RandIter(0       ,    len(SCREAMING_SNAKE_CASE    )       ,    1024       ,    seed=42    )]

def     UpperCamelCase       ():
						UpperCamelCase							:		List[Any]							      = {"""num examples""": SPEED_TEST_N_EXAMPLES}
						UpperCamelCase							:		Dict							      = (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=SCREAMING_SNAKE_CASE       ,    chunk_size=SCREAMING_SNAKE_CASE    )
						print("""Functions"""    )
						for func in functions:
												print(func.__name__    )
												UpperCamelCase							:		Union[str, 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"""


def     UpperCamelCase       (SCREAMING_SNAKE_CASE    ):
						UpperCamelCase							:		Tuple							      = 0
						for plain_chr in plain_text:
												UpperCamelCase							:		List[str]							      = (
												    ord(SCREAMING_SNAKE_CASE    ) + (hash_value << 6) + (hash_value << 16) - hash_value
												)
						return hash_value



