Skip to content

Latest commit

 

History

History
579 lines (381 loc) · 25.1 KB

File metadata and controls

579 lines (381 loc) · 25.1 KB

src/minisql/executor/join.ml

Home · Files

Provides minisql executor join facilities for this project.

Package: minisql.executor.join

Reachable from entry: yes

Imports

Declarations

apply

function apply(leftRows, rightRows, boundJoin)

Executes the semantic nested-loop fallback for every supported join type. Tracks matched right rows for RIGHT/FULL padding and emits typed NULL padding for unmatched outer rows. Returns rows in deterministic left-major order.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.

View source

applyHash

function applyHash(leftRows, rightRows, boundJoin)

Backward-compatible entry point used by direct executor tests.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.

View source

applyHashBuild

function applyHashBuild(leftRows, rightRows, boundJoin, buildRight)

Selects a direct hash-build orientation without a server query token.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
buildRight dynamic buildRight value consumed by this operation.

View source

applyHashBuildCore

function applyHashBuildCore(leftRows, rightRows, boundJoin, buildRight, database, sessionId)

Executes the optimizer-selected hash build orientation. LEFT joins keep the right build side because unmatched-left tracking is part of that algorithm.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
buildRight dynamic buildRight value consumed by this operation.
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.

View source

applyHashBuildWithSpill

function applyHashBuildWithSpill(leftRows, rightRows, boundJoin, buildRight, temporaryRoot, threshold)

Historical direct API retains behavior without a cooperative server token.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
buildRight dynamic buildRight value consumed by this operation.
temporaryRoot dynamic temporaryRoot value consumed by this operation.
threshold dynamic threshold value consumed by this operation.

View source

applyHashBuildWithSpillControlled

function applyHashBuildWithSpillControlled(leftRows, rightRows, boundJoin, buildRight, temporaryRoot, threshold, database, sessionId)

Server execution path propagates cancellation/deadline state into spill workers.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
buildRight dynamic buildRight value consumed by this operation.
temporaryRoot dynamic temporaryRoot value consumed by this operation.
threshold dynamic threshold value consumed by this operation.
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.

View source

applyHashBuildWithSpillCore

function applyHashBuildWithSpillCore(leftRows, rightRows, boundJoin, buildRight, temporaryRoot, threshold, database, sessionId)

Executes a grace-style partitioned hash join when the selected build input exceeds the row threshold. Each partition is CRC/shape validated by the shared spill codec and removed on both success and failure paths.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
buildRight dynamic buildRight value consumed by this operation.
temporaryRoot dynamic temporaryRoot value consumed by this operation.
threshold dynamic threshold value consumed by this operation.
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.

View source

applyHashLeft

function applyHashLeft(leftRows, rightRows, boundJoin)

Preserves left-build hash joins for callers without a server query token.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.

View source

applyHashLeftCore

function applyHashLeftCore(leftRows, rightRows, boundJoin, database, sessionId)

Executes an INNER equi-join with the left input as the hash-build side. The emitted row remains left.values + right.values, so choosing the smaller build side never changes bound column indexes.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.

View source

applyHashRight

function applyHashRight(leftRows, rightRows, boundJoin)

Preserves right-build hash joins for callers without a server query token.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.

View source

applyHashRightCore

function applyHashRightCore(leftRows, rightRows, boundJoin, database, sessionId)

Executes an INNER or LEFT equi-join with a right-side hash table. NULL keys never match, full value comparison resolves collisions, and the original predicate is rechecked before emission. Unsupported shapes fall back.

Parameter Type Default Description
leftRows dynamic leftRows value consumed by this operation.
rightRows dynamic rightRows value consumed by this operation.
boundJoin dynamic boundJoin value consumed by this operation.
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.

View source

applySpilledPartition

function applySpilledPartition(task)

Reads and joins one pair of hash partitions on a native worker. Runs are deleted by their owning task on both successful and failed reads.

Parameter Type Default Description
task dynamic task value consumed by this operation.

View source

canHash

function canHash(boundJoin)

Returns whether the supplied value satisfies the hash condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
boundJoin dynamic boundJoin value consumed by this operation.

View source

cleanupPartitionTasks

function cleanupPartitionTasks(tasks)

Removes every spill run already owned by not-yet-submitted partition tasks.

Parameter Type Default Description
tasks dynamic tasks value consumed by this operation.

View source

combine

function combine(left, right)

Implements combine for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.

View source

componentName

function componentName()

Performs the componentName operation for the minisql executor join module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

conditionPasses

function conditionPasses(condition, row)

Implements condition passes for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
condition dynamic condition value consumed by this operation.
row dynamic row value consumed by this operation.

View source

equalityColumns

function equalityColumns(boundJoin)

Implements equality columns for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
boundJoin dynamic boundJoin value consumed by this operation.

View source

fail

function fail(code, operation, message)

Performs the fail operation for the minisql executor join module. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
code dynamic code value consumed by this operation.
operation dynamic operation value consumed by this operation.
message dynamic Human-readable message associated with the operation.

View source

HASH_BUCKET_COUNT

const HASH_BUCKET_COUNT = 257

Defines the hash bucket count constant used by the minisql executor join module.

View source

HASH_MASK

const HASH_MASK = 2147483647

Defines the hash mask constant used by the minisql executor join module.

View source

hashBytes

function hashBytes(input, seed)

Implements hash bytes for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
input dynamic input value consumed by this operation.
seed dynamic seed value consumed by this operation.

View source

hashValue

function hashValue(value)

Implements hash value for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

integerDivide

function integerDivide(numerator, denominator)

Computes non-negative truncating integer division without losing precision.

Parameter Type Default Description
numerator dynamic numerator value consumed by this operation.
denominator dynamic denominator value consumed by this operation.

View source

INTRA_QUERY_WORKERS

const INTRA_QUERY_WORKERS = 4

Defines the intra query workers constant used by the minisql executor join module.

View source

INVALID_ARGUMENT

const INVALID_ARGUMENT = 9001

Join executor. M16 provides the correctness-first nested-loop implementation.

View source

isImplemented

function isImplemented()

Returns whether implemented satisfies the condition required by the minisql executor join module. Returns the computed value or operation status. Does not modify its inputs.

View source

nullValues

function nullValues(table)

Implements null values for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
table dynamic table value consumed by this operation.

View source

nullValuesForTypes

function nullValuesForTypes(typeInfos)

Implements null values for types for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
typeInfos dynamic typeInfos value consumed by this operation.

View source

pollJoinControl

function pollJoinControl(database, sessionId, counter, operation)

Polls a server-owned query at bounded hash-operator intervals. Direct module tests pass a void database and retain the dependency-free historical API.

Parameter Type Default Description
database dynamic database value consumed by this operation.
sessionId dynamic Identifier of session.
counter dynamic counter value consumed by this operation.
operation dynamic operation value consumed by this operation.

View source

projectedSpillRows

function projectedSpillRows(rows)

Converts scanned rows to the generic validated spill-run representation.

Parameter Type Default Description
rows dynamic rows value consumed by this operation.

View source

scannedSpillRows

function scannedSpillRows(rows)

Restores value-only scanned rows after a validated spill-run read.

Parameter Type Default Description
rows dynamic rows value consumed by this operation.

View source

targetMilestone

function targetMilestone()

Performs the targetMilestone operation for the minisql executor join module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source