lidavidm commented on code in PR #41646:
URL: https://github.com/apache/arrow/pull/41646#discussion_r1687533928


##########
java/dataset/src/main/java/org/apache/arrow/dataset/scanner/MapUtil.java:
##########


Review Comment:
   Ideally this would be in a separate namespace that we do not export in 
module-info.java



##########
java/dataset/src/main/java/org/apache/arrow/dataset/scanner/csv/CsvFragmentScanOptions.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.arrow.dataset.scanner.csv;
+
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.arrow.dataset.file.FileFormat;
+import org.apache.arrow.dataset.scanner.FragmentScanOptions;
+import org.apache.arrow.dataset.scanner.MapUtil;
+
+public class CsvFragmentScanOptions implements FragmentScanOptions {
+  private final CsvConvertOptions convertOptions;
+  private final Map<String, String> readOptions;
+  private final Map<String, String> parseOptions;
+
+  /**
+   * CSV scan options, map to CPP struct CsvFragmentScanOptions. The key in 
config map is the field
+   * name of mapping cpp struct
+   *
+   * @param convertOptions similar to CsvFragmentScanOptions#convert_options 
in CPP, the ArrowSchema
+   *     represents column_types, convert data option such as null value 
recognition.
+   * @param readOptions similar to CsvFragmentScanOptions#read_options in CPP, 
specify how to read
+   *     the file such as block_size
+   * @param parseOptions similar to CsvFragmentScanOptions#parse_options in 
CPP, parse file option
+   *     such as delimiter
+   */
+  public CsvFragmentScanOptions(
+      CsvConvertOptions convertOptions,
+      Map<String, String> readOptions,
+      Map<String, String> parseOptions) {
+    this.convertOptions = convertOptions;
+    this.readOptions = readOptions;
+    this.parseOptions = parseOptions;
+  }
+
+  /**
+   * File format id.

Review Comment:
   docstring is out of date



##########
java/dataset/src/main/cpp/jni_wrapper.cc:
##########
@@ -363,6 +366,65 @@ std::shared_ptr<arrow::Buffer> 
LoadArrowBufferFromByteBuffer(JNIEnv* env, jobjec
   return buffer;
 }
 
+inline bool ParseBool(const std::string& value) { return value == "true" ? 
true : false; }
+
+/// \brief Construct FragmentScanOptions from config map
+#ifdef ARROW_CSV
+arrow::Result<std::shared_ptr<arrow::dataset::FragmentScanOptions>>
+ToCsvFragmentScanOptions(const std::unordered_map<std::string, std::string>& 
configs) {
+  std::shared_ptr<arrow::dataset::CsvFragmentScanOptions> options =
+      std::make_shared<arrow::dataset::CsvFragmentScanOptions>();
+  for (auto const& it : configs) {
+    auto& key = it.first;
+    auto& value = it.second;

Review Comment:
   ```suggestion
     for (const auto& [key, value] : configs) {
   ```



##########
java/dataset/src/test/java/org/apache/arrow/dataset/TestFragmentScanOptions.java:
##########


Review Comment:
   Can we test that it fails without the options set?



##########
java/dataset/src/main/java/org/apache/arrow/dataset/scanner/MapUtil.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.arrow.dataset.scanner;
+
+import java.util.Map;
+
+/** The utility class for Map. */
+public class MapUtil {

Review Comment:
   Util classes should be final and have a private constructor



##########
java/dataset/src/main/java/org/apache/arrow/dataset/scanner/csv/CsvFragmentScanOptions.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.arrow.dataset.scanner.csv;
+
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.arrow.dataset.file.FileFormat;
+import org.apache.arrow.dataset.scanner.FragmentScanOptions;
+import org.apache.arrow.dataset.scanner.MapUtil;
+
+public class CsvFragmentScanOptions implements FragmentScanOptions {
+  private final CsvConvertOptions convertOptions;
+  private final Map<String, String> readOptions;
+  private final Map<String, String> parseOptions;
+
+  /**
+   * CSV scan options, map to CPP struct CsvFragmentScanOptions. The key in 
config map is the field
+   * name of mapping cpp struct
+   *
+   * @param convertOptions similar to CsvFragmentScanOptions#convert_options 
in CPP, the ArrowSchema
+   *     represents column_types, convert data option such as null value 
recognition.
+   * @param readOptions similar to CsvFragmentScanOptions#read_options in CPP, 
specify how to read
+   *     the file such as block_size
+   * @param parseOptions similar to CsvFragmentScanOptions#parse_options in 
CPP, parse file option
+   *     such as delimiter
+   */
+  public CsvFragmentScanOptions(
+      CsvConvertOptions convertOptions,
+      Map<String, String> readOptions,
+      Map<String, String> parseOptions) {
+    this.convertOptions = convertOptions;
+    this.readOptions = readOptions;
+    this.parseOptions = parseOptions;
+  }
+
+  /**
+   * File format id.
+   *
+   * @return id
+   */
+  @Override
+  public FileFormat fileFormat() {
+    return FileFormat.CSV;
+  }
+
+  /**
+   * Serialize this class to string array and then called by JNI call.
+   *
+   * @return string array as Map JNI bridge format.
+   */

Review Comment:
   Can we make it clearer that this is not part of the public API?



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