




import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__UpperCamelCase      : Any					      =   100_000_000_000
__UpperCamelCase      : str					      =   10_000

__UpperCamelCase      ,						__UpperCamelCase      : Optional[int]					      =   os.path.split(__file__)
__UpperCamelCase      : Dict					      =   os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))





def 	__A	(			__lowerCamelCase							,    __lowerCamelCase					)   -> datasets.Dataset:
	a		       =							pa.Table.from_pydict({"""col""": [0] * chunk_size}					)
	a		       =							pa.concat_tables([table] * (num_examples // chunk_size)					)
	return datasets.Dataset(__lowerCamelCase							,    fingerprint="""table_100B"""					)

@dataclass
class 	__lowerCAmelCase			:
							UpperCamelCase__        =						42
							UpperCamelCase__        =						42
							UpperCamelCase__        =						42
							UpperCamelCase__        =						42
							def    lowerCamelCase__							(		self		:Dict       ):







								'''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		:Optional[Any]       ):







								'''simple docstring'''







								return iter(self._sampled_values       )





							def __len__(		self		:int       ):







								'''simple docstring'''







								return self.size







@get_duration
def 	__A	(			__lowerCamelCase					)   -> Optional[Any]:
	a		       =							dataset[0]





@get_duration
def 	__A	(			__lowerCamelCase					)   -> Any:
	a		       =							dataset[-1]





@get_duration
def 	__A	(			__lowerCamelCase					)   -> List[str]:
	a		       =							dataset[range(len(__lowerCamelCase					) // 2							,    len(__lowerCamelCase					) // 2 + 1024					)]





@get_duration
def 	__A	(			__lowerCamelCase					)   -> Optional[Any]:
	a		       =							dataset[RandIter(0							,    len(__lowerCamelCase					)							,    1024							,    seed=42					)]





def 	__A	(			)   -> Optional[int]:
	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=__lowerCamelCase							,    chunk_size=__lowerCamelCase					)
	print("""Functions"""					)
	for func in functions:
		print(func.__name__					)
		a		       =							func(__lowerCamelCase					)

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


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







import math





def 	__A	(			__lowerCamelCase					)   -> bool:

	if 1 < number < 4:
		# 2 and 3 are primes
		return True
	elif number < 2 or number % 2 == 0 or number % 3 == 0:
		# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
		return False

	# All primes number are in format of 6k +/- 1
	for i in range(5							,    int(math.sqrt(__lowerCamelCase					) + 1					)							,    6					):
		if number % i == 0 or number % (i + 2) == 0:
			return False
	return True





def 	__A	(			__lowerCamelCase = 6008_5147_5143					)   -> int:

	try:
		a		       =							int(__lowerCamelCase					)
	except (TypeError, ValueError):
		raise TypeError("""Parameter n must be int or castable to int."""					)
	if n <= 0:
		raise ValueError("""Parameter n must be greater than or equal to one."""					)
	a		       =							0
	if is_prime(__lowerCamelCase					):
		return n
	while n % 2 == 0:
		n //= 2
	if is_prime(__lowerCamelCase					):
		return n
	for i in range(3							,    int(math.sqrt(__lowerCamelCase					)					) + 1							,    2					):
		if n % i == 0:
			if is_prime(n // i					):
				a		       =							n // i
				break
			elif is_prime(__lowerCamelCase					):
				a		       =							i
	return max_number


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

