1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #pragma once
19 
20 #include <memory>
21 
22 #include "arrow/json/options.h"
23 #include "arrow/result.h"
24 #include "arrow/status.h"
25 #include "arrow/util/macros.h"
26 #include "arrow/util/visibility.h"
27 
28 namespace arrow {
29 
30 class Buffer;
31 class MemoryPool;
32 class Table;
33 class RecordBatch;
34 class Array;
35 class DataType;
36 
37 namespace io {
38 class InputStream;
39 }  // namespace io
40 
41 namespace json {
42 
43 /// A class that reads an entire JSON file into a Arrow Table
44 ///
45 /// The file is expected to consist of individual line-separated JSON objects
46 class ARROW_EXPORT TableReader {
47  public:
48   virtual ~TableReader() = default;
49 
50   /// Read the entire JSON file and convert it to a Arrow Table
51   virtual Result<std::shared_ptr<Table>> Read() = 0;
52 
53   /// Create a TableReader instance
54   static Result<std::shared_ptr<TableReader>> Make(MemoryPool* pool,
55                                                    std::shared_ptr<io::InputStream> input,
56                                                    const ReadOptions&,
57                                                    const ParseOptions&);
58 };
59 
60 ARROW_EXPORT Result<std::shared_ptr<RecordBatch>> ParseOne(ParseOptions options,
61                                                            std::shared_ptr<Buffer> json);
62 
63 }  // namespace json
64 }  // namespace arrow
65