Variable

An monotonically increasing set of Tuples.

There are three stages in the lifecycle of a tuple:

1. A tuple is added to this.toAdd, but is not yet visible externally. 2. Newly added tuples are then promoted to this.recent for one iteration. 3. After one iteration, recent tuples are moved to this.stable for posterity.

Each time this.changed() is called, the recent relation is folded into stable, and the toAdd relations are merged, potentially deduplicated against stable, and then made recent. This way, across calls to changed() all added tuples are in recent at least once and eventually all are in stable.

A Variable may optionally be instructed not to de-duplicate its tuples, for reasons of performance. Such a variable cannot be relied on to terminate iterative computation, and it is important that any cycle of derivations have at least one de-duplicating variable on it. TODO: tuple should be constrainted to something with Key/Value.

Members

Aliases

TT
alias TT = TupleT

Convenient alias to retrieve the tuple type.

Functions

complete
Relation!TupleT complete()

Consumes the variable and returns a relation.

countStable
size_t countStable()
fromAntiJoin
void fromAntiJoin(Input1T input1, Input2T input2)

Adds tuples from input1 whose key is not present in input2.

fromJoin
void fromJoin(Input1T input1, Input2T input2)

Adds tuples that result from joining input1 and input2.

fromMap
void fromMap(Input1T input)

Adds tuples that result from mapping input.

insert
void insert(Relation!TupleT relation)
void insert(TupleT[] relation)
void insert(T relation)

Inserts a relation into the variable.

Variables

distinct
bool distinct;

Should the variable be maintained distinctly.

forceFastPath
bool forceFastPath;

Used for testing purpose to ensure both paths produce the same result.

name
string name;

A useful name for the variable.

recent
Relation!TupleT recent;

A list of recent tuples, still to be processed.

stable
Relation!TupleT[] stable;

A list of relations whose union are the accepted tuples.

toAdd
Relation!TupleT[] toAdd;

A list of future tuples, to be introduced.

Inherited Members

From VariableTrait

changed
bool changed()

Reports whether the variable has changed since it was last asked.

Meta