You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: hashtable_distinct.eg.go
    path of file: ./repos/cockroach/pkg/sql/colexec/colexechash
    
    the code of the file until where you have to start completion: // Code generated by execgen; DO NOT EDIT.
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package colexechash

import (
	"bytes"
	"math"

	"github.com/cockroachdb/cockroach/pkg/col/coldata"
	"github.com/cockroachdb/cockroach/pkg/col/coldataext"
	"github.com/cockroachdb/cockroach/pkg/col/typeconv"
	"github.com/cockroachdb/cockroach/pkg/sql/colexec/colexecutils"
	"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
	"github.com/
    
func (ht *HashTable) updateSel(b coldata.Batch) {
	if b.Length() == 0 {
		return
	}
	if sel := b.Selection(); sel != nil {
		batchLength := b.Length()
		// Capture the slices in order for BCE to occur.
		HeadIDs := ht.ProbeScratch.HeadID
		hashBuffer := ht.ProbeScratch.HashBuffer
		_ = HeadIDs[batchLength-1]
		_ = hashBuffer[batchLength-1]
		// Reuse the buffer allocated for foundNull.
		visited := ht.ProbeScratch.foundNull
		copy(visited, colexecutils.ZeroBoolColumn)
		distinctCount := 0
		for i := 0; i < batchLength && distinctCount < batchLength; i++ {
			//gcassert:bce
			HeadID := HeadIDs[i]
			if HeadID != 0 {
				if hasVisited := visited[HeadID-1]; !hasVisited {
					sel[distinctCount] = sel[HeadID-1]
					visited[HeadID-1] = true
					//gcassert:bce
					hashBuffer[distinctCount] = hashBuffer[i]
					distinctCount++
				}
			}
		}
		b.SetLength(distinctCount)
	} else {
		b.SetSelection(true)
		sel = b.Selection()
		batchLength := b.Length()
		// Capture the slices in order for BCE to occur.
		HeadIDs := ht.ProbeScratch.HeadID
		hashBuffer := ht.ProbeScratch.HashBuffer
		_ = HeadIDs[batchLength-1]
		_ = hashBuffer[batchLength-1]
		// Reuse the buffer allocated for foundNull.
		visited := ht.ProbeScratch.foundNull
		copy(visited, colexecutils.ZeroBoolColumn)
		distinctCount := 0
		for i := 0; i < batchLength && distinctCount < batchLength; i++ {
			//gcassert:bce
			HeadID := HeadIDs[i]
			if HeadID != 0 {
				if hasVisited := visited[HeadID-1]; !hasVisited {
					sel[distinctCount] = int(HeadID - 1)
					visited[HeadID-1] = true
					//gcassert:bce
					hashBuffer[distinctCount] = hashBuffer[i]
					distinctCount++
				}
			}
		}
		b.SetLength(distinctCount)
	}
}