github.com/tobgu/qframe@v0.4.0/internal/icolumn/filters.go (about) 1 package icolumn 2 3 import ( 4 "github.com/tobgu/qframe/filter" 5 "github.com/tobgu/qframe/internal/index" 6 ) 7 8 // Column - constant 9 var filterFuncs = map[string]func(index.Int, []int, int, index.Bool){ 10 filter.Gt: gt, 11 filter.Gte: gte, 12 filter.Lt: lt, 13 filter.Lte: lte, 14 filter.Eq: eq, 15 filter.Neq: neq, 16 "any_bits": anyBits, 17 "all_bits": allBits, 18 } 19 20 // Comparisons against multiple values 21 var multiInputFilterFuncs = map[string]func(index.Int, []int, intSet, index.Bool){ 22 filter.In: in, 23 } 24 25 // Column - Column 26 var filterFuncs2 = map[string]func(index.Int, []int, []int, index.Bool){ 27 filter.Gt: gt2, 28 filter.Gte: gte2, 29 filter.Lt: lt2, 30 filter.Lte: lte2, 31 filter.Eq: eq2, 32 filter.Neq: neq2, 33 } 34 35 // Column only 36 var filterFuncs0 = map[string]func(index.Int, []int, index.Bool){ 37 filter.IsNull: isNull, 38 filter.IsNotNull: isNotNull, 39 } 40 41 func isNull(_ index.Int, _ []int, bIndex index.Bool) { 42 // Int columns are never null, this function is provided for convenience to avoid 43 // clients from having to keep track of if a column is of type int or float for 44 // common operations. 45 for i := range bIndex { 46 bIndex[i] = false 47 } 48 } 49 50 func isNotNull(_ index.Int, _ []int, bIndex index.Bool) { 51 // Int columns are never null, this function is provided for convenience to avoid 52 // clients from having to keep track of if a column is of type int or float for 53 // common operations. 54 for i := range bIndex { 55 bIndex[i] = true 56 } 57 } 58 59 func in(index index.Int, column []int, comp intSet, bIndex index.Bool) { 60 for i, x := range bIndex { 61 if !x { 62 bIndex[i] = comp.Contains(column[index[i]]) 63 } 64 } 65 } 66 67 func anyBits(index index.Int, column []int, comp int, bIndex index.Bool) { 68 for i, x := range bIndex { 69 if !x { 70 bIndex[i] = column[index[i]]&comp > 0 71 } 72 } 73 } 74 75 func allBits(index index.Int, column []int, comp int, bIndex index.Bool) { 76 for i, x := range bIndex { 77 if !x { 78 bIndex[i] = column[index[i]]&comp == comp 79 } 80 } 81 }