From ad813d1d0dd06daeb8c8b9aa959d4097c37ceee5 Mon Sep 17 00:00:00 2001 From: Nathan <148575555+nathan-artie@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:15:46 -0700 Subject: [PATCH] Make `batch` generic --- clients/bigquery/batch.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clients/bigquery/batch.go b/clients/bigquery/batch.go index 1f151b87d..14967167e 100644 --- a/clients/bigquery/batch.go +++ b/clients/bigquery/batch.go @@ -1,23 +1,23 @@ package bigquery -type Batch struct { - rows []*Row +type Batch[T any] struct { + rows []T chunkSize int iteratorIdx int } -func NewBatch(rows []*Row, chunkSize int) *Batch { - return &Batch{ +func NewBatch[T any](rows []T, chunkSize int) *Batch[T] { + return &Batch[T]{ rows: rows, chunkSize: chunkSize, } } -func (b *Batch) HasNext() bool { +func (b *Batch[T]) HasNext() bool { return len(b.rows) > b.iteratorIdx } -func (b *Batch) NextChunk() []*Row { +func (b *Batch[T]) NextChunk() []T { start := b.iteratorIdx b.iteratorIdx += b.chunkSize end := b.iteratorIdx