Skip to content

Commit

Permalink
update dep
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Dec 3, 2024
1 parent 771f481 commit ded61da
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions service/executor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand All @@ -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++ {
Expand Down

0 comments on commit ded61da

Please sign in to comment.