|
18 | 18 |
|
19 | 19 | package org.apache.drill.exec.store.http; |
20 | 20 |
|
21 | | -import com.fasterxml.jackson.annotation.JsonIgnore; |
| 21 | + |
22 | 22 | import com.fasterxml.jackson.annotation.JsonInclude; |
23 | 23 | import com.fasterxml.jackson.annotation.JsonProperty; |
24 | 24 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
25 | 25 | import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; |
26 | 26 | import org.apache.drill.common.PlanStringBuilder; |
27 | 27 | import org.apache.drill.exec.record.metadata.TupleMetadata; |
28 | | -import org.apache.drill.exec.server.options.OptionSet; |
29 | | -import org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions; |
30 | | - |
| 28 | +import org.apache.drill.exec.store.easy.json.config.JsonConfigOptions; |
31 | 29 | import java.util.Objects; |
32 | 30 |
|
33 | 31 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) |
34 | 32 | @JsonDeserialize(builder = HttpJsonOptions.HttpJsonOptionsBuilder.class) |
35 | | -public class HttpJsonOptions { |
36 | | - |
37 | | - @JsonProperty |
38 | | - private final Boolean allowNanInf; |
39 | | - |
40 | | - @JsonProperty |
41 | | - private final Boolean allTextMode; |
42 | | - |
43 | | - @JsonProperty |
44 | | - private final Boolean readNumbersAsDouble; |
45 | | - |
46 | | - @JsonProperty |
47 | | - private final Boolean enableEscapeAnyChar; |
48 | | - |
49 | | - @JsonProperty |
50 | | - private final Boolean skipMalformedRecords; |
51 | | - |
52 | | - @JsonProperty |
53 | | - private final Boolean skipMalformedDocument; |
54 | | - |
| 33 | +public class HttpJsonOptions extends JsonConfigOptions { |
55 | 34 | @JsonProperty |
56 | 35 | private final TupleMetadata schema; |
57 | 36 |
|
58 | 37 | HttpJsonOptions(HttpJsonOptionsBuilder builder) { |
59 | | - this.allowNanInf = builder.allowNanInf; |
60 | | - this.allTextMode = builder.allTextMode; |
61 | | - this.readNumbersAsDouble = builder.readNumbersAsDouble; |
62 | | - this.enableEscapeAnyChar = builder.enableEscapeAnyChar; |
63 | | - this.skipMalformedRecords = builder.skipMalformedRecords; |
64 | | - this.skipMalformedDocument = builder.skipMalformedDocument; |
| 38 | + super(builder.allowNanInf, builder.allTextMode, builder.readNumbersAsDouble, builder.enableEscapeAnyChar, builder.skipMalformedDocument, builder.skipMalformedRecords); |
65 | 39 | this.schema = builder.schema; |
66 | 40 | } |
67 | 41 |
|
68 | 42 | public static HttpJsonOptionsBuilder builder() { |
69 | 43 | return new HttpJsonOptionsBuilder(); |
70 | 44 | } |
71 | 45 |
|
72 | | - @JsonIgnore |
73 | | - public JsonLoaderOptions getJsonOptions(OptionSet optionSet) { |
74 | | - JsonLoaderOptions options = new JsonLoaderOptions(optionSet); |
75 | | - if (allowNanInf != null) { |
76 | | - options.allowNanInf = allowNanInf; |
77 | | - } |
78 | | - if (allTextMode != null) { |
79 | | - options.allTextMode = allTextMode; |
80 | | - } |
81 | | - if (readNumbersAsDouble != null) { |
82 | | - options.readNumbersAsDouble = readNumbersAsDouble; |
83 | | - } |
84 | | - if (enableEscapeAnyChar != null) { |
85 | | - options.enableEscapeAnyChar = enableEscapeAnyChar; |
86 | | - } |
87 | | - if (skipMalformedRecords != null) { |
88 | | - options.skipMalformedRecords = skipMalformedRecords; |
89 | | - } |
90 | | - if (skipMalformedDocument != null) { |
91 | | - options.skipMalformedDocument = skipMalformedDocument; |
92 | | - } |
93 | | - |
94 | | - return options; |
95 | | - } |
96 | | - |
97 | | - @JsonProperty("allowNanInf") |
98 | | - public Boolean allowNanInf() { |
99 | | - return this.allowNanInf; |
100 | | - } |
101 | | - |
102 | | - @JsonProperty("allTextMode") |
103 | | - public Boolean allTextMode() { |
104 | | - return this.allTextMode; |
105 | | - } |
106 | | - |
107 | | - @JsonProperty("readNumbersAsDouble") |
108 | | - public Boolean readNumbersAsDouble() { |
109 | | - return this.readNumbersAsDouble; |
110 | | - } |
111 | | - |
112 | | - @JsonProperty("enableEscapeAnyChar") |
113 | | - public Boolean enableEscapeAnyChar() { |
114 | | - return this.enableEscapeAnyChar; |
115 | | - } |
116 | | - |
117 | | - @JsonProperty("skipMalformedRecords") |
118 | | - public Boolean skipMalformedRecords() { |
119 | | - return this.skipMalformedRecords; |
120 | | - } |
121 | | - |
122 | | - @JsonProperty("skipMalformedDocument") |
123 | | - public Boolean skipMalformedDocument() { |
124 | | - return this.skipMalformedDocument; |
125 | | - } |
126 | 46 |
|
127 | 47 | @JsonProperty("schema") |
128 | 48 | public TupleMetadata schema() { |
@@ -166,53 +86,41 @@ public String toString() { |
166 | 86 | } |
167 | 87 |
|
168 | 88 | @JsonPOJOBuilder(withPrefix = "") |
169 | | - public static class HttpJsonOptionsBuilder { |
170 | | - private Boolean allowNanInf; |
171 | | - |
172 | | - private Boolean allTextMode; |
173 | | - |
174 | | - private Boolean readNumbersAsDouble; |
175 | | - |
176 | | - private Boolean enableEscapeAnyChar; |
177 | | - |
178 | | - private Boolean skipMalformedRecords; |
179 | | - |
180 | | - private Boolean skipMalformedDocument; |
181 | | - |
| 89 | + public static class HttpJsonOptionsBuilder extends JsonConfigOptionsBuilder { |
182 | 90 | private TupleMetadata schema; |
183 | 91 |
|
184 | | - public HttpJsonOptionsBuilder allowNanInf(Boolean allowNanInf) { |
185 | | - this.allowNanInf = allowNanInf; |
| 92 | + public HttpJsonOptionsBuilder schema(TupleMetadata schema) { |
| 93 | + this.schema = schema; |
186 | 94 | return this; |
187 | 95 | } |
188 | 96 |
|
189 | 97 | public HttpJsonOptionsBuilder allTextMode(Boolean allTextMode) { |
190 | | - this.allTextMode = allTextMode; |
| 98 | + super.allTextMode(allTextMode); |
191 | 99 | return this; |
192 | 100 | } |
193 | 101 |
|
194 | | - public HttpJsonOptionsBuilder readNumbersAsDouble(Boolean readNumbersAsDouble) { |
195 | | - this.readNumbersAsDouble = readNumbersAsDouble; |
| 102 | + public HttpJsonOptionsBuilder allowNanInf(Boolean allowNanInf) { |
| 103 | + super.allowNanInf(allowNanInf); |
196 | 104 | return this; |
197 | 105 | } |
198 | 106 |
|
199 | 107 | public HttpJsonOptionsBuilder enableEscapeAnyChar(Boolean enableEscapeAnyChar) { |
200 | | - this.enableEscapeAnyChar = enableEscapeAnyChar; |
| 108 | + super.enableEscapeAnyChar(enableEscapeAnyChar); |
201 | 109 | return this; |
202 | 110 | } |
203 | 111 |
|
204 | | - public HttpJsonOptionsBuilder skipMalformedRecords(Boolean skipMalformedRecords) { |
205 | | - this.skipMalformedRecords = skipMalformedRecords; |
| 112 | + public HttpJsonOptionsBuilder readNumbersAsDouble(Boolean readNumbersAsDouble) { |
| 113 | + super.readNumbersAsDouble(readNumbersAsDouble); |
206 | 114 | return this; |
207 | 115 | } |
208 | 116 |
|
209 | | - public HttpJsonOptionsBuilder skipMalformedDocument(Boolean skipMalformedDocument) { |
210 | | - this.skipMalformedDocument = skipMalformedDocument; |
| 117 | + public HttpJsonOptionsBuilder skipMalformedRecords(Boolean skipMalformedRecords) { |
| 118 | + super.skipMalformedRecords(skipMalformedRecords); |
211 | 119 | return this; |
212 | 120 | } |
213 | 121 |
|
214 | | - public HttpJsonOptionsBuilder schema(TupleMetadata schema) { |
215 | | - this.schema = schema; |
| 122 | + public HttpJsonOptionsBuilder skipMalformedDocument(Boolean skipMalformedDocument) { |
| 123 | + super.skipMalformedDocument(skipMalformedDocument); |
216 | 124 | return this; |
217 | 125 | } |
218 | 126 |
|
|
0 commit comments