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 @@ -22,7 +22,7 @@

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
import static java.util.Comparator.comparingLong;
import static java.util.Objects.requireNonNull;

Expand All @@ -41,8 +41,7 @@ public SplitAssignment(
this.planNodeId = requireNonNull(planNodeId, "planNodeId is null");
// Sort the splits to make sure that the order of scheduling splits is deterministic
this.splits = requireNonNull(splits, "splits is null").stream()
.sorted(comparingLong(ScheduledSplit::getSequenceId))
.collect(toImmutableSet());
.collect(toImmutableSortedSet(comparingLong(ScheduledSplit::getSequenceId)));
this.noMoreSplits = noMoreSplits;
}

Expand Down
38 changes: 1 addition & 37 deletions core/trino-spi/src/main/java/io/trino/spi/block/BlockUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,7 @@ static int calculateNewArraySize(int currentSize, int minimumSize)

static int calculateBlockResetSize(int currentSize)
{
long newSize = (long) ceil(currentSize * BLOCK_RESET_SKEW);

// verify new size is within reasonable bounds
if (newSize < DEFAULT_CAPACITY) {
newSize = DEFAULT_CAPACITY;
}
else if (newSize > MAX_ARRAY_SIZE) {
newSize = MAX_ARRAY_SIZE;
}
return (int) newSize;
return clamp((long) ceil(currentSize * BLOCK_RESET_SKEW), DEFAULT_CAPACITY, MAX_ARRAY_SIZE);
}

static int calculateBlockResetBytes(int currentBytes)
Expand Down Expand Up @@ -194,33 +185,6 @@ static long[] compactArray(long[] array, int index, int length)
return Arrays.copyOfRange(array, index, index + length);
}

static int countSelectedPositionsFromOffsets(boolean[] positions, int[] offsets, int offsetBase)
{
checkArrayRange(offsets, offsetBase, positions.length);
int used = 0;
for (int i = 0; i < positions.length; i++) {
int offsetStart = offsets[offsetBase + i];
int offsetEnd = offsets[offsetBase + i + 1];
used += ((positions[i] ? 1 : 0) * (offsetEnd - offsetStart));
}
return used;
}

static int countAndMarkSelectedPositionsFromOffsets(boolean[] positions, int[] offsets, int offsetBase, boolean[] elementPositions)
{
checkArrayRange(offsets, offsetBase, positions.length);
int used = 0;
for (int i = 0; i < positions.length; i++) {
int offsetStart = offsets[offsetBase + i];
int offsetEnd = offsets[offsetBase + i + 1];
if (positions[i]) {
used += (offsetEnd - offsetStart);
Arrays.fill(elementPositions, offsetStart, offsetEnd, true);
}
}
return used;
}

/**
* Returns <tt>true</tt> if the two specified arrays contain the same object in every position.
* Unlike the {@link Arrays#equals(Object[], Object[])} method, this method compares using reference equals.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ public boolean getBoolean(int field)
public long getLong(int field)
{
checkState(row != null, "No current row");
return getLong(getTpchColumn(field));
}

private long getLong(TpchColumn<E> tpchColumn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with the existing code here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was redundant

{
TpchColumn<E> tpchColumn = getTpchColumn(field);
if (tpchColumn.getType().getBase() == TpchColumnType.Base.DATE) {
return tpchColumn.getDate(row);
}
Expand All @@ -209,24 +205,14 @@ private long getLong(TpchColumn<E> tpchColumn)
public double getDouble(int field)
{
checkState(row != null, "No current row");
return getDouble(getTpchColumn(field));
}

private double getDouble(TpchColumn<E> tpchColumn)
{
return tpchColumn.getDouble(row);
return getTpchColumn(field).getDouble(row);
}

@Override
public Slice getSlice(int field)
{
checkState(row != null, "No current row");
return getSlice(getTpchColumn(field));
}

private Slice getSlice(TpchColumn<E> tpchColumn)
{
return Slices.utf8Slice(tpchColumn.getString(row));
return Slices.utf8Slice(getTpchColumn(field).getString(row));
}

@Override
Expand Down Expand Up @@ -275,13 +261,13 @@ private boolean rowMatchesPredicate()
private Object getTrinoObject(TpchColumn<E> column, Type type)
{
if (type.getJavaType() == long.class) {
return getLong(column);
return column.getInteger(row);
}
if (type.getJavaType() == double.class) {
return getDouble(column);
return column.getDouble(row);
}
if (type.getJavaType() == Slice.class) {
return getSlice(column);
return Slices.utf8Slice(column.getString(row));
}
throw new TrinoException(NOT_SUPPORTED, format("Unsupported column type %s", type.getDisplayName()));
}
Expand Down
Loading