Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import java.util.List;
import java.util.Objects;

public final class DBSPAggregateLinearPostprocessOperator extends DBSPUnaryOperator {
public final class DBSPAggregateLinearPostprocessOperator
extends DBSPUnaryOperator
implements ILinearAggregate {
public final DBSPClosureExpression postProcess;

// This operator is incremental-only
Expand All @@ -27,7 +29,7 @@ public DBSPAggregateLinearPostprocessOperator(
DBSPTypeIndexedZSet outputType,
DBSPExpression function,
DBSPClosureExpression postProcess, OutputPort input) {
super(node, "aggregate_linear_postprocess", function, outputType, false, input, true);
super(node, "aggregate_linear_postprocess", function, outputType, false, input);
this.postProcess = postProcess;
Utilities.enforce(outputType.elementType.sameType(postProcess.getResultType()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import java.util.List;
import java.util.Objects;

public final class DBSPAggregateLinearPostprocessRetainKeysOperator extends DBSPBinaryOperator {
public final class DBSPAggregateLinearPostprocessRetainKeysOperator
extends DBSPBinaryOperator
implements ILinearAggregate {
public final DBSPClosureExpression postProcess;
public final DBSPClosureExpression retainKeysFunction;

Expand All @@ -30,7 +32,7 @@ public DBSPAggregateLinearPostprocessRetainKeysOperator(
DBSPClosureExpression retainKeysFunction,
OutputPort left, OutputPort right) {
super(node, "aggregate_linear_postprocess_retain_keys",
function, outputType, false, left, right, true);
function, outputType, false, left, right);
this.postProcess = postProcess;
this.retainKeysFunction = retainKeysFunction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@
import javax.annotation.Nullable;
import java.util.List;

public final class DBSPAggregateOperator extends DBSPAggregateOperatorBase {
public final class DBSPAggregateOperator extends DBSPAggregateOperatorBase implements INonLinearAggregate {
public DBSPAggregateOperator(
CalciteRelNode node,
DBSPTypeIndexedZSet outputType,
@Nullable DBSPAggregator function,
@Nullable DBSPAggregateList aggregate, OutputPort input) {
super(node, "aggregate", outputType,
function, aggregate, false, input, true);
super(node, "aggregate", outputType, function, aggregate, false, input);
Utilities.enforce(input.getOutputIndexedZSetType().keyType.sameType(outputType.keyType));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import java.util.Objects;

/*** Base class for operators that perform some form of aggregation. */
public abstract class DBSPAggregateOperatorBase extends DBSPUnaryOperator {
public abstract class DBSPAggregateOperatorBase
extends DBSPUnaryOperator {
// Initially 'aggregateList' may be not null, and 'function' may be null.
// Later always aggregateList is null, and function is not null.
@Nullable
Expand All @@ -25,9 +26,8 @@ protected DBSPAggregateOperatorBase(CalciteRelNode node, String operation,
@Nullable DBSPAggregator function,
@Nullable DBSPAggregateList aggregateList,
boolean multiset,
OutputPort source,
boolean containsIntegrate) {
super(node, operation, function, outputType, multiset, source, containsIntegrate);
OutputPort source) {
super(node, operation, function, outputType, multiset, source);
this.aggregateList = aggregateList;
// There are really two different representations of an aggregate operator,
// which reuse the same classes: a high-level one, which contains an Aggregate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* |
*/
@NonCoreIR
public class DBSPAggregateZeroOperator extends DBSPUnaryOperator {
public class DBSPAggregateZeroOperator extends DBSPUnaryOperator implements ILinear {
/** Create an AggregateZero operator.
*
* @param node Calcite node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

/** Anti join operator: produces elements from the left stream that have no corresponding keys
* in the right stream. */
public final class DBSPAntiJoinOperator extends DBSPBinaryOperator {
public final class DBSPAntiJoinOperator extends DBSPBinaryOperator implements IJoin {
public DBSPAntiJoinOperator(CalciteRelNode node, OutputPort left, OutputPort right) {
super(node, "antijoin", null, left.outputType(), left.isMultiset(), left, right, true);
super(node, "antijoin", null, left.outputType(), left.isMultiset(), left, right);
// Inputs must be indexed
left.getOutputIndexedZSetType();
right.getOutputIndexedZSetType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* which applies an arbitrary function to its 2 inputs.
* The inputs and outputs cannot be Z-sets or indexed Z-sets.
* The comments from {@link DBSPApplyOperator} apply to this operator as well. */
public final class DBSPApply2Operator extends DBSPBinaryOperator {
public final class DBSPApply2Operator extends DBSPBinaryOperator implements ILinear {
public DBSPApply2Operator(CalciteRelNode node, DBSPClosureExpression function,
OutputPort left, OutputPort right) {
super(node, "apply2", function, function.getResultType(), false, left, right, false);
super(node, "apply2", function, function.getResultType(), false, left, right);
Utilities.enforce(function.parameters.length == 2,
() -> "Expected 2 parameters for function " + function);
DBSPType param0Type = function.parameters[0].getType().deref();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
* from a {@link DBSPWaterlineOperator}, which replicates its output to all workers.
* So it's never OK to have an apply operator process inputs from standard operators.
* In the type system such inputs would show up as ZSets or IndexedZSets. */
public final class DBSPApplyOperator extends DBSPUnaryOperator {
public final class DBSPApplyOperator extends DBSPUnaryOperator implements ILinear {
public static void noZsets(DBSPType type) {
Utilities.enforce(!type.is(DBSPTypeZSet.class));
Utilities.enforce(!type.is(DBSPTypeIndexedZSet.class));
}

public DBSPApplyOperator(CalciteRelNode node, DBSPClosureExpression function,
DBSPType outputType, OutputPort input, @Nullable String comment) {
super(node, "apply", function, outputType, false, input, comment, false);
super(node, "apply", function, outputType, false, input, comment);
Utilities.enforce(function.parameters.length == 1,
() -> "Expected 1 parameter for function " + function);
DBSPType paramType = function.parameters[0].getType().deref();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
public abstract class DBSPBinaryOperator extends DBSPSimpleOperator {
protected DBSPBinaryOperator(CalciteRelNode node, String operation,
@Nullable DBSPExpression function, DBSPType outputType,
boolean isMultiset, OutputPort left, OutputPort right,
boolean containsIntegrator) {
super(node, operation, function, outputType, isMultiset, containsIntegrator);
boolean isMultiset, OutputPort left, OutputPort right) {
super(node, operation, function, outputType, isMultiset);
this.addInput(left);
this.addInput(right);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

/** Corresponds to the DBSP chain_aggregate operator.
* Used to implement min and max for append-only collections with O(1) space and time. */
public class DBSPChainAggregateOperator extends DBSPUnaryOperator {
public class DBSPChainAggregateOperator extends DBSPUnaryOperator implements ILinearAggregate {
public final DBSPClosureExpression init;

public DBSPChainAggregateOperator(CalciteRelNode node, DBSPClosureExpression init,
DBSPClosureExpression function, DBSPType outputType, OutputPort source) {
super(node, "chain_aggregate", function, outputType, false, source, true);
super(node, "chain_aggregate", function, outputType, false, source);
this.init = init;
Utilities.enforce(init.parameters.length == 2);
Utilities.enforce(function.parameters.length == 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
/** A Chain operator performs a linear chain of Map/Filter/MapIndex operations.
* In the end it is lowered to a {@link DBSPFlatMapOperator} or
* {@link DBSPFlatMapIndexOperator} operator, depending on the last operation. */
public class DBSPChainOperator extends DBSPUnaryOperator {
public class DBSPChainOperator extends DBSPUnaryOperator implements ILinear {
public final ComputationChain chain;

public DBSPChainOperator(CalciteRelNode node, ComputationChain chain, boolean isMultiset, OutputPort source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class DBSPConstantOperator extends DBSPSimpleOperator {
public DBSPConstantOperator(CalciteRelNode node, DBSPExpression value, boolean isMultiset) {
// Notice that we use the 'this.function' field to represent
// the constant value. Constants are not ClosureExpressions.
super(node, "constant", value, value.getType(), isMultiset, false);
super(node, "constant", value, value.getType(), isMultiset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* the input element makes it to the output. The {@code error} function takes
* a scalar, and an element and returns an error message with the ERROR_SCHEMA structure.
* It is invoked only when the function returns 'false'. */
public final class DBSPControlledKeyFilterOperator extends DBSPOperatorWithError {
public final class DBSPControlledKeyFilterOperator extends DBSPOperatorWithError implements ILinear {
public DBSPControlledKeyFilterOperator(
CalciteRelNode node, DBSPClosureExpression function, DBSPClosureExpression error,
OutputPort data, OutputPort control) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/** The inverse of the map_index operator. This operator simply drops the index
* from an indexed z-set and keeps all the values. It can be implemented by
* a DBSP map operator, but it is worthwhile to have a separate operation. */
public final class DBSPDeindexOperator extends DBSPUnaryOperator {
public final class DBSPDeindexOperator extends DBSPUnaryOperator implements ILinear {
static DBSPType outputType(DBSPTypeIndexedZSet ix) {
return TypeCompiler.makeZSet(ix.elementType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/** The z^-1 operator from DBSP.
* If the function is specified, it is the initial value produced by the delay. */
public final class DBSPDelayOperator extends DBSPUnaryOperator {
public final class DBSPDelayOperator extends DBSPUnaryOperator implements IStateful {
public DBSPDelayOperator(CalciteRelNode node, @Nullable DBSPExpression initial, OutputPort source) {
super(node, initial == null ? "transaction_delay" : "transaction_delay_with_initial_value",
initial, source.outputType(), source.isMultiset(), source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* This shows up often, and it can be implemented more efficiently
* than using the pair. */
@NonCoreIR
public final class DBSPDelayedIntegralOperator extends DBSPUnaryOperator {
public final class DBSPDelayedIntegralOperator extends DBSPUnaryOperator implements IContainsIntegrator {
public DBSPDelayedIntegralOperator(CalciteRelNode node, OutputPort source) {
super(node, "accumulate_delay_trace", null, source.outputType(), source.isMultiset(), source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.List;

/** Represents a delta operator (called delta0 in DBSP) */
public class DBSPDeltaOperator extends DBSPUnaryOperator {
public class DBSPDeltaOperator extends DBSPUnaryOperator implements ILinear {
public DBSPDeltaOperator(CalciteRelNode node, OutputPort source) {
super(node, "delta0", null, source.outputType(), source.isMultiset(), source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import javax.annotation.Nullable;
import java.util.List;

public final class DBSPDifferentiateOperator extends DBSPUnaryOperator {
public final class DBSPDifferentiateOperator extends DBSPUnaryOperator implements IStateful {
public DBSPDifferentiateOperator(CalciteRelNode node, OutputPort source) {
super(node, "differentiate", null, source.outputType(), source.isMultiset(), source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import java.util.List;

@NonCoreIR
public final class DBSPDistinctIncrementalOperator extends DBSPBinaryOperator {
public final class DBSPDistinctIncrementalOperator extends DBSPBinaryOperator implements IContainsIntegrator {
public DBSPDistinctIncrementalOperator(CalciteRelNode node, OutputPort integral, OutputPort delta) {
super(node, "distinct_incremental", null, delta.outputType(), false, integral, delta, false);
super(node, "distinct_incremental", null, delta.outputType(), false, integral, delta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import javax.annotation.Nullable;
import java.util.List;

public final class DBSPDistinctOperator extends DBSPUnaryOperator {
public final class DBSPDistinctOperator extends DBSPUnaryOperator implements IContainsIntegrator {
public DBSPDistinctOperator(CalciteRelNode node, OutputPort input) {
super(node, "distinct", null, input.outputType(), false, input, true);
super(node, "distinct", null, input.outputType(), false, input);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.List;
import java.util.Objects;

public final class DBSPFilterOperator extends DBSPUnaryOperator {
public final class DBSPFilterOperator extends DBSPUnaryOperator implements ILinear {
public DBSPFilterOperator(CalciteRelNode node, DBSPExpression condition, OutputPort input) {
super(node, "filter", condition, input.outputType(), input.isMultiset(), input);
this.checkResultType(condition, new DBSPTypeBool(CalciteEmptyRel.INSTANCE, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.List;
import java.util.Objects;

public final class DBSPFlatMapIndexOperator extends DBSPUnaryOperator {
public final class DBSPFlatMapIndexOperator extends DBSPUnaryOperator implements ILinear {
public DBSPFlatMapIndexOperator(CalciteRelNode node, DBSPExpression expression,
DBSPTypeIndexedZSet outputType, boolean isMultiset,
OutputPort input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.List;
import java.util.Objects;

public final class DBSPFlatMapOperator extends DBSPUnaryOperator {
public final class DBSPFlatMapOperator extends DBSPUnaryOperator implements ILinear {
public DBSPFlatMapOperator(CalciteRelNode node, DBSPExpression expression,
DBSPTypeZSet outputType, boolean isMultiset, OutputPort input) {
super(node, "flat_map", expression, outputType, isMultiset, input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* operators: map (computing the hop start window) followed by flat_map
* (which generates all the windows). It does not correspond to any DBSP
* Rust operator. */
public final class DBSPHopOperator extends DBSPUnaryOperator {
public final class DBSPHopOperator extends DBSPUnaryOperator implements ILinear {
public final int timestampIndex;
public final DBSPExpression interval;
public final DBSPExpression start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/** Apply a topK operation to each of the groups in an indexed collection.
* This always sorts the elements of each group.
* To sort the entire collection just group by (). */
public final class DBSPIndexedTopKOperator extends DBSPUnaryOperator {
public final class DBSPIndexedTopKOperator extends DBSPUnaryOperator implements IContainsIntegrator {
/** These values correspond to the SQL keywords
* ROW, RANK, and DENSE RANK. See e.g.:
* https://learn.microsoft.com/en-us/sql/t-sql/functions/ranking-functions-transact-sql
Expand Down Expand Up @@ -75,7 +75,7 @@ public DBSPIndexedTopKOperator(CalciteRelNode node, TopKNumbering numbering,
DBSPEqualityComparatorExpression equalityComparator,
DBSPClosureExpression outputProducer, OutputPort source) {
super(node, "topK", comparator,
outputType(source.getOutputIndexedZSetType(), outputProducer), source.isMultiset(), source, true);
outputType(source.getOutputIndexedZSetType(), outputProducer), source.isMultiset(), source);
Utilities.enforce(comparator.is(DBSPComparatorExpression.class) ||
comparator.is(DBSPPathExpression.class));
this.limit = limit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.dbsp.sqlCompiler.circuit.operator;

import com.fasterxml.jackson.databind.JsonNode;
import org.dbsp.sqlCompiler.circuit.IInputMapOperator;
import org.dbsp.sqlCompiler.circuit.IMultiOutput;
import org.dbsp.sqlCompiler.circuit.OutputPort;
import org.dbsp.sqlCompiler.compiler.TableMetadata;
import org.dbsp.sqlCompiler.compiler.backend.JsonDecoder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import javax.annotation.Nullable;
import java.util.List;

public final class DBSPIntegrateOperator extends DBSPUnaryOperator {
public final class DBSPIntegrateOperator extends DBSPUnaryOperator implements IContainsIntegrator {
public DBSPIntegrateOperator(CalciteRelNode node, OutputPort source) {
super(node, "integrate", null, source.outputType(), source.isMultiset(), source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import java.util.Objects;

public final class DBSPIntegrateTraceRetainKeysOperator
extends DBSPBinaryOperator implements GCOperator
extends DBSPBinaryOperator implements IGCOperator
{
public DBSPIntegrateTraceRetainKeysOperator(
CalciteRelNode node, DBSPExpression expression,
OutputPort data, OutputPort control) {
super(node, "accumulate_integrate_trace_retain_keys", expression,
data.outputType(), data.isMultiset(), data, control, false);
data.outputType(), data.isMultiset(), data, control);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* - bottom_n
* Used to GC the right input of ASOF JOIN operators, Min, Max, ArgMin, ArgMax, MinSome, TopK. */
public final class DBSPIntegrateTraceRetainNValuesOperator
extends DBSPBinaryOperator implements GCOperator {
extends DBSPBinaryOperator implements IGCOperator {
public enum WhichN {
LastN("last_n"),
TopN("top_n"),
Expand All @@ -51,7 +51,7 @@ public DBSPIntegrateTraceRetainNValuesOperator(
CalciteRelNode node, DBSPExpression function,
OutputPort data, OutputPort control, int n, WhichN which) {
super(node, "accumulate_integrate_trace_retain_values_" + which.which,
function, data.outputType(), data.isMultiset(), data, control, false);
function, data.outputType(), data.isMultiset(), data, control);
Utilities.enforce(n > 0);
this.n = n;
this.which = which;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

/** Currently always inserted after the input of a join operator */
public final class DBSPIntegrateTraceRetainValuesOperator
extends DBSPBinaryOperator implements GCOperator {
extends DBSPBinaryOperator implements IGCOperator {

public final boolean accumulate;

public DBSPIntegrateTraceRetainValuesOperator(
CalciteRelNode node, DBSPExpression function,
OutputPort data, OutputPort control, boolean accumulate) {
super(node, accumulate ? "accumulate_integrate_trace_retain_values" : "integrate_trace_retain_values",
function, data.outputType(), data.isMultiset(), data, control, false);
function, data.outputType(), data.isMultiset(), data, control);
this.accumulate = accumulate;
}

Expand Down
Loading