Skip to content

Commit b2e2653

Browse files
authored
DRILL-8243: Move JSON Config Options Out of HTTP Plugin (#2570)
1 parent 0e83894 commit b2e2653

File tree

2 files changed

+236
-109
lines changed

2 files changed

+236
-109
lines changed

contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpJsonOptions.java

Lines changed: 17 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -18,111 +18,31 @@
1818

1919
package org.apache.drill.exec.store.http;
2020

21-
import com.fasterxml.jackson.annotation.JsonIgnore;
21+
2222
import com.fasterxml.jackson.annotation.JsonInclude;
2323
import com.fasterxml.jackson.annotation.JsonProperty;
2424
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2525
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
2626
import org.apache.drill.common.PlanStringBuilder;
2727
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;
3129
import java.util.Objects;
3230

3331
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
3432
@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 {
5534
@JsonProperty
5635
private final TupleMetadata schema;
5736

5837
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);
6539
this.schema = builder.schema;
6640
}
6741

6842
public static HttpJsonOptionsBuilder builder() {
6943
return new HttpJsonOptionsBuilder();
7044
}
7145

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-
}
12646

12747
@JsonProperty("schema")
12848
public TupleMetadata schema() {
@@ -166,53 +86,41 @@ public String toString() {
16686
}
16787

16888
@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 {
18290
private TupleMetadata schema;
18391

184-
public HttpJsonOptionsBuilder allowNanInf(Boolean allowNanInf) {
185-
this.allowNanInf = allowNanInf;
92+
public HttpJsonOptionsBuilder schema(TupleMetadata schema) {
93+
this.schema = schema;
18694
return this;
18795
}
18896

18997
public HttpJsonOptionsBuilder allTextMode(Boolean allTextMode) {
190-
this.allTextMode = allTextMode;
98+
super.allTextMode(allTextMode);
19199
return this;
192100
}
193101

194-
public HttpJsonOptionsBuilder readNumbersAsDouble(Boolean readNumbersAsDouble) {
195-
this.readNumbersAsDouble = readNumbersAsDouble;
102+
public HttpJsonOptionsBuilder allowNanInf(Boolean allowNanInf) {
103+
super.allowNanInf(allowNanInf);
196104
return this;
197105
}
198106

199107
public HttpJsonOptionsBuilder enableEscapeAnyChar(Boolean enableEscapeAnyChar) {
200-
this.enableEscapeAnyChar = enableEscapeAnyChar;
108+
super.enableEscapeAnyChar(enableEscapeAnyChar);
201109
return this;
202110
}
203111

204-
public HttpJsonOptionsBuilder skipMalformedRecords(Boolean skipMalformedRecords) {
205-
this.skipMalformedRecords = skipMalformedRecords;
112+
public HttpJsonOptionsBuilder readNumbersAsDouble(Boolean readNumbersAsDouble) {
113+
super.readNumbersAsDouble(readNumbersAsDouble);
206114
return this;
207115
}
208116

209-
public HttpJsonOptionsBuilder skipMalformedDocument(Boolean skipMalformedDocument) {
210-
this.skipMalformedDocument = skipMalformedDocument;
117+
public HttpJsonOptionsBuilder skipMalformedRecords(Boolean skipMalformedRecords) {
118+
super.skipMalformedRecords(skipMalformedRecords);
211119
return this;
212120
}
213121

214-
public HttpJsonOptionsBuilder schema(TupleMetadata schema) {
215-
this.schema = schema;
122+
public HttpJsonOptionsBuilder skipMalformedDocument(Boolean skipMalformedDocument) {
123+
super.skipMalformedDocument(skipMalformedDocument);
216124
return this;
217125
}
218126

0 commit comments

Comments
 (0)