-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARROW-17786: [Java] Read CSV files using org.apache.arrow.dataset.jni…
….NativeDatasetFactory (#14182) Support CSV file format in java Dataset API Authored-by: david dali susanibar arce <[email protected]> Signed-off-by: David Li <[email protected]>
- Loading branch information
1 parent
fa3cf78
commit a39f219
Showing
5 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ public enum FileFormat { | |
PARQUET(0), | ||
ARROW_IPC(1), | ||
ORC(2), | ||
CSV(3), | ||
NONE(-1); | ||
|
||
private final int id; | ||
|
49 changes: 49 additions & 0 deletions
49
java/dataset/src/test/java/org/apache/arrow/dataset/CsvWriteSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.Random; | ||
|
||
public class CsvWriteSupport { | ||
private final URI uri; | ||
private final Random random = new Random(); | ||
|
||
public CsvWriteSupport(File outputFolder) throws URISyntaxException { | ||
uri = new URI("file", outputFolder.getPath() + File.separator + "generated-" + random.nextLong() + ".csv", null); | ||
} | ||
|
||
public static CsvWriteSupport writeTempFile(File outputFolder, String... values) | ||
throws URISyntaxException, IOException { | ||
CsvWriteSupport writer = new CsvWriteSupport(outputFolder); | ||
try (FileWriter addValues = new FileWriter(new File(writer.uri), true)) { | ||
for (Object value : values) { | ||
addValues.write(value + "\n"); | ||
} | ||
} | ||
return writer; | ||
} | ||
|
||
public String getOutputURI() { | ||
return uri.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters