powersj commented on issue #43186:
URL: https://github.com/apache/arrow/issues/43186#issuecomment-2215099001
@joellubi,
Here is a test case you can use outside of my branch :)
```go
package main
import (
"os"
"time"
"github.com/apache/arrow/go/v16/arrow"
"github.com/apache/arrow/go/v16/arrow/array"
"github.com/apache/arrow/go/v16/arrow/memory"
"github.com/apache/arrow/go/v16/parquet"
"github.com/apache/arrow/go/v16/parquet/pqarrow"
)
type Metric struct {
Time time.Time
CPUUsage float64
Memory float64
}
func main() {
file, err := os.OpenFile("metrics.parquet",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0640)
if err != nil {
panic(err)
}
defer file.Close()
pool := memory.NewCheckedAllocator(memory.NewGoAllocator())
fields := []arrow.Field{
{Name: "time", Type: arrow.FixedWidthTypes.Timestamp_ms},
{Name: "cpu_usage", Type: arrow.PrimitiveTypes.Float64},
{Name: "memory", Type: arrow.PrimitiveTypes.Float64},
}
schema := arrow.NewSchema(fields, nil)
builder := array.NewRecordBuilder(pool, schema)
defer builder.Release()
metrics := []Metric{
{Time: time.Now(), CPUUsage: 5.5, Memory: 1024.0},
}
for _, metric := range metrics {
builder.Field(0).(*array.TimestampBuilder).Append(arrow.Timestamp(metric.Time.UnixNano()
/ int64(time.Millisecond)))
builder.Field(1).(*array.Float64Builder).Append(metric.CPUUsage)
builder.Field(2).(*array.Float64Builder).Append(metric.Memory)
}
record := builder.NewRecord()
defer record.Release()
parquetWriteProps := parquet.NewWriterProperties()
arrowWriteProps := pqarrow.NewArrowWriterProperties()
parquetFileWriter, err := pqarrow.NewFileWriter(record.Schema(), file,
parquetWriteProps, arrowWriteProps)
if err != nil {
panic(err)
}
defer parquetFileWriter.Close()
err = parquetFileWriter.Write(record)
if err != nil {
panic(err)
}
}
```
```shell
❯ GOARCH=386 go run .
panic: unaligned 64-bit atomic operation
goroutine 1 [running]:
runtime/internal/atomic.panicUnaligned()
/usr/lib/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Xadd64(0x9eb246c, 0xffffffffffffffff)
/usr/lib/go/src/runtime/internal/atomic/atomic_386.s:125 +0x11
github.com/apache/arrow/go/v16/parquet/pqarrow.(*multipathLevelBuilder).Release(0x9eb2420)
/home/powersj/go/pkg/mod/github.com/apache/arrow/go/[email protected]/parquet/pqarrow/path_builder.go:509
+0x3a
github.com/apache/arrow/go/v16/parquet/pqarrow.(*arrowColumnWriter).Write(0x9e4dd10,
{0x8f70188, 0x9e7b260})
/home/powersj/go/pkg/mod/github.com/apache/arrow/go/[email protected]/parquet/pqarrow/encode_arrow.go:198
+0x1b9
github.com/apache/arrow/go/v16/parquet/pqarrow.(*FileWriter).WriteColumnChunked(0x9e9a640,
0x9e89710, 0x0, 0x1)
/home/powersj/go/pkg/mod/github.com/apache/arrow/go/[email protected]/parquet/pqarrow/file_writer.go:330
+0xf7
github.com/apache/arrow/go/v16/parquet/pqarrow.(*FileWriter).WriteColumnData(0x9e9a640,
{0x8f78eb0, 0x9e89590})
/home/powersj/go/pkg/mod/github.com/apache/arrow/go/[email protected]/parquet/pqarrow/file_writer.go:339
+0x109
github.com/apache/arrow/go/v16/parquet/pqarrow.(*FileWriter).Write(0x9e9a640,
{0x8f78218, 0x9ea81c0})
/home/powersj/go/pkg/mod/github.com/apache/arrow/go/[email protected]/parquet/pqarrow/file_writer.go:242
+0x280
main.main()
/home/powersj/test/main.go:60 +0x5c5
exit status 2
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]