a predicate comparing two columns should select through the vectors' own comparison, not generated code

未关闭
#6,499 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
clojure, java
领域
databases

调研方向

Read src/test/clojure/xtdb/scalar_predicate_test.clj and the existing scalar predicate kernels from #4969 to see how their selection is checked against the generated selection spec. Then inspect expression.clj's ->scalar-predicate, ScalarCompare.kt, and evalWords; the issue calls for same-type column comparisons under and/or/not, with NULL, NaN, and signed zero behavior covered. Done means the oracle test confirms matching selections for covered types and unsupported pairs fall back per batch.

由索引模型根据 Issue 内容生成。

描述

expression engine performance

A predicate comparing two columns of a batch, l_commitdate < l_receiptdate, should select through the vectors' own comparison, as a column against a literal or param already does.

  • #4969's kernels cover a column against a literal or param only
    A leaf with a column on both sides makes the recogniser decline, so the whole predicate — its and/or/not siblings included — runs as generated per-row code.

  • TPC-H's Q4, Q12 and Q21 filter on two lineitem date columns

    • check: their share of query time spent in the generated predicate is unmeasured.

Problem

  • ->scalar-predicate (expression.clj) returns nil for a leaf without a literal or param operand
    So one such leaf takes the whole predicate off the kernel.

  • The vectors' compare loops take a scalar right-hand side
    Vector.compare(op, rhs, sel, mask) reads one value per batch; a column right-hand side needs a second vector read in the same branch-free word loop (evalWords, ScalarCompare.kt), its validity ANDed in.

Potential approach

  • goal: a leaf comparing two columns of one covered type is a kernel leaf
    These four are jointly sufficient.

    • Covered means the types #4969 covers against a literal
      i8–i64, f32, f64 and date with all six CmpOps; utf8 and varbinary with EQ/NEQ only.

    • Each covered vector compares itself against another vector of its own type
      A Vector.compare overload taking a vector right-hand side. NULL on either side is not selected; NaN and ±0.0 as the generated code has them.

    • Both sides read through one sel and mask
      A predicate's columns are all columns of its input relation, which views them through one indirection. x < x needs nothing special.

    • The recogniser builds the leaf under the existing and/or/not, falling back per batch where either vector isn't covered, and pinned by an oracle test against the generated selection spec, as src/test/clojure/xtdb/scalar_predicate_test.clj does.

Out of scope

  • Mixed-type pairs (i64 against f64, date against timestamp), which the generated code promotes; they decline.
  • A column against an expression (l_a + 1 < l_b).
  • Join conditions comparing columns of two relations.
主要语言
Clojure
星标
3.1k
派生
193
平均合并
1 天 8 小时
30 天内合并 PR
73

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

xtdb/xtdb 的其他 Issue

查看 xtdb/xtdb 的全部 Issue

相似的 Issue

更多 Clojure Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。