Which function do you want to add comments to?
AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go.
What comments do you want to add?
// AllocateBatch attempts to allocate a batch of unique random ports from the allocator's port range.
// The number of ports to allocate is specified by portNum.
// It returns a slice of allocated port numbers and an error if allocation fails.
// An error is returned when portNum exceeds the total size of the port range.
// This method is concurrency-safe as it acquires a lock before modifying the port allocation state.
// Note: The allocated ports are not persisted; they are only stored in the local map to avoid duplicates within the same batch.
Which function do you want to add comments to?
AllocateBatch in pkg/ddc/base/portallocator/random_allocator.go.
What comments do you want to add?
// AllocateBatch attempts to allocate a batch of unique random ports from the allocator's port range.
// The number of ports to allocate is specified by portNum.
// It returns a slice of allocated port numbers and an error if allocation fails.
// An error is returned when portNum exceeds the total size of the port range.
// This method is concurrency-safe as it acquires a lock before modifying the port allocation state.
// Note: The allocated ports are not persisted; they are only stored in the local map to avoid duplicates within the same batch.