Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion grafast/grafast/src/engine/executeBucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
ExecuteStepEvent,
ExecutionDetails,
ExecutionDetailsStream,
ExecutionDetailsValues,
ExecutionEntryFlags,
ExecutionExtra,
ExecutionResults,
Expand Down Expand Up @@ -830,7 +831,9 @@ export function executeBucket(
indexMap: makeIndexMap(count),
indexForEach: makeIndexForEach(count),
count,
values,
values: Object.assign(values, {
get: values.at as ExecutionDetailsValues["get"],
}),
extra,
stream: evaluateStream(bucket, step, distributorOptions),
};
Expand Down
17 changes: 11 additions & 6 deletions grafast/grafast/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,19 +720,24 @@ export interface ExecutionDetailsStream {
initialCount: number;
}

type TupleIndicies<T extends readonly [...any[]]> = {
[K in keyof T]: K extends `${infer N extends number}` ? N : never;
}[keyof T];
export type ExecutionDetailsValues<
TDeps extends readonly [...any[]] = readonly [...any[]],
> = { [TKey in keyof TDeps]: ExecutionValue<TDeps[TKey]> } & {
get<const TKey extends TupleIndicies<TDeps>>(
idx: TKey,
): ExecutionValue<TDeps[TKey]>;
};
export interface ExecutionDetails<
TDeps extends readonly [...any[]] = readonly [...any[]],
> {
/** The size of the batch being processed */
count: number;

/** An "execution value" for each dependency of the step */
values: {
[DepIdx in keyof TDeps]: ExecutionValue<TDeps[DepIdx]>;
} & {
length: TDeps["length"];
map: ReadonlyArray<ExecutionValue<TDeps[number]>>["map"];
};
values: ExecutionDetailsValues<TDeps>;

/** Helper; makes array from `callback(batchIndex)` for each `0 <= batchIndex < count` */
indexMap: IndexMap;
Expand Down
2 changes: 1 addition & 1 deletion grafast/grafast/src/steps/listTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class __ListTransformStep<
);
}

const listStepValue = values[this.listStepDepId];
const listStepValue = values[this.listStepDepId as 0];

if (itemStep._isUnary) {
const list = listStepValue.unaryValue();
Expand Down
4 changes: 2 additions & 2 deletions grafast/grafast/src/steps/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export class ListenStep<
values,
stream,
}: ExecutionDetails<
readonly [GrafastSubscriber<TTopics>, TTopic]
readonly [GrafastSubscriber<TTopics>, TTopic, TTopics[TTopic] | undefined]
>): GrafastResultStreamList<TTopics[TTopic]> {
if (!stream) {
throw new Error("ListenStep must be streamed, never merely executed");
}
const pubsubValue = values[this.pubsubDep as 0];
const topicValue = values[this.topicDep as 1];
const initialEventValue =
this.initialEventDep !== null ? values[this.initialEventDep] : null;
this.initialEventDep !== null ? values[this.initialEventDep as 2] : null;
return indexMap((i) => {
const pubsub = pubsubValue.at(i);
if (!pubsub) {
Expand Down
Loading