Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: shaoting-huang <[email protected]>
  • Loading branch information
shaoting-huang committed Jan 6, 2025
1 parent b06e1c5 commit 894edfa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions go/packed/packed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package packed

import (
"fmt"
"testing"

"github.com/apache/arrow/go/v12/arrow"
Expand All @@ -24,7 +23,8 @@ import (
"github.com/stretchr/testify/assert"
)

func TestRead(t *testing.T) {
func TestPackedOneFile(t *testing.T) {
batches := 100
schema := arrow.NewSchema([]arrow.Field{
{Name: "a", Type: arrow.PrimitiveTypes.Int32},
{Name: "b", Type: arrow.PrimitiveTypes.Int64},
Expand Down Expand Up @@ -55,16 +55,20 @@ func TestRead(t *testing.T) {
bufferSize := 10 * 1024 * 1024 // 10MB
pw, err := newPackedWriter(path, schema, bufferSize)
assert.NoError(t, err)
err = pw.writeRecordBatch(rec)
assert.NoError(t, err)
for i := 0; i < batches; i++ {
err = pw.writeRecordBatch(rec)
assert.NoError(t, err)
}
mapping, err := pw.close()
assert.NoError(t, err)
fmt.Println(mapping)
assert.Equal(t, mapping["a"], ColumnOffset{0, 0})
assert.Equal(t, mapping["b"], ColumnOffset{0, 1})
assert.Equal(t, mapping["c"], ColumnOffset{0, 2})

reader, err := Open(path, schema, 10*1024*1024 /* 10MB */)
assert.NoError(t, err)
rr, err := reader.Read()
assert.NoError(t, err)
defer rr.Release()
assert.Equal(t, int64(3), rr.NumRows())
assert.Equal(t, int64(3*batches), rr.NumRows())
}

0 comments on commit 894edfa

Please sign in to comment.