protected void buildInitialTable ( final MutableObjectIterator < BT > input ) throws IOException { // create the partitions final int partitionFanOut = getPartitioningFanOutNoEstimates ( this . availableMemory . size ( ) ) ; if ( partitionFanOut > MAX_NUM_PARTITIONS ) { throw new RuntimeException ( "Hash join partitions estimate exeeds maximum number of partitions." ) ; } createPartitions ( partitionFanOut , 0 ) ; // set up the table structure. the write behind buffers are taken away, as are one buffer per partition final int numBuckets = getInitialTableSize ( this . availableMemory . size ( ) , this . segmentSize , partitionFanOut , this . avgRecordLen ) ; initTable ( numBuckets , ( byte ) partitionFanOut ) ; final TypeComparator < BT > buildTypeComparator = this . buildSideComparator ; BT record = this . buildSideSerializer . createInstance ( ) ; // go over the complete input and insert every element into the hash table while ( this . running && ( ( record = input . next ( record ) ) != null ) ) { final int hashCode = hash ( buildTypeComparator . hash ( record ) , 0 ) ; insertIntoTable ( record , hashCode ) ; } if ( ! this . running ) { return ; } // finalize the partitions for ( int i = 0 ; i < this . partitionsBeingBuilt . size ( ) ; i ++ ) { HashPartition < BT , PT > p = this . partitionsBeingBuilt . get ( i ) ; p . finalizeBuildPhase ( this . ioManager , this . currentEnumerator , this . writeBehindBuffers ) ; } }
Creates the initial hash table . This method sets up partitions hash index and inserts the data from the given iterator .