Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-3613

[Go] Resize does not correctly update the length

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0
    • Component/s: Go

      Description

      If you have the following code:

      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())
      }
      

      It gives the following output:

      0 0
      0 64
      0 32
      44 64
      44 32
      

      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.

        Attachments

          Activity

            People

            • Assignee:
              fsaintjacques Francois Saint-Jacques
              Reporter:
              jsternberg Jonathan A Sternberg
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h