





"""simple docstring"""
import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json



@pytest.fixture
def   __lowerCamelCase     (							a_  :	str							)    ->   str:
      __SCREAMING_SNAKE_CASE     :List[str]	       =						tmp_path / '''file.jsonl'''
      __SCREAMING_SNAKE_CASE     :Dict	       =						textwrap.dedent(
          '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''							)
      with open(a_				,     '''w'''							) as f:
            f.write(a_							)
      return str(a_							)



@pytest.fixture
def   __lowerCamelCase     (							a_  :	Optional[int]							)    ->   str:
      __SCREAMING_SNAKE_CASE     :int	       =						tmp_path / '''file_utf16_encoded.jsonl'''
      __SCREAMING_SNAKE_CASE     :Dict	       =						textwrap.dedent(
          '''\
        {"col_1": -1}
        {"col_1": 1, "col_2": 2}
        {"col_1": 10, "col_2": 20}
        '''							)
      with open(a_				,     '''w'''				,     encoding='''utf-16'''							) as f:
            f.write(a_							)
      return str(a_							)



@pytest.fixture
def   __lowerCamelCase     (							a_  :	Any							)    ->   int:
      __SCREAMING_SNAKE_CASE     :Optional[int]	       =						tmp_path / '''file_with_list_of_dicts.json'''
      __SCREAMING_SNAKE_CASE     :Any	       =						textwrap.dedent(
          '''\
        [
            {"col_1": -1},
            {"col_1": 1, "col_2": 2},
            {"col_1": 10, "col_2": 20}
        ]
        '''							)
      with open(a_				,     '''w'''							) as f:
            f.write(a_							)
      return str(a_							)



@pytest.fixture
def   __lowerCamelCase     (							a_  :	Dict							)    ->   Optional[int]:
      __SCREAMING_SNAKE_CASE     :Dict	       =						tmp_path / '''file_with_list_of_dicts_field.json'''
      __SCREAMING_SNAKE_CASE     :str	       =						textwrap.dedent(
          '''\
        {
            "field1": 1,
            "field2": "aabb",
            "field3": [
                {"col_1": -1},
                {"col_1": 1, "col_2": 2},
                {"col_1": 10, "col_2": 20}
            ]
        }
        '''							)
      with open(a_				,     '''w'''							) as f:
            f.write(a_							)
      return str(a_							)



@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''				,     [
        ('''jsonl_file''', {}),
        ('''jsonl_file_utf16_encoded''', {'''encoding''': '''utf-16'''}),
        ('''json_file_with_list_of_dicts''', {}),
        ('''json_file_with_list_of_dicts_field''', {'''field''': '''field3'''}),
    ]				,     )
def   __lowerCamelCase     (							a_  :	Union[str, Any]				,     a_  :	str				,     a_  :	Dict							)    ->   List[Any]:
      __SCREAMING_SNAKE_CASE     :str	       =						Json(**a_							)
      __SCREAMING_SNAKE_CASE     :int	       =						json._generate_tables([[request.getfixturevalue(a_							)]]							)
      __SCREAMING_SNAKE_CASE     :Dict	       =						pa.concat_tables([table for _, table in generator]							)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20]}







@pytest.mark.parametrize(
    '''file_fixture, config_kwargs'''				,     [
        (
            '''jsonl_file''',
            {'''features''': Features({'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							)},
        ),
        (
            '''json_file_with_list_of_dicts''',
            {'''features''': Features({'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							)},
        ),
        (
            '''json_file_with_list_of_dicts_field''',
            {
                '''field''': '''field3''',
                '''features''': Features(
                    {'''col_1''': Value('''int64'''							), '''col_2''': Value('''int64'''							), '''missing_col''': Value('''string'''							)}							),
            },
        ),
    ]				,     )
def   __lowerCamelCase     (							a_  :	List[Any]				,     a_  :	Optional[Any]				,     a_  :	int							)    ->   Optional[int]:
      __SCREAMING_SNAKE_CASE     :List[str]	       =						Json(**a_							)
      __SCREAMING_SNAKE_CASE     :Optional[Any]	       =						json._generate_tables([[request.getfixturevalue(a_							)]]							)
      __SCREAMING_SNAKE_CASE     :Any	       =						pa.concat_tables([table for _, table in generator]							)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20], "missing_col": [None, None, None]}






"""simple docstring"""
def   __lowerCamelCase     (							a_  :	str							)    ->   int:
      __SCREAMING_SNAKE_CASE     :List[Any]	       =						0
      for plain_chr in plain_text:
            __SCREAMING_SNAKE_CASE     :List[str]	       =						(
                ord(a_							) + (hash_value << 6) + (hash_value << 16) - hash_value
            )
      return hash_value