Skip to content

Comments

ARROW-4130: [Go] offset not used when accessing binary array#3283

Closed
jpacik wants to merge 4 commits intoapache:masterfrom
jpacik:fix/go-binary-slice
Closed

ARROW-4130: [Go] offset not used when accessing binary array#3283
jpacik wants to merge 4 commits intoapache:masterfrom
jpacik:fix/go-binary-slice

Conversation

@jpacik
Copy link
Contributor

@jpacik jpacik commented Dec 28, 2018

Closes #3270 .

@codecov-io
Copy link

codecov-io commented Dec 28, 2018

Codecov Report

Merging #3283 into master will decrease coverage by 20.62%.
The diff coverage is 81.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #3283       +/-   ##
===========================================
- Coverage    88.5%   67.88%   -20.63%     
===========================================
  Files         539       58      -481     
  Lines       72968     4029    -68939     
===========================================
- Hits        64583     2735    -61848     
+ Misses       8278     1185     -7093     
- Partials      107      109        +2
Impacted Files Coverage Δ
go/arrow/array/binary.go 84.21% <81.81%> (+27.06%) ⬆️
python/pyarrow/ipc.pxi
cpp/src/arrow/csv/chunker-test.cc
cpp/src/parquet/column_page.h
cpp/src/parquet/bloom_filter-test.cc
cpp/src/arrow/array/builder_decimal.cc
cpp/src/plasma/client.cc
cpp/src/arrow/io/test-common.h
cpp/src/gandiva/function_registry.h
cpp/src/arrow/util/int-util-test.cc
... and 474 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 9376d85...5cf6a4f. Read the comment docs.

@jpacik
Copy link
Contributor Author

jpacik commented Dec 28, 2018

@stuartcarnie can you review this?

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.

just a first pass.
seems good.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think reusing the same vs slice is unnecessarily clever.
what about:

vs := make([]string, slice.Len())
for i := range vs {
    vs[i] = slice.ValueString(i)
}

instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbinet I'd like it if the tests made as few allocations as possible, but if you think this change would increase readability then I have no problem with it. The extra allocations are negligible anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about:

vs := make([]string, arr.Len())
for i := range vs {
    vs[i] = arr.ValueString(i)
}

instead of creating this easy-to-mistake-with-1 l value?

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

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.

LGTM.

but let's wait for @stuartcarnie and/or @alexandreyc

Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps store the returned value and display it if tc.panic is true to prevent any unwanted compiler ellision?

@wesm
Copy link
Member

wesm commented Jan 4, 2019

@stuartcarnie @alexandreyc can you review?

func (a *Binary) Value(i int) []byte {
if i < 0 || i >= a.array.data.length {
panic("arrow/array: index out of range")
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it Go-ey to boundscheck?

Copy link
Contributor

Choose a reason for hiding this comment

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

Go compilers do it for slices and arrays. It's in the specs of the Go language.

@alexandreyc
Copy link
Contributor

LGTM

(Sorry for being rather inactive these last weeks, I hope I will have more time to contribute in a few weeks)

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.

5 participants