vdiravka commented on a change in pull request #2348:
URL: https://github.com/apache/drill/pull/2348#discussion_r741526661



##########
File path: 
contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpJsonOptions.java
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package org.apache.drill.exec.store.http;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.OptionSet;
+import org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions;
+
+@Slf4j
+@Builder
+@Getter
+@Accessors(fluent = true)
+@EqualsAndHashCode
+@ToString
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+@JsonDeserialize(builder = HttpJsonOptions.HttpJsonOptionsBuilder.class)
+public class HttpJsonOptions {
+
+  @JsonInclude
+  private final boolean allowNanInf;
+
+  @JsonInclude
+  private final boolean allTextMode;
+
+  @JsonInclude
+  private final boolean readNumbersAsDouble;
+
+  @JsonInclude
+  private final boolean enableEscapeAnyChar;
+
+  /**
+   * Describes whether or not this reader can unwrap a single root array record
+   * and treat it like a set of distinct records.
+   */
+  @JsonInclude
+  private final boolean skipOuterList;  // Default should be true
+
+  @JsonIgnore
+  public JsonLoaderOptions getJsonOptions(OptionSet optionSet) {
+
+    JsonLoaderOptions options = new JsonLoaderOptions();
+
+    if (optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS) != 
allowNanInf) {
+      options.allowNanInf = allowNanInf;
+    } else {
+      options.allowNanInf = 
optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS);
+    }
+
+    if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != allTextMode) 
{
+
+      options.allTextMode = allTextMode;
+    } else {
+      options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);

Review comment:
       Just logically
   ```
       if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != 
allTextMode) {
         options.allTextMode = allTextMode;
       } else {
         options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);
       }
   ```
   fully equals to:
   ```
       options.allTextMode = allTextMode;
   ```
   
   But you are right about missing option in plugin configs and non default 
system option. In this case we need take into account that system option. To do 
this we need understand, when the plugin config option is absent. It is not 
possible with primitive `boolean`, because `false` can mean missing plugin 
config value or user specified false value. So to fix this need to use Boolean. 
Therefore by default (when option is not specified in plugin config) it will be 
null and for this case we can use system/session option here.

##########
File path: 
contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpJsonOptions.java
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package org.apache.drill.exec.store.http;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.OptionSet;
+import org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions;
+
+@Slf4j
+@Builder
+@Getter
+@Accessors(fluent = true)
+@EqualsAndHashCode
+@ToString
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+@JsonDeserialize(builder = HttpJsonOptions.HttpJsonOptionsBuilder.class)
+public class HttpJsonOptions {
+
+  @JsonInclude
+  private final boolean allowNanInf;
+
+  @JsonInclude
+  private final boolean allTextMode;
+
+  @JsonInclude
+  private final boolean readNumbersAsDouble;
+
+  @JsonInclude
+  private final boolean enableEscapeAnyChar;
+
+  /**
+   * Describes whether or not this reader can unwrap a single root array record
+   * and treat it like a set of distinct records.
+   */
+  @JsonInclude
+  private final boolean skipOuterList;  // Default should be true
+
+  @JsonIgnore
+  public JsonLoaderOptions getJsonOptions(OptionSet optionSet) {
+
+    JsonLoaderOptions options = new JsonLoaderOptions();
+
+    if (optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS) != 
allowNanInf) {
+      options.allowNanInf = allowNanInf;
+    } else {
+      options.allowNanInf = 
optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS);
+    }
+
+    if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != allTextMode) 
{
+
+      options.allTextMode = allTextMode;
+    } else {
+      options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);

Review comment:
       Just logically
   ```
       if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != 
allTextMode) {
         options.allTextMode = allTextMode;
       } else {
         options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);
       }
   ```
   fully equals to:
   ```
       options.allTextMode = allTextMode;
   ```
   
   But you are right about missing option in plugin configs and non default 
