private boolean findFirstSameBuildRow ( MemorySegment bucket , int searchHashCode , int bucketInSegmentOffset , BinaryRow buildRowToInsert ) { int posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH ; int countInBucket = bucket . getShort ( bucketInSegmentOffset + HEADER_COUNT_OFFSET ) ; int numInBucket = 0 ; RandomAccessInputView view = partition . getBuildStateInputView ( ) ; while ( countInBucket != 0 ) { while ( numInBucket < countInBucket ) { final int thisCode = bucket . getInt ( posInSegment ) ; posInSegment += HASH_CODE_LEN ; if ( thisCode == searchHashCode ) { final int pointer = bucket . getInt ( bucketInSegmentOffset + BUCKET_POINTER_START_OFFSET + ( numInBucket * POINTER_LEN ) ) ; numInBucket ++ ; try { view . setReadPosition ( pointer ) ; BinaryRow row = table . binaryBuildSideSerializer . mapFromPages ( table . reuseBuildRow , view ) ; if ( buildRowToInsert . equals ( row ) ) { return true ; } } catch ( IOException e ) { throw new RuntimeException ( "Error deserializing key or value from the hashtable: " + e . getMessage ( ) , e ) ; } } else { numInBucket ++ ; } } // this segment is done. check if there is another chained bucket final int forwardPointer = bucket . getInt ( bucketInSegmentOffset + HEADER_FORWARD_OFFSET ) ; if ( forwardPointer == BUCKET_FORWARD_POINTER_NOT_SET ) { return false ; } final int overflowSegIndex = forwardPointer >>> table . segmentSizeBits ; bucket = overflowSegments [ overflowSegIndex ] ; bucketInSegmentOffset = forwardPointer & table . segmentSizeMask ; countInBucket = bucket . getShort ( bucketInSegmentOffset + HEADER_COUNT_OFFSET ) ; posInSegment = bucketInSegmentOffset + BUCKET_HEADER_LENGTH ; numInBucket = 0 ; } return false ; }
For distinct build .