You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by qu...@apache.org on 2023/06/05 13:52:40 UTC

[arrow-julia] branch main updated: Fix case where compressed file reports non-zero buffer length (#448)

This is an automated email from the ASF dual-hosted git repository.

quinnj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-julia.git


The following commit(s) were added to refs/heads/main by this push:
     new e57bdab  Fix case where compressed file reports non-zero buffer length (#448)
e57bdab is described below

commit e57bdab3171df107fba887e50e34632f8a71096b
Author: Jacob Quinn <qu...@gmail.com>
AuthorDate: Mon Jun 5 07:52:34 2023 -0600

    Fix case where compressed file reports non-zero buffer length (#448)
    
    Fixes #437. Thanks to @DrChainsaw for the investigation, proposed fix,
    and test file.
---
 src/table.jl                           |   5 ++---
 test/java_compressed_zero_length.arrow | Bin 0 -> 746 bytes
 test/runtests.jl                       |   8 ++++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/table.jl b/src/table.jl
index 50bcd3b..ada392d 100644
--- a/src/table.jl
+++ b/src/table.jl
@@ -570,10 +570,9 @@ function buildbitmap(batch, rb, nodeidx, bufferidx)
 end
 
 function uncompress(ptr::Ptr{UInt8}, buffer, compression)
-    if buffer.length == 0
-        return 0, UInt8[]
-    end
+    buffer.length == 0 && return 0, UInt8[]
     len = unsafe_load(convert(Ptr{Int64}, ptr))
+    len == 0 && return 0, UInt8[]
     ptr += 8 # skip past uncompressed length as Int64
     encodedbytes = unsafe_wrap(Array, ptr, buffer.length - 8)
     if len == -1
diff --git a/test/java_compressed_zero_length.arrow b/test/java_compressed_zero_length.arrow
new file mode 100644
index 0000000..36345e1
Binary files /dev/null and b/test/java_compressed_zero_length.arrow differ
diff --git a/test/runtests.jl b/test/runtests.jl
index 12c826c..4f84e7c 100644
--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -690,6 +690,14 @@ end
 
 end
 
+@testset "# 437" begin
+
+t = Arrow.Table(joinpath(dirname(pathof(Arrow)), "../test/java_compressed_zero_length.arrow"))
+@test length(t) == 2
+@test length(t.name) == 0
+
+end
+
 end # @testset "misc"
 
 end