1
1
mirror of https://github.com/wader/fq.git synced 2024-12-21 20:31:43 +03:00
fq/format/postgres/common/pg_heap.go

50 lines
937 B
Go
Raw Normal View History

package common
import (
"github.com/wader/fq/pkg/scalar"
)
2022-09-06 12:55:15 +03:00
//nolint:revive
const (
2022-10-07 12:04:49 +03:00
PageSize = 8192
2022-09-06 12:55:15 +03:00
FirstNormalTransactionID = 3
2022-08-01 13:15:17 +03:00
LP_UNUSED = 0 /* unused (should always have lp_len=0) */
LP_NORMAL = 1 /* used (should always have lp_len>0) */
LP_REDIRECT = 2 /* HOT redirect (should have lp_len=0) */
LP_DEAD = 3
)
2022-09-06 12:55:15 +03:00
func TransactionIDIsNormal(xid uint64) bool {
return xid >= FirstNormalTransactionID
2022-08-04 11:16:50 +03:00
}
type lpFlagsMapper struct{}
2023-05-03 09:45:25 +03:00
func (m lpFlagsMapper) MapUint(s scalar.Uint) (scalar.Uint, error) {
switch s.Actual {
2022-08-01 13:15:17 +03:00
case LP_UNUSED:
s.Sym = "LP_UNUSED"
case LP_NORMAL:
s.Sym = "LP_NORMAL"
case LP_REDIRECT:
s.Sym = "LP_REDIRECT"
case LP_DEAD:
s.Sym = "LP_DEAD"
}
return s, nil
}
var LpFlagsMapper = lpFlagsMapper{}
type Mask struct {
Mask uint64
}
2023-05-03 09:45:25 +03:00
func (m Mask) MapUint(s scalar.Uint) (scalar.Uint, error) {
m1 := s.Actual
v := IsMaskSet(m1, m.Mask)
s.Actual = v
return s, nil
}