2022-07-29 09:10:00 +03:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/wader/fq/pkg/scalar"
|
|
|
|
)
|
|
|
|
|
2022-09-06 12:55:15 +03:00
|
|
|
//nolint:revive
|
2022-07-29 09:10:00 +03:00
|
|
|
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-07-29 09:10:00 +03:00
|
|
|
)
|
|
|
|
|
2022-09-06 12:55:15 +03:00
|
|
|
func TransactionIDIsNormal(xid uint64) bool {
|
|
|
|
return xid >= FirstNormalTransactionID
|
2022-08-04 11:16:50 +03:00
|
|
|
}
|
|
|
|
|
2022-07-29 09:10:00 +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"
|
|
|
|
}
|
2022-07-29 09:10:00 +03:00
|
|
|
return s, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var LpFlagsMapper = lpFlagsMapper{}
|
|
|
|
|
2022-08-01 09:55:37 +03:00
|
|
|
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
|
2022-08-01 09:55:37 +03:00
|
|
|
v := IsMaskSet(m1, m.Mask)
|
|
|
|
s.Actual = v
|
|
|
|
return s, nil
|
|
|
|
}
|