Interface HashTable
- All Known Implementing Classes:
- HashTableTemplate
public interface HashTable
- 
Nested Class SummaryNested Classes
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intstatic final intThe batch size used for internal batch holdersstatic final floatThe default load factor of a hash table.static final intThe maximum capacity of the hash table (in terms of number of buckets).static final TemplateClassDefinition<HashTable> 
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Frees all the direct memory consumed by theHashTable.voiddecreaseRecordNumForKey(int currentIndex) Decrease the count of records for a specific key by one.longThe amount of direct memory consumed by the hash table.intgetBuildHashCode(int incomingRowIdx) Computes the hash code for the record at the given index in the build side batch.intgetProbeHashCode(int incomingRowIdx) Computes the hash code for the record at the given index in the probe side batch.intgetRecordNumForKey(int currentIndex) voidgetStats(HashTableStats stats) intbooleanisEmpty()Returns a message containing memory usage statistics.org.apache.commons.lang3.tuple.Pair<VectorContainer, Integer> booleanoutputKeys(int batchIdx, VectorContainer outContainer, int numRecords) Retrieves the key columns and transfers them to the output container.intprobeForKey(int incomingRowIdx, int hashCode) put(int incomingRowIdx, IndexPointer htIdxHolder, int hashCode, int batchSize) voidreset()Clears all the memory used by theHashTableand re-initializes it.voidsetRecordNumForKey(int currentIndex, int num) Set the count of records for a specific key to num.voidsetTargetBatchRowCount(int batchRowCount) voidsetup(HashTableConfig htConfig, BufferAllocator allocator, VectorContainer incomingBuild, RecordBatch incomingProbe, RecordBatch outgoing, VectorContainer htContainerOrig, FragmentContext context, ClassGenerator<?> cg) setup(org.apache.drill.exec.physical.impl.common.HashTableConfig, org.apache.drill.exec.memory.BufferAllocator, org.apache.drill.exec.record.VectorContainer, org.apache.drill.exec.record.RecordBatch, org.apache.drill.exec.record.RecordBatch, org.apache.drill.exec.record.VectorContainer, org.apache.drill.exec.ops.FragmentContext, org.apache.drill.exec.expr.ClassGenerator<?>)must be called before anything can be done to theHashTable.intsize()voidUpdates the incoming (build and probe side) value vectors references in theHashTableTemplate.BatchHolders.voidupdateIncoming(VectorContainer newIncoming, RecordBatch newIncomingProbe) Changes the incoming probe and build side batches, and then updates all the value vector references in theHashTableTemplate.BatchHolders.voidupdateInitialCapacity(int initialCapacity) Update the initial capacity for the hash table.
- 
Field Details- 
TEMPLATE_DEFINITION
- 
MAXIMUM_CAPACITYstatic final int MAXIMUM_CAPACITYThe maximum capacity of the hash table (in terms of number of buckets).- See Also:
 
- 
DEFAULT_LOAD_FACTORstatic final float DEFAULT_LOAD_FACTORThe default load factor of a hash table.- See Also:
 
- 
BATCH_SIZEstatic final int BATCH_SIZEThe batch size used for internal batch holders- See Also:
 
- 
BATCH_MASKstatic final int BATCH_MASK- See Also:
 
 
- 
- 
Method Details- 
setupvoid setup(HashTableConfig htConfig, BufferAllocator allocator, VectorContainer incomingBuild, RecordBatch incomingProbe, RecordBatch outgoing, VectorContainer htContainerOrig, FragmentContext context, ClassGenerator<?> cg) setup(org.apache.drill.exec.physical.impl.common.HashTableConfig, org.apache.drill.exec.memory.BufferAllocator, org.apache.drill.exec.record.VectorContainer, org.apache.drill.exec.record.RecordBatch, org.apache.drill.exec.record.RecordBatch, org.apache.drill.exec.record.VectorContainer, org.apache.drill.exec.ops.FragmentContext, org.apache.drill.exec.expr.ClassGenerator<?>)must be called before anything can be done to theHashTable.- Parameters:
- htConfig-
- allocator-
- incomingBuild-
- incomingProbe-
- outgoing-
- htContainerOrig-
- context-
- cg-
 
