MCPcopy Create free account
hub / github.com/apache/arrow / IsSatisfiable

Method IsSatisfiable

cpp/src/arrow/compute/expression.cc:344–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342} // namespace
343
344bool Expression::IsSatisfiable() const {
345 if (type() == nullptr) return true;
346 if (type()->id() != Type::BOOL) return true;
347
348 if (auto lit = literal()) {
349 if (lit->null_count() == lit->length()) {
350 return false;
351 }
352
353 if (lit->is_scalar()) {
354 return lit->scalar_as<BooleanScalar>().value;
355 }
356
357 return true;
358 }
359
360 if (field_ref()) return true;
361
362 auto call = CallNotNull(*this);
363
364 // invert(true_unless_null(x)) is always false or null by definition
365 // true_unless_null arises in simplification of inequalities below
366 if (call->function_name == "invert") {
367 if (auto nested_call = call->arguments[0].call()) {
368 if (nested_call->function_name == "true_unless_null") return false;
369 }
370 }
371
372 if (call->function_name == "and_kleene" || call->function_name == "and") {
373 return std::all_of(call->arguments.begin(), call->arguments.end(),
374 [](const Expression& arg) { return arg.IsSatisfiable(); });
375 }
376 if (call->function_name == "or_kleene" || call->function_name == "or") {
377 return std::any_of(call->arguments.begin(), call->arguments.end(),
378 [](const Expression& arg) { return arg.IsSatisfiable(); });
379 }
380
381 return true;
382}
383
384namespace {
385

Callers 9

FilterRowGroupsMethod · 0.80
TestRowGroupsMethod · 0.80
TryCountRowsMethod · 0.80
GetFragmentsImplMethod · 0.80
GetFragmentsMethod · 0.80
GetFragmentsAsyncMethod · 0.80
CountRowsMethod · 0.80
GetFragmentsImplMethod · 0.80
TESTFunction · 0.80

Calls 11

field_refFunction · 0.85
CallNotNullFunction · 0.85
is_scalarMethod · 0.80
callMethod · 0.80
typeFunction · 0.70
literalFunction · 0.70
idMethod · 0.45
null_countMethod · 0.45
lengthMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 2

TestRowGroupsMethod · 0.64
TESTFunction · 0.64