Open asfimport opened 1 year ago
Georeth Zhou: any updates?
David Dali Susanibar Arce / @davisusanibar:
Hi [~georeth]
let me check that
David Dali Susanibar Arce / @davisusanibar: There isn't problem for binary file with less than rowCount <= 2048.
There is a problem with the Validity Buffer, for example for 2049 rows initially there is assigned 504 buffer size, but at the end is requested 512 length size.
Need to continue reviewing for changes needed.
David Dali Susanibar Arce / @davisusanibar:
Base on the current implementation the default compression codec is no compression.
David Dali Susanibar Arce / @davisusanibar: @lidavidm please if you help me with this doubt:
Vector module was designed to support Compression codec (Lz4/Zstd)? Because I only see abstract class AbstractCompressionCodec, then doDecompress is only implemented on Compression module and if I try to used that this will cause cyclic dependency Vector <–> Compression.
Could you help us about a way to implement compression on Vector module?
David Li / @lidavidm: @davisusanibar I don't see the problem? Compression is implemented. Just add dependencies on both modules from your application.
In any case, the first issue here is that Java should detect the file is compressed and error if it doesn't support the codec.
David Li / @lidavidm: The ArrowFileReader/StreamReader take in an optional codec factory instance, so that's probably the underlying issue (the modules are decoupled so by default you can't read a compressed file), but we should still fix the error message when you don't pass in the factory.
David Dali Susanibar Arce / @davisusanibar:
Hi [~georeth]
,
Please consider this PR to add cookbook for read compressed files.
File file = new File("src/main/resources/compare/lz4.arrow");
try (
BufferAllocator rootAllocator = new RootAllocator();
FileInputStream fileInputStream = new FileInputStream(file);
// ArrowFileReader reader = new ArrowFileReader(fileInputStream.getChannel(), rootAllocator): Use CommonsCompressionFactory for compressed files
ArrowFileReader reader = new ArrowFileReader(fileInputStream.getChannel(),
rootAllocator, CommonsCompressionFactory.INSTANCE)
) {
System.out.println("Record batches in file: " + reader.getRecordBlocks().size());
for (ArrowBlock arrowBlock : reader.getRecordBlocks()) {
reader.loadRecordBatch(arrowBlock);
VectorSchemaRoot vectorSchemaRootRecover = reader.getVectorSchemaRoot();
System.out.println("Size: --> " + vectorSchemaRootRecover.getRowCount());
System.out.print(vectorSchemaRootRecover.contentToTSVString());
}
} catch (IOException e) {
e.printStackTrace();
}
Georeth Zhou: @davisusanibar thank you.
It works now.
I encountered this bug when I loaded a dataframe stored in the Arrow IPC format.
Call stack:
This bug can be reproduced by a simple dataframe created by pandas:
Pandas compresses the dataframe by default. If the compression is turned off, Java can load the dataframe. Thus, I guess the bounds checking code is buggy when loading compressed file.
That dataframe can be loaded in polars, pandas and pyarrow, so it's unlikely to be a pandas bug.
Environment: Linux and Windows. Apache Arrow Java version: 10.0.0, 9.0.0, 4.0.1. Pandas 1.4.2 using pyarrow 8.0.0 (anaconda3-2022.05) Reporter: Georeth Zhou
Note: This issue was originally created as ARROW-18198. Please see the migration documentation for further details.