Provides minisql executor sort facilities for this project.
Package: minisql.executor.sort
Reachable from entry: yes
minisql/common/endian.mlasendian→ src/minisql/common/endian.mlminisql/common/uuid.mlasuuid→ src/minisql/common/uuid.mlminisql/executor/projection.mlasprojection→ src/minisql/executor/projection.mlminisql/platform/clock.mlasclock→ src/minisql/platform/clock.mlminisql/platform/file.mlasfile_api→ src/minisql/platform/file.mlminisql/security/key_provider.mlaskey_provider→ src/minisql/security/key_provider.mlminisql/sql/types.mlastypes→ src/minisql/sql/types.mlminisql/sql/values.mlasvalues→ src/minisql/sql/values.mlminisql/storage/row_codec.mlasrow_codec→ src/minisql/storage/row_codec.mlstd/crypto/aes_gcm.mlasaes_gcm→../MiniLangCompilerML/std/crypto/aes_gcm.ml— external dependency
function bytesEqual(left, right)Performs the bytesEqual operation for the minisql executor sort 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 |
|---|---|---|---|
left |
dynamic |
— | left value consumed by this operation. |
right |
dynamic |
— | right value consumed by this operation. |
function cleanupRuns(runs)Implements cleanup runs for this module. Returns its result or propagates a structured error from validation or a dependency. Performs I/O through its file, transport, or storage dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
runs |
dynamic |
— | runs value consumed by this operation. |
function combinedValues(row)Implements combined 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 |
|---|---|---|---|
row |
dynamic |
— | row value consumed by this operation. |
function compareNullable(left, right, descending, nullsFirst, nullsSpecified)Compares nullable using the supplied inputs. Returns the computed value or operation status. Does not modify its inputs.
| Parameter | Type | Default | Description |
|---|---|---|---|
left |
dynamic |
— | left value consumed by this operation. |
right |
dynamic |
— | right value consumed by this operation. |
descending |
dynamic |
— | descending value consumed by this operation. |
nullsFirst |
dynamic |
— | nullsFirst value consumed by this operation. |
nullsSpecified |
dynamic |
— | nullsSpecified value consumed by this operation. |
function compareRows(left, right, orderItems)Compares rows using the supplied inputs. Returns the computed value or operation status. Does not modify its inputs.
| Parameter | Type | Default | Description |
|---|---|---|---|
left |
dynamic |
— | left value consumed by this operation. |
right |
dynamic |
— | right value consumed by this operation. |
orderItems |
dynamic |
— | orderItems value consumed by this operation. |
function componentName()Performs the componentName operation for the minisql executor sort module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
const CORRUPT_DATA = 9004Defines the corrupt data constant used by the minisql executor sort module.
function decodeSqlValue(kind, raw)Decodes SQL value using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
kind |
dynamic |
— | kind value consumed by this operation. |
raw |
dynamic |
— | raw value consumed by this operation. |
function encodeHeader(valueCount, orderCount, encrypted)Encodes header using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
valueCount |
dynamic |
— | Number of value to process. |
orderCount |
dynamic |
— | Number of order to process. |
encrypted |
dynamic |
— | encrypted value consumed by this operation. |
function fail(code, operation, message)Performs the fail operation for the minisql executor sort 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. |
const INVALID_ARGUMENT = 9001Stable merge sorting for projected rows. M46 adds a correctness-first
function isImplemented()Returns whether implemented satisfies the condition required by the minisql executor sort module. Returns the computed value or operation status. Does not modify its inputs.
const MAX_SPILL_FILE_BYTES = 268435456Defines the max spill file bytes constant used by the minisql executor sort module.
function merge(left, right, orderItems)Implements merge 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. |
orderItems |
dynamic |
— | orderItems value consumed by this operation. |
synchronized function nextSpillToken()Generates a process-unique spill namespace under an intrinsic function lock. The synchronized modifier serializes nonce updates across parallel SELECT workers.
function rawValues(input)Implements raw 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 |
|---|---|---|---|
input |
dynamic |
— | input value consumed by this operation. |
function readRun(run)Reads run using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Performs I/O through its file, transport, or storage dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
run |
dynamic |
— | run value consumed by this operation. |
function runPath(root, token, index)Runs path using the supplied inputs. Returns the computed value or operation status. Performs I/O through its file, transport, or storage dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
root |
dynamic |
— | root value consumed by this operation. |
token |
dynamic |
— | token value consumed by this operation. |
index |
dynamic |
— | Zero-based index of the affected item. |
function sortProjected(rows, orderItems)Sorts projected using the supplied inputs. 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 |
|---|---|---|---|
rows |
dynamic |
— | rows value consumed by this operation. |
orderItems |
dynamic |
— | orderItems value consumed by this operation. |
function sortProjectedWithSpill(rows, orderItems, temporaryRoot, threshold)Performs stable external merge sorting when rows exceed threshold. Sorted chunks are written as validated runs, then merged pairwise until one remains. Every success and failure path removes owned temporary files.
| Parameter | Type | Default | Description |
|---|---|---|---|
rows |
dynamic |
— | rows value consumed by this operation. |
orderItems |
dynamic |
— | orderItems value consumed by this operation. |
temporaryRoot |
dynamic |
— | temporaryRoot value consumed by this operation. |
threshold |
dynamic |
— | threshold value consumed by this operation. |
const SPILL_HEADER_SIZE = 16Defines the spill header size constant used by the minisql executor sort module.
const SPILL_VERSION = 1Defines the spill version constant used by the minisql executor sort module.
function spillAad(rowIndex)Creates domain-separated AAD for one ordered spill row.
| Parameter | Type | Default | Description |
|---|---|---|---|
rowIndex |
dynamic |
— | Zero-based index of row. |
function spillMagic()Implements spill magic for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
spillNonceStores module-wide spill nonce state for the minisql executor sort module.
- minisql.executor.sort.SpillRun — struct
function spillSchema(rows, valueCount, orderCount)Implements spill schema for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
rows |
dynamic |
— | rows value consumed by this operation. |
valueCount |
dynamic |
— | Number of value to process. |
orderCount |
dynamic |
— | Number of order to process. |
function spillSpec(kind)Implements spill spec for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
kind |
dynamic |
— | kind value consumed by this operation. |
function spillType(kind)Implements spill type for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
kind |
dynamic |
— | kind value consumed by this operation. |
function targetMilestone()Performs the targetMilestone operation for the minisql executor sort module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.
function topNProjected(rows, orderItems, count)Retains only the best count rows in stable ORDER BY order. The optimizer limits this O(rows*count) implementation to small windows, avoiding external runs and a complete result sort for interactive ORDER BY ... LIMIT queries.
| Parameter | Type | Default | Description |
|---|---|---|---|
rows |
dynamic |
— | rows value consumed by this operation. |
orderItems |
dynamic |
— | orderItems value consumed by this operation. |
count |
dynamic |
— | Number of items or units to process. |
function writeRun(path, rows, valueCount, orderCount)Writes run using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns its result or propagates a structured error from validation or a dependency. Performs I/O through its file, transport, or storage dependencies.
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
dynamic |
— | Path of the file or directory used by the operation. |
rows |
dynamic |
— | rows value consumed by this operation. |
valueCount |
dynamic |
— | Number of value to process. |
orderCount |
dynamic |
— | Number of order to process. |