- 
updateBatchesUpdates the incoming (build and probe side) value vectors references in theHashTableTemplate.BatchHolders. This is useful on OK_NEW_SCHEMA (need to verify).- Throws:
- SchemaChangeException
 
- 
getBuildHashCodeComputes the hash code for the record at the given index in the build side batch.- Parameters:
- incomingRowIdx- The index of the build side record of interest.
- Returns:
- The hash code for the record at the given index in the build side batch.
- Throws:
- SchemaChangeException
 
- 
getProbeHashCodeComputes the hash code for the record at the given index in the probe side batch.- Parameters:
- incomingRowIdx- The index of the probe side record of interest.
- Returns:
- The hash code for the record at the given index in the probe side batch.
- Throws:
- SchemaChangeException
 
- 
putHashTable.PutStatus put(int incomingRowIdx, IndexPointer htIdxHolder, int hashCode, int batchSize) throws SchemaChangeException, RetryAfterSpillException 
- 
probeForKey- Parameters:
- incomingRowIdx- The index of the key in the probe batch.
- hashCode- The hashCode of the key.
- Returns:
- Returns -1 if the data in the probe batch at the given incomingRowIdx is not in the hash table. Otherwise returns the composite index of the key in the hash table (index of BatchHolder and record in Batch Holder).
- Throws:
- SchemaChangeException
 
- 
getRecordNumForKeyint getRecordNumForKey(int currentIndex) - Parameters:
- currentIndex- The composite index of the key in the hash table (index of BatchHolder and record in Batch Holder).
- Returns:
- Returns -1 if the count of records for a specific key is not computed. Otherwise returns the count of records for a specific key.
 
- 
setRecordNumForKeyvoid setRecordNumForKey(int currentIndex, int num) Set the count of records for a specific key to num.- Parameters:
- currentIndex- The composite index of the key in the hash table (index of BatchHolder and record in Batch Holder).
- num- The count of records for a specific key to be set.
 
- 
decreaseRecordNumForKeyvoid decreaseRecordNumForKey(int currentIndex) Decrease the count of records for a specific key by one.- Parameters:
- currentIndex- The composite index of the key in the hash table (index of BatchHolder and record in Batch Holder).
 
- 
getStats
- 
sizeint size()
- 
isEmptyboolean isEmpty()
- 
clearvoid clear()Frees all the direct memory consumed by theHashTable.
- 
updateInitialCapacityvoid updateInitialCapacity(int initialCapacity) Update the initial capacity for the hash table. This method will be removed after the key vectors are removed from the hash table. It is used to allocateHashTableTemplate.BatchHolders of appropriate size when the final size of the HashTable is known. Warning! Only call this method before you have inserted elements into the HashTable.- Parameters:
- initialCapacity- The new initial capacity to use.
 
- 
updateIncomingChanges the incoming probe and build side batches, and then updates all the value vector references in theHashTableTemplate.BatchHolders.- Parameters:
- newIncoming- The new build side batch.
- newIncomingProbe- The new probe side batch.
 
- 
resetvoid reset()Clears all the memory used by theHashTableand re-initializes it.
- 
outputKeysRetrieves the key columns and transfers them to the output container. Note this operation removes the key columns from theHashTable.- Parameters:
- batchIdx- The index of a- HashTableTemplate.BatchHolderin the HashTable.
- outContainer- The destination container for the key columns.
- numRecords- The number of key recorts to transfer.
- Returns:
 
- 
makeDebugStringString makeDebugString()Returns a message containing memory usage statistics. Intended to be used for printing debugging or error messages.- Returns:
- A debug string.
 
- 
getActualSizelong getActualSize()The amount of direct memory consumed by the hash table.- Returns:
 
- 
setTargetBatchRowCountvoid setTargetBatchRowCount(int batchRowCount) 
- 
getTargetBatchRowCountint getTargetBatchRowCount()
- 
nextBatchorg.apache.commons.lang3.tuple.Pair<VectorContainer,Integer> nextBatch()
 
-