github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/array.go (about)

     1  package parquet
     2  
     3  import (
     4  	"unsafe"
     5  
     6  	"github.com/vc42/parquet-go/sparse"
     7  )
     8  
     9  func makeArrayValue(values []Value, offset uintptr) sparse.Array {
    10  	ptr := *(*unsafe.Pointer)(unsafe.Pointer(&values))
    11  	return sparse.UnsafeArray(unsafe.Add(ptr, offset), len(values), unsafe.Sizeof(Value{}))
    12  }
    13  
    14  func makeArrayString(values []string) sparse.Array {
    15  	str := ""
    16  	ptr := *(*unsafe.Pointer)(unsafe.Pointer(&values))
    17  	return sparse.UnsafeArray(ptr, len(values), unsafe.Sizeof(str))
    18  }
    19  
    20  func makeArrayBE128(values []*[16]byte) sparse.Array {
    21  	ptr := *(*unsafe.Pointer)(unsafe.Pointer(&values))
    22  	return sparse.UnsafeArray(ptr, len(values), unsafe.Sizeof((*[16]byte)(nil)))
    23  }