system option. In this case, this system option should be taken into account. 
To do this we need to understand, when the plugin config option is absent. It 
is not possible with primitive `boolean`, because `false` can mean missing 
plugin config value or user specified false value. So to fix this need to use 
Boolean. Therefore by default (when option is not specified in plugin config) 
it will be null and for this case we can use system/session option here.

##########
File path: 
contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpJsonOptions.java
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package org.apache.drill.exec.store.http;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.OptionSet;
+import org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions;
+
+@Slf4j
+@Builder
+@Getter
+@Accessors(fluent = true)
+@EqualsAndHashCode
+@ToString
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+@JsonDeserialize(builder = HttpJsonOptions.HttpJsonOptionsBuilder.class)
+public class HttpJsonOptions {
+
+  @JsonInclude
+  private final boolean allowNanInf;
+
+  @JsonInclude
+  private final boolean allTextMode;
+
+  @JsonInclude
+  private final boolean readNumbersAsDouble;
+
+  @JsonInclude
+  private final boolean enableEscapeAnyChar;
+
+  /**
+   * Describes whether or not this reader can unwrap a single root array record
+   * and treat it like a set of distinct records.
+   */
+  @JsonInclude
+  private final boolean skipOuterList;  // Default should be true
+
+  @JsonIgnore
+  public JsonLoaderOptions getJsonOptions(OptionSet optionSet) {
+
+    JsonLoaderOptions options = new JsonLoaderOptions();
+
+    if (optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS) != 
allowNanInf) {
+      options.allowNanInf = allowNanInf;
+    } else {
+      options.allowNanInf = 
optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS);
+    }
+
+    if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != allTextMode) 
{
+
+      options.allTextMode = allTextMode;
+    } else {
+      options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);

Review comment:
       Just logically
   ```
       if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != 
allTextMode) {
         options.allTextMode = allTextMode;
       } else {
         options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);
       }
   ```
   fully equals to:
   ```
       options.allTextMode = allTextMode;
   ```
   
   But you are right about missing option in plugin configs and non default 
system option. In this case, this system option should be taken into account. 
To do this we need to understand, when the plugin config option is absent. It 
is not possible with primitive `boolean`, because `false` can mean missing 
plugin config value or user supplied false value. So to fix this need to use 
Boolean. Therefore by default (when option is not specified in plugin config) 
it will be null and for this case we can use system/session option here.

##########
File path: 
contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpJsonOptions.java
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+package org.apache.drill.exec.store.http;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.OptionSet;
+import org.apache.drill.exec.store.easy.json.loader.JsonLoaderOptions;
+
+@Slf4j
+@Builder
+@Getter
+@Accessors(fluent = true)
+@EqualsAndHashCode
+@ToString
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+@JsonDeserialize(builder = HttpJsonOptions.HttpJsonOptionsBuilder.class)
+public class HttpJsonOptions {
+
+  @JsonInclude
+  private final boolean allowNanInf;
+
+  @JsonInclude
+  private final boolean allTextMode;
+
+  @JsonInclude
+  private final boolean readNumbersAsDouble;
+
+  @JsonInclude
+  private final boolean enableEscapeAnyChar;
+
+  /**
+   * Describes whether or not this reader can unwrap a single root array record
+   * and treat it like a set of distinct records.
+   */
+  @JsonInclude
+  private final boolean skipOuterList;  // Default should be true
+
+  @JsonIgnore
+  public JsonLoaderOptions getJsonOptions(OptionSet optionSet) {
+
+    JsonLoaderOptions options = new JsonLoaderOptions();
+
+    if (optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS) != 
allowNanInf) {
+      options.allowNanInf = allowNanInf;
+    } else {
+      options.allowNanInf = 
optionSet.getBoolean(ExecConstants.JSON_READER_NAN_INF_NUMBERS);
+    }
+
+    if (optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE) != allTextMode) 
{
+
+      options.allTextMode = allTextMode;
+    } else {
+      options.allTextMode = 
optionSet.getBoolean(ExecConstants.JSON_ALL_TEXT_MODE);

Review comment:
       Nice! I agree with the above cases




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to