-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
algebra::transport takes a class with a transport() and prepare() method, with one overload per case of the PolyValue. Often we only care about a few cases, so we have a catch-all overload that handles any type.
If you make a mistake in the type signature of any of the overloads, you might not get a compile error. It will just be dead code, and algebra::transport will call the fallback overload in that case. (Or in the case of prepare(), algebra::transport will just not call it.)
I wonder if we can improve this by defining a Transport interface. Something like this:
template<typename Result> class Transport { public: void prepare(ABT&, const ScanNode&) {} Result transport(ABT&, const ScanNode&) = 0; ... };
Then an individual transport implementation can opt-in to better type errors like this:
class VariableCollector : Transport<void> { void prepare(ABT&, const ScanNode&) override { ... } Result transport(ABT&, const ScanNode&) override { ... } };
The 'override' ensures the method signatures are actually the ones the caller is expecting.