



import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


UpperCAmelCase							=       500_000

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

@get_duration
def       A_   (						__a  :					datasets.Dataset		):

				"""simple docstring"""
				a__					   =		dataset.select(range(0			,		len(__a		)			,		2		)		)

@get_duration
def       A_   (						__a  :					datasets.Dataset		):

				"""simple docstring"""
				a__					   =		dataset.sort("""numbers"""		)

@get_duration
def       A_   (						__a  :					datasets.Dataset		):

				"""simple docstring"""
				a__					   =		dataset.shuffle()

@get_duration
def       A_   (						__a  :					datasets.Dataset		):

				"""simple docstring"""
				a__					   =		dataset.train_test_split(0.1		)

@get_duration
def       A_   (						__a  :					datasets.Dataset			,		__a  :					Any=10		):

				"""simple docstring"""
				for shard_id in range(__a		):
								a__					   =		dataset.shard(__a			,		__a		)

def       A_   (						):

				"""simple docstring"""
				a__					   =		{"""num examples""": SPEED_TEST_N_EXAMPLES}
				a__					   =		(select, sort, shuffle, train_test_split, shard)
				with tempfile.TemporaryDirectory() as tmp_dir:
								print("""generating dataset"""		)
								a__					   =		datasets.Features({"""text""": datasets.Value("""string"""		), """numbers""": datasets.Value("""float32"""		)}		)
								a__					   =		generate_example_dataset(
								    os.path.join(__a			,		"""dataset.arrow"""		)			,		__a			,		num_examples=__a		)
								print("""Functions"""		)
								for func in functions:
												print(func.__name__		)
												a__					   =		func(__a		)

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


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





from .hash_table import HashTable
from .number_theory.prime_numbers import is_prime, next_prime





class     __a     (       __UpperCamelCase ):
 def __init__(  self							,					*lowerCAmelCase__							,					**lowerCAmelCase__					)   ->							Any:




        '''simple docstring'''
        super().__init__(*lowerCAmelCase__							,					**lowerCAmelCase__					)
 def 						SCREAMING_SNAKE_CASE__  (  self							,					lowerCAmelCase__							,					lowerCAmelCase__					)   ->							Union[str, Any]:




        '''simple docstring'''
        lowercase__:  str         =  (
            next_prime(value % self.size_table					)
            if not is_prime(value % self.size_table					)
            else value % self.size_table
        )  # gt = bigger than
        return next_prime_gt - (data % next_prime_gt)
 def 						SCREAMING_SNAKE_CASE__  (  self							,					lowerCAmelCase__							,					lowerCAmelCase__							,					lowerCAmelCase__					)   ->							Union[str, Any]:




        '''simple docstring'''
        return (increment * self.__hash_function_a(lowerCAmelCase__							,					lowerCAmelCase__					)) % self.size_table
 def 						SCREAMING_SNAKE_CASE__  (  self							,					lowerCAmelCase__							,					lowerCAmelCase__=None					)   ->							str:




        '''simple docstring'''
        lowercase__:  Dict         =  1
        lowercase__:  str         =  self.hash_function(lowerCAmelCase__					)

        while self.values[new_key] is not None and self.values[new_key] != key:
               lowercase__:  List[Any]         =  (
                   self.__hash_double_function(lowerCAmelCase__							,					lowerCAmelCase__							,					lowerCAmelCase__					)
                   if self.balanced_factor() >= self.lim_charge
                   else None
               )
               if new_key is None:
                      break
               else:
                      i += 1

        return new_key


