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 @@ -483,15 +483,6 @@ private void finishInput()
return;
}

// reserve memory for the lookup source
long estimatedSizeAfterBuild = index.getEstimatedSize().toBytes() + PagesHash.getEstimatedAdditionalSize(index.getPositionCount());
if (spillEnabled) {
localRevocableMemoryContext.setBytes(estimatedSizeAfterBuild);
}
else {
localUserMemoryContext.setBytes(estimatedSizeAfterBuild);
}

LookupSourceSupplier partition = buildLookupSource();
if (spillEnabled) {
localRevocableMemoryContext.setBytes(partition.get().getInMemorySizeInBytes());
Expand Down Expand Up @@ -570,10 +561,6 @@ private void finishLookupSourceUnspilling()
localUserMemoryContext.setBytes(memoryRetainedByRemainingPages + index.getEstimatedSize().toBytes());
}

// reserve memory for the lookup source
long estimatedSizeAfterBuild = index.getEstimatedSize().toBytes() + PagesHash.getEstimatedAdditionalSize(index.getPositionCount());
localUserMemoryContext.setBytes(estimatedSizeAfterBuild);

LookupSourceSupplier partition = buildLookupSource();
lookupSourceChecksum.ifPresent(checksum ->
checkState(partition.checksum() == checksum, "Unspilled lookupSource checksum does not match original one"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import static com.facebook.presto.operator.SyntheticAddress.decodeSliceIndex;
import static com.facebook.presto.util.HashCollisionsEstimator.estimateNumberOfHashCollisions;
import static io.airlift.slice.SizeOf.sizeOf;
import static io.airlift.slice.SizeOf.sizeOfByteArray;
import static io.airlift.slice.SizeOf.sizeOfIntArray;
import static io.airlift.units.DataSize.Unit.KILOBYTE;
import static java.lang.Math.toIntExact;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -62,7 +60,7 @@ public PagesHash(
this.channelCount = pagesHashStrategy.getChannelCount();

// reserve memory for the arrays
int hashSize = getHashTableSize(addresses.size());
int hashSize = HashCommon.arraySize(addresses.size(), 0.75f);

mask = hashSize - 1;
key = new int[hashSize];
Expand Down Expand Up @@ -119,6 +117,7 @@ public PagesHash(
key[pos] = realPosition;
}
}

size = sizeOf(addresses.elements()) + pagesHashStrategy.getSizeInBytes() +
sizeOf(key) + sizeOf(positionToHashes);
hashCollisions = hashCollisionsLocal;
Expand Down Expand Up @@ -239,24 +238,4 @@ private static int getHashPosition(long rawHash, long mask)

return (int) (rawHash & mask);
}

/**
* @return Given a number of positions, how much more memory would a pagesHash use if we constructed it from a PagesIndex with this number of positions?
* Keep in mind that this is a *Delta*: The actual pagesHash would be larger than this -- add this number to the existing size of the PagesIndex
*/
public static long getEstimatedAdditionalSize(int positionCount)
{
int hashSize = getHashTableSize(positionCount);

long predictedKeySize = sizeOfIntArray(hashSize);
long predictedPositionToHashesSize = sizeOfByteArray(positionCount);
long predictedPositionLinksSize = sizeOfIntArray(positionCount);

return predictedKeySize + predictedPositionToHashesSize + predictedPositionLinksSize;
}

private static int getHashTableSize(int positionCount)
{
return HashCommon.arraySize(positionCount, 0.75f);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ public boolean filter(int leftPosition, Page leftPage, int rightPosition, Page r
}
}

public static class DummySpillerFactory
private static class DummySpillerFactory
implements SingleStreamSpillerFactory
{
private volatile boolean failSpill;
Expand Down