use of org.apache.drill.exec.physical.impl.common.HashPartition in project drill by apache.
the class HashJoinBatch method initializeBuild.
/**
* Initialize fields (that may be reused when reading spilled partitions)
*/
private void initializeBuild() {
// in case we process
baseHashTable.updateIncoming(buildBatch, probeBatch);
// Recreate the partitions every time build is initialized
for (int part = 0; part < numPartitions; part++) {
partitions[part] = new HashPartition(context, allocator, baseHashTable, buildBatch, probeBatch, semiJoin, RECORDS_PER_BATCH, spillSet, part, spilledState.getCycle(), numPartitions);
}
spilledInners = new HashJoinSpilledPartition[numPartitions];
}
use of org.apache.drill.exec.physical.impl.common.HashPartition in project drill by apache.
the class HashJoinProbeTemplate method setupHashJoinProbe.
/**
* Setup the Hash Join Probe object
*
* @param probeBatch
* @param outgoing
* @param joinRelType
* @param semiJoin
* @param leftStartState
* @param partitions
* @param cycleNum
* @param container
* @param spilledInners
* @param buildSideIsEmpty
* @param numPartitions
* @param rightHVColPosition
*/
@Override
public void setupHashJoinProbe(RecordBatch probeBatch, HashJoinBatch outgoing, JoinRelType joinRelType, boolean semiJoin, IterOutcome leftStartState, HashPartition[] partitions, int cycleNum, VectorContainer container, HashJoinBatch.HashJoinSpilledPartition[] spilledInners, boolean buildSideIsEmpty, int numPartitions, int rightHVColPosition) {
this.container = container;
this.spilledInners = spilledInners;
this.probeBatch = probeBatch;
this.probeSchema = probeBatch.getSchema();
this.joinType = joinRelType;
this.outgoingJoinBatch = outgoing;
this.partitions = partitions;
this.cycleNum = cycleNum;
this.buildSideIsEmpty = buildSideIsEmpty;
this.numPartitions = numPartitions;
// position (0 based) of added column == #columns
this.numberOfBuildSideColumns = semiJoin ? 0 : rightHVColPosition;
this.semiJoin = semiJoin;
// e.g. 32 --> 0x1F
partitionMask = numPartitions - 1;
// e.g. 0x1F -> 5
bitsInMask = Integer.bitCount(partitionMask);
joinControl = new JoinControl(outgoingJoinBatch.getPopConfig().getJoinControl());
probeState = ProbeState.PROBE_PROJECT;
this.recordsToProcess = 0;
this.recordsProcessed = 0;
// A special case - if the left was an empty file
if (leftStartState == IterOutcome.NONE) {
changeToFinalProbeState();
} else {
this.recordsToProcess = probeBatch.getRecordCount();
}
// initialize those partitions' current batches and hash-value vectors
for (HashPartition partn : this.partitions) {
partn.allocateNewCurrentBatchAndHV();
}
// In case it's a Right/Full outer join
currRightPartition = 0;
// Initialize the HV vector for the first (already read) left batch
if (this.cycleNum > 0) {
if (read_left_HV_vector != null) {
read_left_HV_vector.clear();
}
if (leftStartState != IterOutcome.NONE) {
// Skip when outer spill was empty
read_left_HV_vector = (IntVector) probeBatch.getContainer().getLast();
}
}
}
Aggregations