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 <cstdint>
21 #include <memory>
22 
23 #include "arrow/json/type_fwd.h"
24 #include "arrow/util/visibility.h"
25 
26 namespace arrow {
27 
28 class DataType;
29 class Schema;
30 
31 namespace json {
32 
33 enum class UnexpectedFieldBehavior : char {
34   /// Unexpected JSON fields are ignored
35   Ignore,
36   /// Unexpected JSON fields error out
37   Error,
38   /// Unexpected JSON fields are type-inferred and included in the output
39   InferType
40 };
41 
42 struct ARROW_EXPORT ParseOptions {
43   // Parsing options
44 
45   /// Optional explicit schema (disables type inference on those fields)
46   std::shared_ptr<Schema> explicit_schema;
47 
48   /// Whether objects may be printed across multiple lines (for example pretty-printed)
49   ///
50   /// If true, parsing may be slower.
51   bool newlines_in_values = false;
52 
53   /// How JSON fields outside of explicit_schema (if given) are treated
54   UnexpectedFieldBehavior unexpected_field_behavior = UnexpectedFieldBehavior::InferType;
55 
56   /// Create parsing options with default values
57   static ParseOptions Defaults();
58 };
59 
60 struct ARROW_EXPORT ReadOptions {
61   // Reader options
62 
63   /// Whether to use the global CPU thread pool
64   bool use_threads = true;
65   /// Block size we request from the IO layer; also determines the size of
66   /// chunks when use_threads is true
67   int32_t block_size = 1 << 20;  // 1 MB
68 
69   /// Create read options with default values
70   static ReadOptions Defaults();
71 };
72 
73 }  // namespace json
74 }  // namespace arrow
75