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

GH-41: [Array] Make String and Binary consistent #165

Merged
merged 3 commits into from
Oct 22, 2024
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
2 changes: 1 addition & 1 deletion arrow/array/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (a *String) ValueStr(i int) string {

// ValueOffset returns the offset of the value at index i.
func (a *String) ValueOffset(i int) int {
if i < 0 || i > a.array.data.length {
if i < 0 || i >= a.array.data.length {
panic("arrow/array: index out of range")
}
return int(a.offsets[i+a.array.data.offset])
Expand Down
6 changes: 0 additions & 6 deletions arrow/array/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ func TestStringArray(t *testing.T) {
if got, want := arr.ValueOffset(i), int(offsets[i]); got != want {
t.Fatalf("arr-offset-beg[%d]: got=%d, want=%d", i, got, want)
}
if got, want := arr.ValueOffset(i+1), int(offsets[i+1]); got != want {
Copy link
Member

Choose a reason for hiding this comment

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

I guess we could validate ValueLen instead? Though maybe not really worth it

t.Fatalf("arr-offset-end[%d]: got=%d, want=%d", i+1, got, want)
}
}

if !reflect.DeepEqual(offsets, arr.ValueOffsets()) {
Expand Down Expand Up @@ -372,9 +369,6 @@ func TestLargeStringArray(t *testing.T) {
if got, want := arr.ValueOffset(i), offsets[i]; got != want {
t.Fatalf("arr-offset-beg[%d]: got=%d, want=%d", i, got, want)
}
if got, want := arr.ValueOffset(i+1), offsets[i+1]; got != want {
t.Fatalf("arr-offset-end[%d]: got=%d, want=%d", i+1, got, want)
}
}

if !reflect.DeepEqual(offsets, arr.ValueOffsets()) {
Expand Down
8 changes: 6 additions & 2 deletions arrow/ipc/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,13 @@ func (w *recordEncoder) visit(p *Payload, arr arrow.Array) error {
case needTruncate(int64(data.Offset()), values, totalDataBytes):
// slice data buffer to include the range we need now.
var (
beg = arr.ValueOffset64(0)
len = minI64(paddedLength(totalDataBytes, kArrowAlignment), int64(totalDataBytes))
beg int64 = 0
len = minI64(paddedLength(totalDataBytes, kArrowAlignment), int64(totalDataBytes))
)
if arr.Len() > 0 {
beg = arr.ValueOffset64(0)
}

values = memory.NewBufferBytes(data.Buffers()[2].Bytes()[beg : beg+len])
default:
if values != nil {
Expand Down
4 changes: 2 additions & 2 deletions parquet/metadata/statistics_types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading