Skip to content

Commit

Permalink
Merge branch 'deephaven:main' into docs-ci-condition-on-latest-link
Browse files Browse the repository at this point in the history
  • Loading branch information
stanbrub authored Jun 25, 2024
2 parents 5fbc8a1 + f647f1a commit 1776921
Show file tree
Hide file tree
Showing 30 changed files with 1,360 additions and 427 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ public OUTPUT_TYPE get() {
}
return cachedResult;
}

public OUTPUT_TYPE getIfCached() {
if (hasCachedResult) { // force a volatile read
if (errorResult != null) {
throw errorResult;
}
return cachedResult;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ private PreAndPostFilters applyFilterRenamings(WhereFilter[] filters) {
} else if (filter instanceof MatchFilter) {
final MatchFilter matchFilter = (MatchFilter) filter;
Assert.assertion(myRenames.size() == 1, "Match Filters should only use one column!");
String newName = myRenames.get(matchFilter.getColumnName());
Assert.neqNull(newName, "newName");
final MatchFilter newFilter = matchFilter.renameFilter(newName);
final WhereFilter newFilter = matchFilter.renameFilter(myRenames);
newFilter.init(tableReference.getDefinition(), compilationProcessor);
preViewFilters.add(newFilter);
} else if (filter instanceof ConditionFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.deephaven.chunk.attributes.Values;
import io.deephaven.chunk.*;
import io.deephaven.util.mutable.MutableInt;
import io.deephaven.util.mutable.MutableLong;

import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -46,12 +47,12 @@ public void addChunk(BucketedContext bucketedContext, Chunk<? extends Values> va
IntChunk<ChunkPositions> startPositions, IntChunk<ChunkLengths> length,
WritableBooleanChunk<Values> stateModified) {
final Context context = (Context) bucketedContext;
final LongChunk<? extends Values> doubleValues = context.toLongCast.apply(values);
final LongChunk<? extends Values> longValues = context.toLongCast.apply(values);
final LongChunk<? extends Values> weightValues = weightOperator.getAddedWeights();
Assert.neqNull(weightValues, "weightValues");
for (int ii = 0; ii < startPositions.size(); ++ii) {
final int startPosition = startPositions.get(ii);
stateModified.set(ii, addChunk(doubleValues, weightValues, startPosition, length.get(ii),
stateModified.set(ii, addChunk(longValues, weightValues, startPosition, length.get(ii),
destinations.get(startPosition)));
}
}
Expand All @@ -62,12 +63,12 @@ public void removeChunk(BucketedContext bucketedContext, Chunk<? extends Values>
IntChunk<ChunkPositions> startPositions, IntChunk<ChunkLengths> length,
WritableBooleanChunk<Values> stateModified) {
final Context context = (Context) bucketedContext;
final LongChunk<? extends Values> doubleValues = context.prevToLongCast.apply(values);
final LongChunk<? extends Values> longValues = context.prevToLongCast.apply(values);
final LongChunk<? extends Values> weightValues = weightOperator.getRemovedWeights();
Assert.neqNull(weightValues, "weightValues");
for (int ii = 0; ii < startPositions.size(); ++ii) {
final int startPosition = startPositions.get(ii);
stateModified.set(ii, removeChunk(doubleValues, weightValues, startPosition, length.get(ii),
stateModified.set(ii, removeChunk(longValues, weightValues, startPosition, length.get(ii),
destinations.get(startPosition)));
}
}
Expand All @@ -93,18 +94,18 @@ public void modifyChunk(BucketedContext bucketedContext, Chunk<? extends Values>
public boolean addChunk(SingletonContext singletonContext, int chunkSize, Chunk<? extends Values> values,
LongChunk<? extends RowKeys> inputRowKeys, long destination) {
final Context context = (Context) singletonContext;
final LongChunk<? extends Values> doubleValues = context.toLongCast.apply(values);
final LongChunk<? extends Values> longValues = context.toLongCast.apply(values);
final LongChunk<? extends Values> weightValues = weightOperator.getAddedWeights();
return addChunk(doubleValues, weightValues, 0, values.size(), destination);
return addChunk(longValues, weightValues, 0, values.size(), destination);
}

@Override
public boolean removeChunk(SingletonContext singletonContext, int chunkSize, Chunk<? extends Values> values,
LongChunk<? extends RowKeys> inputRowKeys, long destination) {
final Context context = (Context) singletonContext;
final LongChunk<? extends Values> doubleValues = context.prevToLongCast.apply(values);
final LongChunk<? extends Values> longValues = context.prevToLongCast.apply(values);
final LongChunk<? extends Values> weightValues = weightOperator.getRemovedWeights();
return removeChunk(doubleValues, weightValues, 0, values.size(), destination);
return removeChunk(longValues, weightValues, 0, values.size(), destination);
}

@Override
Expand All @@ -121,19 +122,19 @@ public boolean modifyChunk(SingletonContext singletonContext, int chunkSize, Chu
newDoubleValues.size(), destination);
}

private static void sumChunks(LongChunk<? extends Values> doubleValues, LongChunk<? extends Values> weightValues,
private static void sumChunks(LongChunk<? extends Values> longValues, LongChunk<? extends Values> weightValues,
int start,
int length,
MutableInt normalOut,
MutableInt weightedSumOut) {
MutableLong weightedSumOut) {
int normal = 0;
int weightedSum = 0;
long weightedSum = 0;

for (int ii = 0; ii < length; ++ii) {
final double weight = weightValues.get(start + ii);
final double component = doubleValues.get(start + ii);
final long weight = weightValues.get(start + ii);
final long component = longValues.get(start + ii);

if (weight == QueryConstants.NULL_DOUBLE || component == QueryConstants.NULL_DOUBLE) {
if (weight == QueryConstants.NULL_LONG || component == QueryConstants.NULL_LONG) {
continue;
}

Expand All @@ -148,12 +149,12 @@ private static void sumChunks(LongChunk<? extends Values> doubleValues, LongChun
private boolean addChunk(LongChunk<? extends Values> longValues, LongChunk<? extends Values> weightValues,
int start, int length, long destination) {
final MutableInt normalOut = new MutableInt();
final MutableInt weightedSumOut = new MutableInt();
final MutableLong weightedSumOut = new MutableLong();

sumChunks(longValues, weightValues, start, length, normalOut, weightedSumOut);

final int newNormal = normalOut.get();
final int newWeightedSum = weightedSumOut.get();
final long newWeightedSum = weightedSumOut.get();

final long totalNormal;
final long existingNormal = normalCount.getUnsafe(destination);
Expand All @@ -171,21 +172,21 @@ private boolean addChunk(LongChunk<? extends Values> longValues, LongChunk<? ext
weightedSum.set(destination, totalWeightedSum);
}

final double existingResult = resultColumn.getAndSetUnsafe(destination, totalWeightedSum);
final long existingResult = resultColumn.getAndSetUnsafe(destination, totalWeightedSum);
return totalWeightedSum != existingResult;
}
return false;
}

private boolean removeChunk(LongChunk<? extends Values> doubleValues, LongChunk<? extends Values> weightValues,
private boolean removeChunk(LongChunk<? extends Values> longValues, LongChunk<? extends Values> weightValues,
int start, int length, long destination) {
final MutableInt normalOut = new MutableInt();
final MutableInt weightedSumOut = new MutableInt();
final MutableLong weightedSumOut = new MutableLong();

sumChunks(doubleValues, weightValues, start, length, normalOut, weightedSumOut);
sumChunks(longValues, weightValues, start, length, normalOut, weightedSumOut);

final int newNormal = normalOut.get();
final int newWeightedSum = weightedSumOut.get();
final long newWeightedSum = weightedSumOut.get();

final long totalNormal;
final long existingNormal = normalCount.getUnsafe(destination);
Expand Down Expand Up @@ -226,17 +227,17 @@ private boolean modifyChunk(LongChunk<? extends Values> prevDoubleValues,
LongChunk<? extends Values> prevWeightValues, LongChunk<? extends Values> newDoubleValues,
LongChunk<? extends Values> newWeightValues, int start, int length, long destination) {
final MutableInt normalOut = new MutableInt();
final MutableInt weightedSumOut = new MutableInt();
final MutableLong weightedSumOut = new MutableLong();

sumChunks(prevDoubleValues, prevWeightValues, start, length, normalOut, weightedSumOut);

final int prevNormal = normalOut.get();
final int prevWeightedSum = weightedSumOut.get();
final long prevWeightedSum = weightedSumOut.get();

sumChunks(newDoubleValues, newWeightValues, start, length, normalOut, weightedSumOut);

final int newNormal = normalOut.get();
final int newWeightedSum = weightedSumOut.get();
final long newWeightedSum = weightedSumOut.get();

final long totalNormal;
final long existingNormal = normalCount.getUnsafe(destination);
Expand All @@ -255,12 +256,12 @@ private boolean modifyChunk(LongChunk<? extends Values> prevDoubleValues,
weightedSum.set(destination, totalWeightedSum);
}

final double existingResult = resultColumn.getAndSetUnsafe(destination, totalWeightedSum);
final long existingResult = resultColumn.getAndSetUnsafe(destination, totalWeightedSum);
return totalWeightedSum != existingResult;
} else {
if (prevNormal > 0) {
weightedSum.set(destination, 0L);
resultColumn.set(destination, QueryConstants.NULL_DOUBLE);
resultColumn.set(destination, QueryConstants.NULL_LONG);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public ByteRangeFilter(String columnName, byte val1, byte val2, boolean lowerInc
}
}

static WhereFilter makeByteRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeByteRangeFilter(String columnName, Condition condition, byte value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseByteFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseByteFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseByteFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseByteFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ public CharRangeFilter(String columnName, char val1, char val2, boolean lowerInc
}
}

static WhereFilter makeCharRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeCharRangeFilter(String columnName, Condition condition, char value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseCharFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseCharFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseCharFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseCharFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ public static WhereFilter makeRange(String columnName, String val) {
(double) (positiveOrZero ? parsed + offset : parsed - offset), positiveOrZero, !positiveOrZero);
}

static WhereFilter makeDoubleRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeDoubleRangeFilter(String columnName, Condition condition, double value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, Double.parseDouble(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, Double.parseDouble(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, Double.parseDouble(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, Double.parseDouble(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ public static WhereFilter makeRange(String columnName, String val) {
(float) (positiveOrZero ? parsed + offset : parsed - offset), positiveOrZero, !positiveOrZero);
}

static WhereFilter makeFloatRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeFloatRangeFilter(String columnName, Condition condition, float value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, Float.parseFloat(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, Float.parseFloat(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, Float.parseFloat(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, Float.parseFloat(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public IntRangeFilter(String columnName, int val1, int val2, boolean lowerInclus
}
}

static WhereFilter makeIntRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeIntRangeFilter(String columnName, Condition condition, int value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseIntFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseIntFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseIntFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseIntFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public LongRangeFilter(String columnName, long val1, long val2, boolean lowerInc
}
}

static WhereFilter makeLongRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeLongRangeFilter(String columnName, Condition condition, long value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseLongFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseLongFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseLongFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseLongFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Loading

0 comments on commit 1776921

Please sign in to comment.