englefly commented on PR #67549:
URL: https://github.com/apache/doris/pull/67549#issuecomment-6120369457
按讨论把 struct info 的表示换成 **rope + 按需物化**(commit ed6523684ee)。
结构:
- `HboStructParts` 类删掉,成员并入 `GroupStructInfo`:一个 group 一份描述,memo 在
`Group#getOrComputeHboStructInfo()` 上。
- rope = 一个有序 piece 列表:`Text`(两个 mode 的文本片段)/ `ScanToken`(该层的 scan)/
`Child`(子 group 的描述引用)。父 group
只登记自己那一层(`F{…}(`、`J{…,c:[…]}(`、分隔符、括号),**不再复制或重建子的串**。
- 三条串与指纹改为按需物化并按 (mode, form) 缓存:`getCanonical(mode)` / `getShape(mode)` /
`getFingerprint(mode)`(= sha256(shape))。四条串 + 两个哈希从"每 group
急切算"变成"只算被请求的"——读侧只用 fingerprint,因此不会再物化 canonical。
- 物化时若子节点该 (mode, form) 的串已物化,直接 append 它的缓存串,**不再递归进它的子树**(即"g2 已生成 ⇒ 生成 g1
不访问 g3")。
- `collectJoinConditions` 改成一次遍历同时产出 WL/NL 两个串(原先同一个 conjunct 归一化两遍)。
- `scans` 保持 eager(不产生字符串工作,drift 判定按下标配对需要它);scan 的 baseline 仍在**描述 group
时**采样,物化阶段不碰 catalog,因此懒物化不会让打印出的数据状态比读侧判定用的更新。
验证(本地 FE 用本分支重新编译并重启):
1. 固定查询集 17 条 / 63 行 EXPLAIN 注解 **逐字节相同**;
2. `run-regression-test.sh --run -d query_p0/hbo`:19 suites,失败 8
个,与改动前**完全一致**(全是 `query_p0/hbo/legacy` 里缺 `hbo_slow_query_threshold_ms` 配置的用例);
3. 单测 `GroupStructInfoCompositionTest` 4/4 通过,新增断言:父的 canonical 里**字面包含**子(含
join 链上的 agg 叶子)的 canonical;先物化子再物化父时物化计数器只 +1(证明没有重走已物化子节点的子树);同一 (mode, form)
重复请求重算 0 次。
**step 2(链信息记忆化,把链遍历从 O(n²) 降到 O(n))本轮没做**:实现时碰到一个语义耦合需要单独处理——现在"同一个 group
在一次描述里出现两次 ⇒ INVALID"(CTE/共享子图)是靠链遍历顺便维护的 `ctx.visited`
保证的;一旦把链信息(`conditionsWL/NL` + 有序叶子)记忆化,链内部不再被遍历,这个检测就必须改成"每份描述带上它覆盖的 group id
集合、合并时检查交集"。这是独立的一块改动,我打算单独一个 commit 做,并补一条"链只走一遍"的计数断言;rope 落地后链信息正好可以挂在这个
rope 节点上。
--
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]