Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle len of -1 in "compressed" buffers from other languages #442

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,12 @@ function uncompress(ptr::Ptr{UInt8}, buffer, compression)
len = unsafe_load(convert(Ptr{Int64}, ptr))
ptr += 8 # skip past uncompressed length as Int64
encodedbytes = unsafe_wrap(Array, ptr, buffer.length - 8)
if len === -1
if len == -1
# len = -1 means data is not compressed
# it's unclear why other language implementations allow this
# but we support to be able to read data produced as such
return length(encodedbytes), copy(encodedbytes)
end

decodedbytes = Vector{UInt8}(undef, len)
if compression.codec === Meta.CompressionTypes.LZ4_FRAME
transcode(LZ4FrameDecompressor, encodedbytes, decodedbytes)
Expand Down
Binary file added test/java_compress_len_neg_one.arrow
Binary file not shown.
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,14 @@ t2 = Arrow.Table(buf2)

end

@testset "# 435" begin

t = Arrow.Table(joinpath(dirname(pathof(Arrow)), "../test/java_compress_len_neg_one.arrow"))
@test length(t) == 15
@test length(t.isA) == 102

end

end # @testset "misc"

end