[
https://issues.apache.org/jira/browse/ARROW-3613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17660636#comment-17660636
]
Rok Mihevc commented on ARROW-3613:
-----------------------------------
This issue has been migrated to [issue
#19922|https://github.com/apache/arrow/issues/19922] on GitHub. Please see the
[migration documentation|https://github.com/apache/arrow/issues/14542] for
further details.
> [Go] Resize does not correctly update the length
> ------------------------------------------------
>
> Key: ARROW-3613
> URL: https://issues.apache.org/jira/browse/ARROW-3613
> Project: Apache Arrow
> Issue Type: Bug
> Components: Go
> Reporter: Jonathan A Sternberg
> Assignee: Francois Saint-Jacques
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.12.0
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> If you have the following code:
> {code:java}
> package main
> import (
> "fmt"
> "github.com/apache/arrow/go/arrow/array"
> "github.com/apache/arrow/go/arrow/memory"
> )
> func main() {
> builder := array.NewFloat64Builder(memory.DefaultAllocator)
> fmt.Println(builder.Len(), builder.Cap())
> builder.Reserve(44)
> fmt.Println(builder.Len(), builder.Cap())
> builder.Resize(5)
> fmt.Println(builder.Len(), builder.Cap())
> builder.Reserve(44)
> for i := 0; i < 44; i++ {
> builder.Append(0)
> }
> fmt.Println(builder.Len(), builder.Cap())
> builder.Resize(5)
> fmt.Println(builder.Len(), builder.Cap())
> }
> {code}
> It gives the following output:
> {code:java}
> 0 0
> 0 64
> 0 32
> 44 64
> 44 32
> {code}
> For whatever reason, the length is not recorded as 5. I understand why the
> capacity might not be 5, but it does seem like the length should be set to 5
> if the array is resized to a length smaller than its current capacity.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)