From ded61da33973a7bfd2bccf638047be1d09b44e9a Mon Sep 17 00:00:00 2001 From: adranwit Date: Tue, 3 Dec 2024 15:44:46 -0800 Subject: [PATCH] update dep --- service/executor/service.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/service/executor/service.go b/service/executor/service.go index a8e7c458..11bef123 100644 --- a/service/executor/service.go +++ b/service/executor/service.go @@ -196,8 +196,6 @@ func (e *Executor) handleInsert(ctx context.Context, sess *dbSession, executable return err } - collection := sess.collection(executable) - collection.Append(executable.Data) if !executable.IsLast { return nil } @@ -208,16 +206,20 @@ func (e *Executor) handleInsert(ctx context.Context, sess *dbSession, executable return err } batchSize := 100 - if collection.Len() < batchSize { - batchSize = collection.Len() + rType := reflect.TypeOf(executable.Data) + if rType.Kind() == reflect.Slice { + actual := reflect.ValueOf(executable.Data) + if actual.Len() < batchSize { + batchSize = actual.Len() + } } - options = append(options, option.BatchSize(batchSize)) options = append(options, e.dbOptions(db, sess)) - _, _, err = service.Exec(ctx, collection.Unwrap(), options...) + _, _, err = service.Exec(ctx, executable.Data, options...) return err } + //TODO: !!!!!! :^^^^^^^^: aBatcher, err := batcherRegistry.GetBatcher(executable.Table, reflect.TypeOf(executable.Data), db, &batcher.Config{ MaxElements: 100, MaxDurationMs: 10, @@ -229,7 +231,7 @@ func (e *Executor) handleInsert(ctx context.Context, sess *dbSession, executable } //TODO: remove reflection - rSlice := reflect.ValueOf(collection.Unwrap()).Elem() + rSlice := reflect.ValueOf(executable.Data) sliceLen := rSlice.Len() var state *batcher.State for i := 0; i < sliceLen; i++ {