Class PreparedInSet

java.lang.Object
dev.frostlake.executor.expressions.PreparedInSet

public class PreparedInSet extends Object
A membership index over a subquery's first-column values, built once for an uncorrelated value IN (subquery) so each outer row is an O(1) probe instead of an O(subqueryRows) linear scan — turning the membership test from O(outer × sub) into O(outer + sub).

It reproduces exactly the equality used by ExpressionEvaluatorVisitor.equals: two Numbers compare numerically and scale-insensitively (like BigDecimal.compareTo — so 5, 5L, 5.0 are equal), while any comparison involving a non-Number compares the operands' toString(). The three-valued NULL rules live in the CALLER: it never probes a NULL, and turns a miss into UNKNOWN when hasNull() says the set held a NULL member. To honour both equality rules with one structure every numeric value is indexed under a canonical numeric key and every value under its toString(): a Number probe checks the numeric key (numeric-vs-numeric) or the string key (numeric-vs-non-numeric), and a non-Number probe checks only the string key.

  • Constructor Details

    • PreparedInSet

      public PreparedInSet()
  • Method Details

    • build

      public static PreparedInSet build(List<Row> rows)
    • hasNull

      public boolean hasNull()
      True when the indexed subquery column contained at least one NULL member.
    • contains

      public boolean contains(Object value)
      True iff value would equal some indexed value under the engine's IN equality.