@@ -64,8 +64,6 @@ export class Col<T= any> extends Value<T> {
64
64
this . vector = batch . getChildAt ( this . colidx ) ! ;
65
65
return this . vector . get . bind ( this . vector ) ;
66
66
}
67
-
68
- emitString ( ) { return `cols[${ this . colidx } ].get(idx)` ; }
69
67
}
70
68
71
69
export abstract class Predicate {
@@ -86,7 +84,7 @@ export abstract class ComparisonPredicate<T= any> extends Predicate {
86
84
return this . _bindLitLit ( batch , this . left , this . right ) ;
87
85
} else { // right is a Col
88
86
89
- return this . _bindColLit ( batch , this . right as Col , this . left ) ;
87
+ return this . _bindLitCol ( batch , this . left , this . right as Col ) ;
90
88
}
91
89
} else { // left is a Col
92
90
if ( this . right instanceof Literal ) {
@@ -100,6 +98,7 @@ export abstract class ComparisonPredicate<T= any> extends Predicate {
100
98
protected abstract _bindLitLit ( batch : RecordBatch , left : Literal , right : Literal ) : PredicateFunc ;
101
99
protected abstract _bindColCol ( batch : RecordBatch , left : Col , right : Col ) : PredicateFunc ;
102
100
protected abstract _bindColLit ( batch : RecordBatch , col : Col , lit : Literal ) : PredicateFunc ;
101
+ protected abstract _bindLitCol ( batch : RecordBatch , lit : Literal , col : Col ) : PredicateFunc ;
103
102
}
104
103
105
104
export abstract class CombinationPredicate extends Predicate {
@@ -169,6 +168,11 @@ export class Equals extends ComparisonPredicate {
169
168
return ( idx : number , cols : RecordBatch ) => col_func ( idx , cols ) == lit . v ;
170
169
}
171
170
}
171
+
172
+ protected _bindLitCol ( batch : RecordBatch , lit : Literal , col : Col ) {
173
+ // Equals is comutative
174
+ return this . _bindColLit ( batch , col , lit ) ;
175
+ }
172
176
}
173
177
174
178
export class LTeq extends ComparisonPredicate {
@@ -187,6 +191,11 @@ export class LTeq extends ComparisonPredicate {
187
191
const col_func = col . bind ( batch ) ;
188
192
return ( idx : number , cols : RecordBatch ) => col_func ( idx , cols ) <= lit . v ;
189
193
}
194
+
195
+ protected _bindLitCol ( batch : RecordBatch , lit : Literal , col : Col ) {
196
+ const col_func = col . bind ( batch ) ;
197
+ return ( idx : number , cols : RecordBatch ) => lit . v <= col_func ( idx , cols ) ;
198
+ }
190
199
}
191
200
192
201
export class GTeq extends ComparisonPredicate {
@@ -205,7 +214,12 @@ export class GTeq extends ComparisonPredicate {
205
214
const col_func = col . bind ( batch ) ;
206
215
return ( idx : number , cols : RecordBatch ) => col_func ( idx , cols ) >= lit . v ;
207
216
}
217
+
218
+ protected _bindLitCol ( batch : RecordBatch , lit : Literal , col : Col ) {
219
+ const col_func = col . bind ( batch ) ;
220
+ return ( idx : number , cols : RecordBatch ) => lit . v >= col_func ( idx , cols ) ;
221
+ }
208
222
}
209
223
210
- export function lit ( n : number ) : Value < any > { return new Literal ( n ) ; }
224
+ export function lit ( v : any ) : Value < any > { return new Literal ( v ) ; }
211
225
export function col ( n : string ) : Col < any > { return new Col ( n ) ; }
0 commit comments