Files
cc86e98b04 Rewrite conditions on same attribute to equivalent array operation (#6353)
* Add operators IN, NOT IN, MATCH ANY, and MATCH NONE

* Implement Static.append()

* Print string arrays with '`' instead of '"'

Example ["aa", "bb"] -> [`aa`, `bb`]

* Rewrite binary operations to array equivalent

The rewriter handles the following cases:
- { .a =  "a" || .a =  "b" } => { .a IN  ["a", "b"] }
- { .a != "a" && .a != "b" } => { .a NOT IN ["a", "b"] }
- { .a =~ "a" || .a =~ "b" } => { .a MATCH ANY ["a", "b"] }
- { .a !~ "a" && .a !~ "b" } => { .a MATCH NONE ["a", "b"] }

* Add test cases with arrays to TestBinOp

* traceql.Parse() applies AST optimizations by default

* Rename predicate_test.go to predicates_test.go

* Add array predicates to parquetquery

* BREAKING CHANGE: more precise regex validation

BinaryOperation.validate() considered everythin a valid regex where
FieldExpression.EncodeToString(false) happened to return a valid regex.
With this change the RHS of a regex operation is required to be a string
or string array

* vp4: handle predicates with arrays correctly

* vp5: handle predicates with arrays correctly

* vp3: handle predicates with arrays correctly

* Add test cases for optimized queries

* Update query test examples with optimizable queries

* vp3: fix handling of array types

* CHANGELOG.md

* Pass array operators down to fetch layer

* Read to first virtual row after seeking on a low definition level

This helps avoid additional spans/op in queries with only
resource attributes

---------

Co-authored-by: Martin Disibio <[email protected]>
2026-02-22 00:55:23 -08:00

1240 lines
24 KiB
Go

// Code generated by make gen-parquet-query. DO NOT EDIT.
// source: pkg/parquetquerygen/predicates.go
package parquetquery
import (
"bytes"
"fmt"
pq "github.com/parquet-go/parquet-go"
)
var _ Predicate = (*IntEqualPredicate)(nil)
type IntEqualPredicate struct {
value int64
}
func NewIntEqualPredicate(val int64) IntEqualPredicate {
return IntEqualPredicate{value: val}
}
func (p IntEqualPredicate) String() string {
return fmt.Sprintf("IntEqualPredicate{%d}", p.value)
}
func (p IntEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Int64()
max := ci.MaxValue(i).Int64()
if min <= p.value && p.value <= max {
return true
}
}
return false
}
return true
}
func (p IntEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Int64()
max := maxV.Int64()
return min <= p.value && p.value <= max
}
return true
}
func (p IntEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv == p.value
}
var _ Predicate = (*IntNotEqualPredicate)(nil)
type IntNotEqualPredicate struct {
value int64
}
func NewIntNotEqualPredicate(val int64) IntNotEqualPredicate {
return IntNotEqualPredicate{value: val}
}
func (p IntNotEqualPredicate) String() string {
return fmt.Sprintf("IntNotEqualPredicate{%d}", p.value)
}
func (p IntNotEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Int64()
max := ci.MaxValue(i).Int64()
if min != p.value || p.value != max {
return true
}
}
return false
}
return true
}
func (p IntNotEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Int64()
max := maxV.Int64()
return min != p.value || p.value != max
}
return true
}
func (p IntNotEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv != p.value
}
var _ Predicate = (*IntGreaterPredicate)(nil)
type IntGreaterPredicate struct {
value int64
}
func NewIntGreaterPredicate(val int64) IntGreaterPredicate {
return IntGreaterPredicate{value: val}
}
func (p IntGreaterPredicate) String() string {
return fmt.Sprintf("IntGreaterPredicate{%d}", p.value)
}
func (p IntGreaterPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).Int64()
if max > p.value {
return true
}
}
return false
}
return true
}
func (p IntGreaterPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.Int64()
return max > p.value
}
return true
}
func (p IntGreaterPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv > p.value
}
var _ Predicate = (*IntGreaterEqualPredicate)(nil)
type IntGreaterEqualPredicate struct {
value int64
}
func NewIntGreaterEqualPredicate(val int64) IntGreaterEqualPredicate {
return IntGreaterEqualPredicate{value: val}
}
func (p IntGreaterEqualPredicate) String() string {
return fmt.Sprintf("IntGreaterEqualPredicate{%d}", p.value)
}
func (p IntGreaterEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).Int64()
if max >= p.value {
return true
}
}
return false
}
return true
}
func (p IntGreaterEqualPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.Int64()
return max >= p.value
}
return true
}
func (p IntGreaterEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv >= p.value
}
var _ Predicate = (*IntLessPredicate)(nil)
type IntLessPredicate struct {
value int64
}
func NewIntLessPredicate(val int64) IntLessPredicate {
return IntLessPredicate{value: val}
}
func (p IntLessPredicate) String() string {
return fmt.Sprintf("IntLessPredicate{%d}", p.value)
}
func (p IntLessPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Int64()
if min < p.value {
return true
}
}
return false
}
return true
}
func (p IntLessPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.Int64()
return min < p.value
}
return true
}
func (p IntLessPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv < p.value
}
var _ Predicate = (*IntLessEqualPredicate)(nil)
type IntLessEqualPredicate struct {
value int64
}
func NewIntLessEqualPredicate(val int64) IntLessEqualPredicate {
return IntLessEqualPredicate{value: val}
}
func (p IntLessEqualPredicate) String() string {
return fmt.Sprintf("IntLessEqualPredicate{%d}", p.value)
}
func (p IntLessEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Int64()
if min <= p.value {
return true
}
}
return false
}
return true
}
func (p IntLessEqualPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.Int64()
return min <= p.value
}
return true
}
func (p IntLessEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
return vv <= p.value
}
var _ Predicate = (*FloatEqualPredicate)(nil)
type FloatEqualPredicate struct {
value float64
}
func NewFloatEqualPredicate(val float64) FloatEqualPredicate {
return FloatEqualPredicate{value: val}
}
func (p FloatEqualPredicate) String() string {
return fmt.Sprintf("FloatEqualPredicate{%f}", p.value)
}
func (p FloatEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Double()
max := ci.MaxValue(i).Double()
if min <= p.value && p.value <= max {
return true
}
}
return false
}
return true
}
func (p FloatEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Double()
max := maxV.Double()
return min <= p.value && p.value <= max
}
return true
}
func (p FloatEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv == p.value
}
var _ Predicate = (*FloatNotEqualPredicate)(nil)
type FloatNotEqualPredicate struct {
value float64
}
func NewFloatNotEqualPredicate(val float64) FloatNotEqualPredicate {
return FloatNotEqualPredicate{value: val}
}
func (p FloatNotEqualPredicate) String() string {
return fmt.Sprintf("FloatNotEqualPredicate{%f}", p.value)
}
func (p FloatNotEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Double()
max := ci.MaxValue(i).Double()
if min != p.value || p.value != max {
return true
}
}
return false
}
return true
}
func (p FloatNotEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Double()
max := maxV.Double()
return min != p.value || p.value != max
}
return true
}
func (p FloatNotEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv != p.value
}
var _ Predicate = (*FloatGreaterPredicate)(nil)
type FloatGreaterPredicate struct {
value float64
}
func NewFloatGreaterPredicate(val float64) FloatGreaterPredicate {
return FloatGreaterPredicate{value: val}
}
func (p FloatGreaterPredicate) String() string {
return fmt.Sprintf("FloatGreaterPredicate{%f}", p.value)
}
func (p FloatGreaterPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).Double()
if max > p.value {
return true
}
}
return false
}
return true
}
func (p FloatGreaterPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.Double()
return max > p.value
}
return true
}
func (p FloatGreaterPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv > p.value
}
var _ Predicate = (*FloatGreaterEqualPredicate)(nil)
type FloatGreaterEqualPredicate struct {
value float64
}
func NewFloatGreaterEqualPredicate(val float64) FloatGreaterEqualPredicate {
return FloatGreaterEqualPredicate{value: val}
}
func (p FloatGreaterEqualPredicate) String() string {
return fmt.Sprintf("FloatGreaterEqualPredicate{%f}", p.value)
}
func (p FloatGreaterEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).Double()
if max >= p.value {
return true
}
}
return false
}
return true
}
func (p FloatGreaterEqualPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.Double()
return max >= p.value
}
return true
}
func (p FloatGreaterEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv >= p.value
}
var _ Predicate = (*FloatLessPredicate)(nil)
type FloatLessPredicate struct {
value float64
}
func NewFloatLessPredicate(val float64) FloatLessPredicate {
return FloatLessPredicate{value: val}
}
func (p FloatLessPredicate) String() string {
return fmt.Sprintf("FloatLessPredicate{%f}", p.value)
}
func (p FloatLessPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Double()
if min < p.value {
return true
}
}
return false
}
return true
}
func (p FloatLessPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.Double()
return min < p.value
}
return true
}
func (p FloatLessPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv < p.value
}
var _ Predicate = (*FloatLessEqualPredicate)(nil)
type FloatLessEqualPredicate struct {
value float64
}
func NewFloatLessEqualPredicate(val float64) FloatLessEqualPredicate {
return FloatLessEqualPredicate{value: val}
}
func (p FloatLessEqualPredicate) String() string {
return fmt.Sprintf("FloatLessEqualPredicate{%f}", p.value)
}
func (p FloatLessEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Double()
if min <= p.value {
return true
}
}
return false
}
return true
}
func (p FloatLessEqualPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.Double()
return min <= p.value
}
return true
}
func (p FloatLessEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
return vv <= p.value
}
var _ Predicate = (*BoolEqualPredicate)(nil)
type BoolEqualPredicate struct {
value bool
}
func NewBoolEqualPredicate(val bool) BoolEqualPredicate {
return BoolEqualPredicate{value: val}
}
func (p BoolEqualPredicate) String() string {
return fmt.Sprintf("BoolEqualPredicate{%t}", p.value)
}
func (p BoolEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p BoolEqualPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p BoolEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Boolean()
return vv == p.value
}
var _ Predicate = (*BoolNotEqualPredicate)(nil)
type BoolNotEqualPredicate struct {
value bool
}
func NewBoolNotEqualPredicate(val bool) BoolNotEqualPredicate {
return BoolNotEqualPredicate{value: val}
}
func (p BoolNotEqualPredicate) String() string {
return fmt.Sprintf("BoolNotEqualPredicate{%t}", p.value)
}
func (p BoolNotEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p BoolNotEqualPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p BoolNotEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.Boolean()
return vv != p.value
}
var _ Predicate = (*StringGreaterPredicate)(nil)
type StringGreaterPredicate struct {
value []byte
}
func NewStringGreaterPredicate(val []byte) StringGreaterPredicate {
return StringGreaterPredicate{value: val}
}
func (p StringGreaterPredicate) String() string {
return fmt.Sprintf("StringGreaterPredicate{%s}", p.value)
}
func (p StringGreaterPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).ByteArray()
if bytes.Compare(max, p.value) > 0 {
return true
}
}
return false
}
return true
}
func (p StringGreaterPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.ByteArray()
return bytes.Compare(max, p.value) > 0
}
return true
}
func (p StringGreaterPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return bytes.Compare(vv, p.value) > 0
}
var _ Predicate = (*StringGreaterEqualPredicate)(nil)
type StringGreaterEqualPredicate struct {
value []byte
}
func NewStringGreaterEqualPredicate(val []byte) StringGreaterEqualPredicate {
return StringGreaterEqualPredicate{value: val}
}
func (p StringGreaterEqualPredicate) String() string {
return fmt.Sprintf("StringGreaterEqualPredicate{%s}", p.value)
}
func (p StringGreaterEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
max := ci.MaxValue(i).ByteArray()
if bytes.Compare(max, p.value) >= 0 {
return true
}
}
return false
}
return true
}
func (p StringGreaterEqualPredicate) KeepPage(page pq.Page) bool {
_, maxV, ok := page.Bounds()
if ok {
max := maxV.ByteArray()
return bytes.Compare(max, p.value) >= 0
}
return true
}
func (p StringGreaterEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return bytes.Compare(vv, p.value) >= 0
}
var _ Predicate = (*StringLessPredicate)(nil)
type StringLessPredicate struct {
value []byte
}
func NewStringLessPredicate(val []byte) StringLessPredicate {
return StringLessPredicate{value: val}
}
func (p StringLessPredicate) String() string {
return fmt.Sprintf("StringLessPredicate{%s}", p.value)
}
func (p StringLessPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).ByteArray()
if bytes.Compare(min, p.value) < 0 {
return true
}
}
return false
}
return true
}
func (p StringLessPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.ByteArray()
return bytes.Compare(min, p.value) < 0
}
return true
}
func (p StringLessPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return bytes.Compare(vv, p.value) < 0
}
var _ Predicate = (*StringLessEqualPredicate)(nil)
type StringLessEqualPredicate struct {
value []byte
}
func NewStringLessEqualPredicate(val []byte) StringLessEqualPredicate {
return StringLessEqualPredicate{value: val}
}
func (p StringLessEqualPredicate) String() string {
return fmt.Sprintf("StringLessEqualPredicate{%s}", p.value)
}
func (p StringLessEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).ByteArray()
if bytes.Compare(min, p.value) <= 0 {
return true
}
}
return false
}
return true
}
func (p StringLessEqualPredicate) KeepPage(page pq.Page) bool {
minV, _, ok := page.Bounds()
if ok {
min := minV.ByteArray()
return bytes.Compare(min, p.value) <= 0
}
return true
}
func (p StringLessEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return bytes.Compare(vv, p.value) <= 0
}
var _ Predicate = (*ByteEqualPredicate)(nil)
type ByteEqualPredicate struct {
value []byte
}
func NewByteEqualPredicate(val []byte) ByteEqualPredicate {
return ByteEqualPredicate{value: val}
}
func (p ByteEqualPredicate) String() string {
return fmt.Sprintf("ByteEqualPredicate{%s}", p.value)
}
func (p ByteEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).ByteArray()
max := ci.MaxValue(i).ByteArray()
if bytes.Compare(p.value, min) >= 0 && bytes.Compare(p.value, max) <= 0 {
return true
}
}
return false
}
return true
}
func (p ByteEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.ByteArray()
max := maxV.ByteArray()
return bytes.Compare(p.value, min) >= 0 && bytes.Compare(p.value, max) <= 0
}
return true
}
func (p ByteEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return bytes.Equal(vv, p.value)
}
var _ Predicate = (*ByteNotEqualPredicate)(nil)
type ByteNotEqualPredicate struct {
value []byte
}
func NewByteNotEqualPredicate(val []byte) ByteNotEqualPredicate {
return ByteNotEqualPredicate{value: val}
}
func (p ByteNotEqualPredicate) String() string {
return fmt.Sprintf("ByteNotEqualPredicate{%s}", p.value)
}
func (p ByteNotEqualPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).ByteArray()
max := ci.MaxValue(i).ByteArray()
if !bytes.Equal(min, p.value) || !bytes.Equal(p.value, max) {
return true
}
}
return false
}
return true
}
func (p ByteNotEqualPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.ByteArray()
max := maxV.ByteArray()
return !bytes.Equal(min, p.value) || !bytes.Equal(p.value, max)
}
return true
}
func (p ByteNotEqualPredicate) KeepValue(v pq.Value) bool {
vv := v.ByteArray()
return !bytes.Equal(vv, p.value)
}
var _ Predicate = (*IntInPredicate)(nil)
type IntInPredicate struct {
values []int64
}
func NewIntInPredicate(vals []int64) IntInPredicate {
return IntInPredicate{values: vals}
}
func (p IntInPredicate) String() string { return fmt.Sprintf("IntInPredicate{%v}", p.values) }
func (p IntInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Int64()
max := ci.MaxValue(i).Int64()
for _, v := range p.values {
if min <= v && v <= max {
return true
}
}
}
return false
}
return true
}
func (p IntInPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Int64()
max := maxV.Int64()
for _, v := range p.values {
if min <= v && v <= max {
return true
}
}
return false
}
return true
}
func (p IntInPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
for _, x := range p.values {
if vv == x {
return true
}
}
return false
}
var _ Predicate = (*IntNotInPredicate)(nil)
type IntNotInPredicate struct {
values []int64
}
func NewIntNotInPredicate(vals []int64) IntNotInPredicate {
return IntNotInPredicate{values: vals}
}
func (p IntNotInPredicate) String() string {
return fmt.Sprintf("IntNotInPredicate{%v}", p.values)
}
func (p IntNotInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p IntNotInPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p IntNotInPredicate) KeepValue(v pq.Value) bool {
vv := v.Int64()
for _, x := range p.values {
if vv == x {
return false
}
}
return true
}
var _ Predicate = (*FloatInPredicate)(nil)
type FloatInPredicate struct {
values []float64
}
func NewFloatInPredicate(vals []float64) FloatInPredicate {
return FloatInPredicate{values: vals}
}
func (p FloatInPredicate) String() string { return fmt.Sprintf("FloatInPredicate{%v}", p.values) }
func (p FloatInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
ci, err := c.ColumnIndex()
if err == nil && ci != nil {
for i := 0; i < ci.NumPages(); i++ {
min := ci.MinValue(i).Double()
max := ci.MaxValue(i).Double()
for _, v := range p.values {
if min <= v && v <= max {
return true
}
}
}
return false
}
return true
}
func (p FloatInPredicate) KeepPage(page pq.Page) bool {
minV, maxV, ok := page.Bounds()
if ok {
min := minV.Double()
max := maxV.Double()
for _, v := range p.values {
if min <= v && v <= max {
return true
}
}
return false
}
return true
}
func (p FloatInPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
for _, x := range p.values {
if vv == x {
return true
}
}
return false
}
var _ Predicate = (*FloatNotInPredicate)(nil)
type FloatNotInPredicate struct {
values []float64
}
func NewFloatNotInPredicate(vals []float64) FloatNotInPredicate {
return FloatNotInPredicate{values: vals}
}
func (p FloatNotInPredicate) String() string {
return fmt.Sprintf("FloatNotInPredicate{%v}", p.values)
}
func (p FloatNotInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p FloatNotInPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p FloatNotInPredicate) KeepValue(v pq.Value) bool {
vv := v.Double()
for _, x := range p.values {
if vv == x {
return false
}
}
return true
}
var _ Predicate = (*BoolInPredicate)(nil)
type BoolInPredicate struct {
values []bool
}
func NewBoolInPredicate(vals []bool) BoolInPredicate {
return BoolInPredicate{values: vals}
}
func (p BoolInPredicate) String() string { return fmt.Sprintf("BoolInPredicate{%v}", p.values) }
func (p BoolInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p BoolInPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p BoolInPredicate) KeepValue(v pq.Value) bool {
vv := v.Boolean()
for _, x := range p.values {
if vv == x {
return true
}
}
return false
}
var _ Predicate = (*BoolNotInPredicate)(nil)
type BoolNotInPredicate struct {
values []bool
}
func NewBoolNotInPredicate(vals []bool) BoolNotInPredicate {
return BoolNotInPredicate{values: vals}
}
func (p BoolNotInPredicate) String() string {
return fmt.Sprintf("BoolNotInPredicate{%v}", p.values)
}
func (p BoolNotInPredicate) KeepColumnChunk(c *ColumnChunkHelper) bool {
if d := c.Dictionary(); d != nil {
return keepDictionary(d, p.KeepValue)
}
return true
}
func (p BoolNotInPredicate) KeepPage(page pq.Page) bool {
return true
}
func (p BoolNotInPredicate) KeepValue(v pq.Value) bool {
vv := v.Boolean()
for _, x := range p.values {
if vv == x {
return false
}
}
return true
}