dmitry-chirkov-dremio commented on code in PR #50372:
URL: https://github.com/apache/arrow/pull/50372#discussion_r3593460394
##########
cpp/src/gandiva/projector.cc:
##########
@@ -283,6 +288,10 @@ Status Projector::ValidateArrayDataCapacity(const
arrow::ArrayData& array_data,
const std::string& Projector::DumpIR() { return llvm_generator_->ir(); }
+const std::string& Projector::DumpUnoptimizedIR() {
Review Comment:
One concrete implementation would be to make the captured IR state, rather
than the mutable Configuration, the source of truth. WDYT?
In Engine expose whether unoptimized IR was actually captured:
```cpp
bool has_unoptimized_ir() const {
return !unoptimized_module_ir_.empty();
}
```
Forward that through LLVMGenerator:
```cpp
bool has_unoptimized_ir() const {
return engine_->has_unoptimized_ir();
}
```
Then Projector can guard the accessor using the actual stored state:
```cpp
Result<std::string> Projector::DumpUnoptimizedIR() {
ARROW_RETURN_IF(
!llvm_generator_->has_unoptimized_ir(),
Status::Invalid("Unoptimized IR was not captured when this projector
was built"));
return llvm_generator_->unoptimized_ir();
}
```
This also handles both cache hits and later Configuration mutations without
duplicating build-time state in Projector.
A regression test could build a projector with dump_ir=false, mutate the
shared configuration afterward, and verify that the accessor still returns
Invalid:
```cpp
auto configuration = std::make_shared<Configuration>(
true, gandiva::default_function_registry(), /*dump_ir=*/false);
std::shared_ptr<Projector> projector;
ASSERT_OK(Projector::Make(schema, {expr}, configuration, &projector));
configuration->set_dump_ir(true);
ASSERT_RAISES_WITH_MESSAGE(
Invalid,
"Invalid: Unoptimized IR was not captured when this projector was built",
projector->DumpUnoptimizedIR());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]