shouldSkipLiveBatchWithFilter will check max and min for the corresponding column against the filter express and determines whether we should skip processing this live batch. Following constraints apply: 1. Filter must be on main table. 2. Filter must be a binary expression. 3. OPs must be one of (E
(b *memstore.LiveBatch, filter expr.Expr)
| 1395 | // 5. Another side of the xpr must be NumericalLiteral |
| 1396 | // 6. ColumnType must be UInt32 |
| 1397 | func shouldSkipLiveBatchWithFilter(b *memstore.LiveBatch, filter expr.Expr) bool { |
| 1398 | if filter == nil { |
| 1399 | return false |
| 1400 | } |
| 1401 | |
| 1402 | if binExpr, ok := filter.(*expr.BinaryExpr); ok { |
| 1403 | var columnExpr *expr.VarRef |
| 1404 | var numExpr *expr.NumberLiteral |
| 1405 | op := binExpr.Op |
| 1406 | switch op { |
| 1407 | case expr.GTE, expr.GT, expr.LT, expr.LTE, expr.EQ: |
| 1408 | default: |
| 1409 | return false |
| 1410 | } |
| 1411 | // First try lhs VarRef, rhs Num. |
| 1412 | lhsVarRef, lhsOK := binExpr.LHS.(*expr.VarRef) |
| 1413 | rhsNum, rhsOK := binExpr.RHS.(*expr.NumberLiteral) |
| 1414 | if lhsOK && rhsOK { |
| 1415 | columnExpr = lhsVarRef |
| 1416 | numExpr = rhsNum |
| 1417 | } else { |
| 1418 | // Then try rhs VarRef, lhs Num. |
| 1419 | lhsNum, lhsOK := binExpr.LHS.(*expr.NumberLiteral) |
| 1420 | rhsVarRef, rhsOK := binExpr.RHS.(*expr.VarRef) |
| 1421 | if lhsOK && rhsOK { |
| 1422 | // Swap column to the left and number to right. |
| 1423 | columnExpr = rhsVarRef |
| 1424 | numExpr = lhsNum |
| 1425 | // Invert the OP. |
| 1426 | switch op { |
| 1427 | case expr.GTE: |
| 1428 | op = expr.LTE |
| 1429 | case expr.GT: |
| 1430 | op = expr.LT |
| 1431 | case expr.LTE: |
| 1432 | op = expr.GTE |
| 1433 | case expr.LT: |
| 1434 | op = expr.GT |
| 1435 | } |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | if columnExpr != nil && numExpr != nil { |
| 1440 | // Time filters and main table filters are guaranteed to be on main table. |
| 1441 | vp := b.Columns[columnExpr.ColumnID] |
| 1442 | if vp == nil { |
| 1443 | return true |
| 1444 | } |
| 1445 | |
| 1446 | if columnExpr.DataType != memCom.Uint32 { |
| 1447 | return false |
| 1448 | } |
| 1449 | |
| 1450 | num := int64(numExpr.Int) |
| 1451 | minUint32, maxUint32 := vp.(memCom.LiveVectorParty).GetMinMaxValue() |
| 1452 | min, max := int64(minUint32), int64(maxUint32) |
| 1453 | switch op { |
| 1454 | case expr.GTE: |
no test coverage detected