MCPcopy Create free account
hub / github.com/bytedance/bolt / makeBetweenFilter

Method makeBetweenFilter

bolt/expression/ExprToSubfieldFilter.cpp:481–533  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

479
480// static
481std::unique_ptr<common::Filter> ExprToSubfieldFilterParser::makeBetweenFilter(
482 const core::TypedExprPtr& lowerExpr,
483 const core::TypedExprPtr& upperExpr,
484 core::ExpressionEvaluator* evaluator,
485 bool negated) {
486 auto lower = toConstant(lowerExpr, evaluator);
487 if (!lower) {
488 return nullptr;
489 }
490 auto upper = toConstant(upperExpr, evaluator);
491 if (!upper) {
492 return nullptr;
493 }
494 switch (lower->typeKind()) {
495 case TypeKind::INTEGER:
496 if (negated) {
497 return notBetween(
498 singleValue<int32_t>(lower), singleValue<int32_t>(upper));
499 }
500 return between(singleValue<int32_t>(lower), singleValue<int32_t>(upper));
501 case TypeKind::BIGINT:
502 if (negated) {
503 return notBetween(
504 singleValue<int64_t>(lower), singleValue<int64_t>(upper));
505 }
506 return between(singleValue<int64_t>(lower), singleValue<int64_t>(upper));
507 case TypeKind::DOUBLE:
508 return negated
509 ? nullptr
510 : betweenDouble(
511 singleValue<double>(lower), singleValue<double>(upper));
512 case TypeKind::REAL:
513 return negated
514 ? nullptr
515 : betweenFloat(singleValue<float>(lower), singleValue<float>(upper));
516 case TypeKind::VARCHAR:
517 if (negated) {
518 return notBetween(
519 std::string(singleValue<StringView>(lower)),
520 std::string(singleValue<StringView>(upper)));
521 }
522 return between(
523 std::string(singleValue<StringView>(lower)),
524 std::string(singleValue<StringView>(upper)));
525 case TypeKind::TIMESTAMP:
526 return negated
527 ? nullptr
528 : between(
529 singleValue<Timestamp>(lower), singleValue<Timestamp>(upper));
530 default:
531 return nullptr;
532 }
533}
534
535// static
536std::unique_ptr<common::Filter> ExprToSubfieldFilterParser::makeOrFilter(

Callers

nothing calls this directly

Calls 6

toConstantFunction · 0.85
notBetweenFunction · 0.85
betweenFunction · 0.85
betweenDoubleFunction · 0.85
betweenFloatFunction · 0.85
typeKindMethod · 0.45

Tested by

no test coverage detected