
"""simple docstring"""




import itertools
from dataclasses import dataclass
from typing import List, Optional

import pyarrow as pa
import pyarrow.parquet as pq

import datasets
from datasets.table import table_cast


A__      :	List[str]          =    datasets.utils.logging.get_logger(__name__)







@dataclass
class   _lowercase						(       datasets.BuilderConfig				):


     '''simple docstring'''





     _A								=							1_0000
     _A								=							None
     _A								=							None







class   _lowercase						(       datasets.ArrowBasedBuilder				):


     '''simple docstring'''





     _A								=							ParquetConfig



     def  lowerCAmelCase__       (      self  )->					List[str]:
          return datasets.DatasetInfo(features=self.config.features  )



     def  lowerCAmelCase__       (      self ,			__UpperCamelCase  )->					List[str]:
          if not self.config.data_files:
               raise ValueError(F"At least one data file must be specified, but got data_files={self.config.data_files}"  )
          UpperCAmelCase__							: Optional[Any] 							=						dl_manager.download_and_extract(self.config.data_files  )
          if isinstance(__UpperCamelCase ,			(str, list, tuple)  ):
               UpperCAmelCase__							: List[Any] 							=						data_files
               if isinstance(__UpperCamelCase ,			__UpperCamelCase  ):
                    UpperCAmelCase__							: Optional[int] 							=						[files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               UpperCAmelCase__							: Any 							=						[dl_manager.iter_files(__UpperCamelCase  ) for file in files]
               return [datasets.SplitGenerator(name=datasets.Split.TRAIN ,			gen_kwargs={"files": files}  )]
          UpperCAmelCase__							: Any 							=						[]
          for split_name, files in data_files.items():
               if isinstance(__UpperCamelCase ,			__UpperCamelCase  ):
                    UpperCAmelCase__							: Any 							=						[files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               UpperCAmelCase__							: Any 							=						[dl_manager.iter_files(__UpperCamelCase  ) for file in files]
               # Infer features is they are stoed in the arrow schema
               if self.info.features is None:
                    for file in itertools.chain.from_iterable(__UpperCamelCase  ):
                         with open(__UpperCamelCase ,			"rb"  ) as f:
                              UpperCAmelCase__							: Optional[Any] 							=						datasets.Features.from_arrow_schema(pq.read_schema(__UpperCamelCase  )  )
                         break
               splits.append(datasets.SplitGenerator(name=__UpperCamelCase ,			gen_kwargs={"files": files}  )  )
          return splits



     def  lowerCAmelCase__       (      self ,			__UpperCamelCase  )->					pa.Table:
          if self.info.features is not None:
               # more expensive cast to support nested features with keys in a different order
               # allows str <-> int/float or str to Audio for example
               UpperCAmelCase__							: Union[str, Any] 							=						table_cast(__UpperCamelCase ,			self.info.features.arrow_schema  )
          return pa_table



     def  lowerCAmelCase__       (      self ,			__UpperCamelCase  )->					Optional[int]:
          UpperCAmelCase__							: Union[str, Any] 							=						self.info.features.arrow_schema if self.info.features is not None else None
          if self.info.features is not None and self.config.columns is not None:
               if sorted(field.name for field in schema  ) != sorted(self.config.columns  ):
                    raise ValueError(
                        F"Tried to load parquet data with columns '{self.config.columns}' with mismatching features '{self.info.features}'"  )
          for file_idx, file in enumerate(itertools.chain.from_iterable(__UpperCamelCase  )  ):
               with open(__UpperCamelCase ,			"rb"  ) as f:
                    UpperCAmelCase__							: Any 							=						pq.ParquetFile(__UpperCamelCase  )
                    try:
                         for batch_idx, record_batch in enumerate(
                             parquet_file.iter_batches(batch_size=self.config.batch_size ,			columns=self.config.columns  )  ):
                              UpperCAmelCase__							: Union[str, Any] 							=						pa.Table.from_batches([record_batch]  )
                              # Uncomment for debugging (will print the Arrow table size and elements)
                              # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                              # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                              yield F"{file_idx}_{batch_idx}", self._cast_table(__UpperCamelCase  )
                    except ValueError as e:
                         logger.error(F"Failed to read file '{file}' with error {type(__UpperCamelCase  )}: {e}"  )
                         raise





"""simple docstring"""




import math



def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''

     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	:       int = 1_0001		):






     '''simple docstring'''

     try:
          UpperCAmelCase__							: List[str] 							=						int(lowerCAmelCase		)
     except (TypeError, ValueError):
          raise TypeError("Parameter nth must be int or castable to int."		) from None
     if nth <= 0:
          raise ValueError("Parameter nth must be greater than or equal to one."		)
     UpperCAmelCase__							: list[int] 							=						[]
     UpperCAmelCase__							: str 							=						2
     while len(lowerCAmelCase		) < nth:
          if is_prime(lowerCAmelCase		):
               primes.append(lowerCAmelCase		)
               num += 1
          else:
               num += 1
     return primes[len(lowerCAmelCase		) - 1]


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



