| 1062 | } |
| 1063 | |
| 1064 | void Expr::evalEncodings( |
| 1065 | const SelectivityVector& rows, |
| 1066 | EvalCtx& context, |
| 1067 | VectorPtr& result) { |
| 1068 | if (deterministic_ && !skipFieldDependentOptimizations()) { |
| 1069 | bool hasFlat = false; |
| 1070 | for (auto* field : distinctFields_) { |
| 1071 | if (isFlat(*context.getField(field->index(context)))) { |
| 1072 | hasFlat = true; |
| 1073 | break; |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | if (!hasFlat) { |
| 1078 | VectorPtr wrappedResult; |
| 1079 | // Attempt peeling and bound the scope of the context used for it. |
| 1080 | |
| 1081 | withContextSaver([&](ContextSaver& saveContext) { |
| 1082 | LocalSelectivityVector newRowsHolder(context); |
| 1083 | LocalSelectivityVector finalRowsHolder(context); |
| 1084 | LocalDecodedVector decodedHolder(context); |
| 1085 | auto peelEncodingsResult = peelEncodings( |
| 1086 | context, |
| 1087 | saveContext, |
| 1088 | rows, |
| 1089 | decodedHolder, |
| 1090 | newRowsHolder, |
| 1091 | finalRowsHolder); |
| 1092 | auto* newRows = peelEncodingsResult.newRows; |
| 1093 | if (newRows) { |
| 1094 | VectorPtr peeledResult; |
| 1095 | // peelEncodings() can potentially produce an empty selectivity |
| 1096 | // vector if all selected values we are waiting for are nulls. So, |
| 1097 | // here we check for such a case. |
| 1098 | if (newRows->hasSelections()) { |
| 1099 | if (peelEncodingsResult.mayCache) { |
| 1100 | evalWithMemo(*newRows, context, peeledResult); |
| 1101 | } else { |
| 1102 | evalWithNulls(*newRows, context, peeledResult); |
| 1103 | } |
| 1104 | } |
| 1105 | wrappedResult = context.getPeeledEncoding()->wrap( |
| 1106 | this->type(), context.pool(), peeledResult, rows); |
| 1107 | } |
| 1108 | }); |
| 1109 | |
| 1110 | if (wrappedResult != nullptr) { |
| 1111 | context.moveOrCopyResult(wrappedResult, rows, result); |
| 1112 | return; |
| 1113 | } |
| 1114 | } |
| 1115 | } |
| 1116 | evalWithNulls(rows, context, result); |
| 1117 | } |
| 1118 | |
| 1119 | bool Expr::removeSureNulls( |
| 1120 | const SelectivityVector& rows, |
nothing calls this directly
no test coverage detected