wgtmac opened a new issue, #34432:
URL: https://github.com/apache/arrow/issues/34432

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   To reproduce the issue, use the C++ code below to write and read arrow IPC 
file. I use the 11.0.0 version. Make sure `arrow_testing` is linked to enable 
`ArrayFromJSON` utility.
   
   ```cpp
   #include "arrow/io/api.h"
   #include "arrow/filesystem/localfs.h"
   #include "arrow/ipc/feather.h"
   #include "arrow/ipc/writer.h"
   #include "arrow/table.h"
   #include "arrow/testing/gtest_util.h"
   
   #include <iostream>
   
   int main(int argc, char** argv) {
     auto codec_type = ::arrow::Compression::UNCOMPRESSED;
     std::string path = "/tmp/test.arrow";
     auto schema = arrow::schema({field("a", arrow::int32()), field("b", 
arrow::utf8())});
     auto a = arrow::ArrayFromJSON(arrow::int32(), "[1, 2, 3]");
     auto b = arrow::ArrayFromJSON(arrow::utf8(), R"(["a", "b", "c"])");
     auto table = arrow::Table::Make(schema, {a, b});
     auto out = arrow::io::FileOutputStream::Open(path).MoveValueUnsafe();
     ::arrow::ipc::IpcWriteOptions options{
         .codec = arrow::util::Codec::Create(codec_type).MoveValueUnsafe(),
         .metadata_version = arrow::ipc::MetadataVersion::V5,
     };
     auto writer = ::arrow::ipc::MakeFileWriter(std::move(out), schema, 
options).MoveValueUnsafe();
     writer->WriteTable(*table).ok();
     writer->Close().ok();
   
     auto fs = arrow::fs::LocalFileSystem();
     auto in = fs.OpenInputFile(path).MoveValueUnsafe();
     auto reader = arrow::ipc::feather::Reader::Open(in).MoveValueUnsafe();
     std::shared_ptr<arrow::Table> read_table;
     if (reader->Read(&read_table).ok()) {
       std::cout << read_table->ToString() << std::endl;
     } else {
       std::cerr << "Failed to read table" << std::endl;
     }
     return 0;
   }
   ```
   
   On the Java side, use the code below:
   ```java
   package test.arrow;
   
   import org.apache.arrow.memory.RootAllocator;
   import org.apache.arrow.vector.ipc.ArrowFileReader;
   import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
   import org.apache.commons.io.IOUtils;
   
   import java.io.DataInputStream;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
   
   public class ArrowReaderTest {
   
     public static void main(String[] args) throws IOException {
       InputStream inputStream = new DataInputStream(new 
FileInputStream("/tmp/test.arrow"));
       RootAllocator allocator = new RootAllocator(Long.MAX_VALUE);
       SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel
         (IOUtils.toByteArray(inputStream));
       try (ArrowFileReader reader = new ArrowFileReader(channel, allocator)) {
         while (reader.loadNextBatch()) {
           
System.out.println(reader.getVectorSchemaRoot().contentToTSVString());
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   ```
   
   The issues vary with different `codec_type`.
   1. UNCOMPRESSED: Both C++ and Java readers can read correct data.
   2. SNAPPY: Both C++ and Java readers cannot read any data. (Same for GZIP)
   3. ZSTD: C++ reader can read data correctly. But the Java reader throws 
`java.lang.NegativeArraySizeException` at 
`org.apache.arrow.vector.VarCharVector.get(VarCharVector.java:115)`
   
   ### Component(s)
   
   C++, Java


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