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

ARROW-4081: [Go] Sum methods panic when the array is empty #3906

Closed
wants to merge 5 commits into from

Conversation

alexandreyc
Copy link
Contributor

Nothing fundamental but more idiomatic and coherent.

@wesm wesm changed the title Slight changes [Go] Slight changes Mar 14, 2019
@wesm
Copy link
Member

wesm commented Mar 14, 2019

@alexandreyc it looks like you're developing out of your master branch and so some unrelated changes got exposed here

@wesm
Copy link
Member

wesm commented Mar 14, 2019

maybe make this PR the fix for ARROW-4081? It's fine to combine those stylistic changes with this I think

@codecov-io
Copy link

codecov-io commented Mar 14, 2019

Codecov Report

Merging #3906 into master will decrease coverage by 18.97%.
The diff coverage is 93.75%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #3906       +/-   ##
===========================================
- Coverage   87.84%   68.86%   -18.98%     
===========================================
  Files         726       60      -666     
  Lines       89340     4134    -85206     
  Branches     1252        0     -1252     
===========================================
- Hits        78480     2847    -75633     
+ Misses      10742     1182     -9560     
+ Partials      118      105       -13
Impacted Files Coverage Δ
go/arrow/math/float64.go 44.44% <100%> (+15.87%) ⬆️
go/arrow/math/uint64.go 44.44% <100%> (+15.87%) ⬆️
go/arrow/math/int64.go 44.44% <100%> (+15.87%) ⬆️
go/arrow/schema.go 97.36% <90%> (+0.03%) ⬆️
go/arrow/math/float64_sse4_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/memory/memory_sse4_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/uint64_sse4_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/int64_sse4_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/uint64_amd64.go 33.33% <0%> (ø) ⬆️
go/arrow/math/int64_amd64.go 33.33% <0%> (ø) ⬆️
... and 673 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 954e3f4...e914235. Read the comment docs.

@alexandreyc
Copy link
Contributor Author

Yes ok, we will use this PR for ARROW-4081. I just need a bit more work to be sure for the fix. I will do it pretty soon.

@wesm wesm changed the title [Go] Slight changes WIP ARROW-4081: [Go] Sum methods on Mac OS X panic when the array is empty Mar 15, 2019
@alexandreyc alexandreyc changed the title WIP ARROW-4081: [Go] Sum methods on Mac OS X panic when the array is empty WIP ARROW-4081: [Go] Sum methods panic when the array is empty Mar 15, 2019
@alexandreyc
Copy link
Contributor Author

The issue is not specific to macOS since I've been able to reproduce it on Linux.

When reading the code it's clear why we panic when an empty array is passed: we take a pointer on the first element of the array to pass to low-level optimized function.

See for instance:

p1 = unsafe.Pointer(&buf[0])

What do you think about this fix?

@sbinet @stuartcarnie

Copy link
Contributor

@sbinet sbinet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the general approach SGTM.

func Test{{.Name}}Funcs_SumEmpty(t *testing.T) {
b := array.New{{.Name}}Builder(memory.NewGoAllocator())
vec := b.New{{.Name}}Array()
b.Release()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put it at line 38 as a defer b.Release() instead.
also: vec is leaked. we should probably have a defer vec.Release() somewhere as well.

perhaps we should use a CheckedAllocator:

mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer mem.AssertSize(t, 0)

@sbinet sbinet self-requested a review March 15, 2019 18:19
@alexandreyc
Copy link
Contributor Author

Should be good now.

@sbinet sbinet changed the title WIP ARROW-4081: [Go] Sum methods panic when the array is empty ARROW-4081: [Go] Sum methods panic when the array is empty Mar 17, 2019
@sbinet sbinet closed this in 699878d Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants