MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / EncodeDurationAscending

Function EncodeDurationAscending

pkg/util/encoding/encoding.go:1027–1039  ·  view source on GitHub ↗

EncodeDurationAscending encodes a duration.Duration value, appends it to the supplied buffer, and returns the final buffer. The encoding is guaranteed to be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare will order them the same way after encoding.

(b []byte, d duration.Duration)

Source from the content-addressed store, hash-verified

1025// be ordered such that if t1.Compare(t2) < 0 (or = 0 or > 0) then bytes.Compare
1026// will order them the same way after encoding.
1027func EncodeDurationAscending(b []byte, d duration.Duration) ([]byte, error) {
1028 sortNanos, months, days, err := d.Encode()
1029 if err != nil {
1030 // TODO(dan): Handle this using d.EncodeBigInt() and the
1031 // durationBigNeg/durationBigPos markers.
1032 return b, err
1033 }
1034 b = append(b, durationMarker)
1035 b = EncodeVarintAscending(b, sortNanos)
1036 b = EncodeVarintAscending(b, months)
1037 b = EncodeVarintAscending(b, days)
1038 return b, nil
1039}
1040
1041// EncodeDurationDescending is the descending version of EncodeDurationAscending.
1042func EncodeDurationDescending(b []byte, d duration.Duration) ([]byte, error) {

Callers

nothing calls this directly

Calls 2

EncodeVarintAscendingFunction · 0.85
EncodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…