ToBigInt64Array converts the value to int64 slice if it's a BigInt64Array.
()
| 1029 | |
| 1030 | // ToBigInt64Array converts the value to int64 slice if it's a BigInt64Array. |
| 1031 | func (v *Value) ToBigInt64Array() ([]int64, error) { |
| 1032 | if !v.IsBigInt64Array() { |
| 1033 | return nil, errors.New("value is not a BigInt64Array") |
| 1034 | } |
| 1035 | |
| 1036 | buffer, byteOffset, byteLength, _ := v.getTypedArrayInfo() |
| 1037 | defer buffer.Free() |
| 1038 | |
| 1039 | totalSize := uint(byteOffset + byteLength) |
| 1040 | bytes, err := buffer.ToByteArray(totalSize) |
| 1041 | if err != nil { |
| 1042 | return nil, err |
| 1043 | } |
| 1044 | |
| 1045 | data := bytes[byteOffset : byteOffset+byteLength] |
| 1046 | result := make([]int64, len(data)/8) |
| 1047 | for i := 0; i < len(result); i++ { |
| 1048 | result[i] = int64(binary.LittleEndian.Uint64(data[i*8:])) |
| 1049 | } |
| 1050 | return result, nil |
| 1051 | } |
| 1052 | |
| 1053 | // ToBigUint64Array converts the value to uint64 slice if it's a BigUint64Array. |
| 1054 | func (v *Value) ToBigUint64Array() ([]uint64, error) { |