encodeInterval encodes an INTERVAL value in PostgreSQL binary format: int64 microseconds + int32 days + int32 months = 16 bytes.
(v interface{})
| 610 | // encodeInterval encodes an INTERVAL value in PostgreSQL binary format: |
| 611 | // int64 microseconds + int32 days + int32 months = 16 bytes. |
| 612 | func encodeInterval(v interface{}) []byte { |
| 613 | v = normalizeDriverValue(v) |
| 614 | buf := make([]byte, 16) |
| 615 | val, ok := v.(arrowmap.IntervalValue) |
| 616 | if !ok { |
| 617 | return nil |
| 618 | } |
| 619 | binary.BigEndian.PutUint64(buf[0:8], uint64(val.Micros)) |
| 620 | binary.BigEndian.PutUint32(buf[8:12], uint32(val.Days)) |
| 621 | binary.BigEndian.PutUint32(buf[12:16], uint32(val.Months)) |
| 622 | return buf |
| 623 | } |
| 624 | |
| 625 | // decodeInterval decodes PostgreSQL binary INTERVAL (16 bytes) into an interval string. |
| 626 | func decodeInterval(data []byte) (string, error) { |