seawinde commented on code in PR #59154:
URL: https://github.com/apache/doris/pull/59154#discussion_r2685601522
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/StructInfoMap.java:
##########
@@ -51,80 +52,156 @@
public class StructInfoMap {
public static final Logger LOG = LogManager.getLogger(StructInfoMap.class);
+ // 2166136261
+ private static final int FNV32_OFFSET_BASIS = 0x811C9DC5;
+ // 16777619
+ private static final int FNV32_PRIME = 0x01000193;
/**
* The map key is the relation id bit set to get corresponding plan
accurately
*/
- private final Map<BitSet, Pair<GroupExpression, List<BitSet>>>
groupExpressionMap = new HashMap<>();
+ private final Map<BitSet, Pair<GroupExpression, List<BitSet>>>
groupExpressionMapByRelationId = new HashMap<>();
/**
* The map key is the relation id bit set to get corresponding plan
accurately
*/
- private final Map<BitSet, StructInfo> infoMap = new HashMap<>();
- private long refreshVersion = 0;
+ private final Map<BitSet, StructInfo> infoMapByRelationId = new
HashMap<>();
+
+ /**
+ * The map key is the common table id bit set to get corresponding plan
accurately
+ */
+ private final Map<BitSet, Pair<GroupExpression, List<BitSet>>>
groupExpressionMapByTableId = new HashMap<>();
+ /**
+ * The map key is the common table id bit set to get corresponding plan
accurately
+ */
+ private final Map<BitSet, StructInfo> infoMapByTableId = new HashMap<>();
+
+ // The key is the tableIds query used, the value is the refresh version
when last refresh
+ private final Map<BitSet, Integer> refreshVersion = new HashMap<>();
/**
* get struct info according to table map
*
- * @param tableMap the original table map
+ * @param targetIdMap the original table map
* @param group the group that the mv matched
* @return struct info or null if not found
*/
- public @Nullable StructInfo getStructInfo(CascadesContext cascadesContext,
BitSet tableMap, Group group,
- Plan originPlan, boolean forceRefresh) {
- StructInfo structInfo = infoMap.get(tableMap);
- if (structInfo != null) {
- return structInfo;
- }
- if (groupExpressionMap.isEmpty() ||
!groupExpressionMap.containsKey(tableMap)) {
- refresh(group, cascadesContext, tableMap, new HashSet<>(),
- forceRefresh);
-
group.getStructInfoMap().setRefreshVersion(cascadesContext.getMemo().getRefreshVersion());
- }
- if (groupExpressionMap.containsKey(tableMap)) {
- Pair<GroupExpression, List<BitSet>> groupExpressionBitSetPair =
getGroupExpressionWithChildren(tableMap);
- // NOTICE: During the transition from physicalAggregate to logical
aggregation,
- // the original function signature needs to remain unchanged
because the constructor of LogicalAggregation
- // will recalculate the signature of the aggregation function.
- // When the calculated signature is inconsistent with the original
signature
- // (e.g. due to the influence of the session variable
enable_decimal256),
- // a problem will arise where the output type of the rewritten
plan is inconsistent with
- // the output type of the upper-level operator.
- structInfo = MoreFieldsThread.keepFunctionSignature(() ->
- constructStructInfo(groupExpressionBitSetPair.first,
groupExpressionBitSetPair.second,
- originPlan, cascadesContext));
- infoMap.put(tableMap, structInfo);
+ public @Nullable StructInfo getStructInfo(CascadesContext cascadesContext,
BitSet targetIdMap, Group group,
+ Plan originPlan, boolean forceRefresh, boolean tableIdMode) {
+ StructInfo structInfo;
+ if (tableIdMode) {
Review Comment:
use Strategy factory to opt the code
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]