This commit is contained in:
Philipp Moritz committed 2019-05-25 18:20:20 -07:00
1 parent 90a3510a87
commit 364971c864
2 files changed
+33 -5

No files matched your search

+15 -5
View File
@@ -67,8 +67,17 @@ cdef class ReadOptions:
def block_size(self, value):
self.options.block_size = value
class ParseOptions:
pass
cdef class ParseOptions:
cdef:
CJSONParseOptions options
__slots__ = ()
cdef _get_reader(input_file, shared_ptr[InputStream]* out):
use_memory_map = False
get_input_stream(input_file, use_memory_map, out)
cdef _get_read_options(ReadOptions read_options, CJSONReadOptions* out):
if read_options is None:
@@ -76,7 +85,6 @@ cdef _get_read_options(ReadOptions read_options, CJSONReadOptions* out):
else:
out[0] = read_options.options
cdef _get_parse_options(ParseOptions parse_options, CJSONParseOptions* out):
if parse_options is None:
out[0] = CJSONParseOptions.Defaults()
@@ -84,12 +92,14 @@ cdef _get_parse_options(ParseOptions parse_options, CJSONParseOptions* out):
out[0] = parse_options.options
def parse_json(input_file, read_options=None, parse_options=None,
def read_json(input_file, read_options=None, parse_options=None,
convert_options=None, MemoryPool memory_pool=None):
cdef:
shared_ptr[InputStream] stream
CJSONReadOptions c_read_options
CJSONParseOptions c_parse_options
shared_ptr[CJSONReader] reader
shared_ptr[CTable] table
_get_reader(input_file, &stream)
_get_read_options(read_options, &c_read_options)
@@ -100,6 +110,6 @@ def parse_json(input_file, read_options=None, parse_options=None,
&reader))
with nogil:
check_status(reader.get().Reader(&table))
check_status(reader.get().Read(&table))
return pyarrow_wrap_table(table)
+18
View File
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from pyarrow._json import ReadOptions, ParseOptions, ConvertOptions, read_json # noqa