jinchengchenghh commented on code in PR #41646: URL: https://github.com/apache/arrow/pull/41646#discussion_r1602895634
########## java/dataset/src/main/java/org/apache/arrow/dataset/scanner/csv/CsvFragmentScanOptions.java: ########## @@ -0,0 +1,94 @@ +/* + * 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.io.Serializable; +import java.nio.ByteBuffer; +import java.util.Locale; +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; + +public class CsvFragmentScanOptions implements Serializable, 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. + * + * @param convertOptions same struct in CPP + * @param readOptions same struct in CPP + * @param parseOptions same struct in CPP + */ + public CsvFragmentScanOptions(CsvConvertOptions convertOptions, + Map<String, String> readOptions, + Map<String, String> parseOptions) { + this.convertOptions = convertOptions; + this.readOptions = readOptions; + this.parseOptions = parseOptions; + } + + public String typeName() { + return FileFormat.CSV.name().toLowerCase(Locale.ROOT); + } + + /** + * File format id. + * + * @return id + */ + public int fileFormatId() { + return FileFormat.CSV.id(); + } + + /** + * Serialize this class to ByteBuffer and then called by jni call. + * + * @return DirectByteBuffer + */ + public ByteBuffer serialize() { + Map<String, String> options = Stream.concat(Stream.concat(readOptions.entrySet().stream(), + parseOptions.entrySet().stream()), Review Comment: Insert all the options to a map because it is a easy implement, and now we don't have same option name in CPP parse_options and read_options, but to further extend, we may need to serialize more accurately. I'm open to here if you think we should serialize each option -- 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]
