Skip to content

Commit

Permalink
Accept ExecutionTuple in SegmentedIndex constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Jun 21, 2021
1 parent b528304 commit 01a82de
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
5 changes: 3 additions & 2 deletions lib/execution_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,9 @@ type SegmentedIndex struct ***REMOVED***
***REMOVED***

// NewSegmentedIndex returns a pointer to a new SegmentedIndex instance,
// given a starting index, LCD and offsets as returned by GetStripedOffsets().
func NewSegmentedIndex(start, lcd int64, offsets []int64) *SegmentedIndex ***REMOVED***
// given an ExecutionTuple.
func NewSegmentedIndex(et *ExecutionTuple) *SegmentedIndex ***REMOVED***
start, offsets, lcd := et.GetStripedOffsets()
return &SegmentedIndex***REMOVED***start: start, lcd: lcd, offsets: offsets***REMOVED***
***REMOVED***

Expand Down
3 changes: 1 addition & 2 deletions lib/executor/base_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ type BaseExecutor struct ***REMOVED***

// NewBaseExecutor returns an initialized BaseExecutor
func NewBaseExecutor(config lib.ExecutorConfig, es *lib.ExecutionState, logger *logrus.Entry) *BaseExecutor ***REMOVED***
start, offsets, lcd := es.ExecutionTuple.GetStripedOffsets()
segIdx := lib.NewSegmentedIndex(start, lcd, offsets)
segIdx := lib.NewSegmentedIndex(es.ExecutionTuple)
return &BaseExecutor***REMOVED***
config: config,
executionState: es,
Expand Down
3 changes: 1 addition & 2 deletions lib/executor/constant_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ func (car *ConstantArrivalRate) Init(ctx context.Context) error ***REMOVED***
// with no work, as determined by their config's HasWork() method.
et, err := car.BaseExecutor.executionState.ExecutionTuple.GetNewExecutionTupleFromValue(car.config.MaxVUs.Int64)
car.et = et
start, offsets, lcd := et.GetStripedOffsets()
car.iterSegIndex = lib.NewSegmentedIndex(start, lcd, offsets)
car.iterSegIndex = lib.NewSegmentedIndex(et)

return err
***REMOVED***
Expand Down
3 changes: 1 addition & 2 deletions lib/executor/ramping_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ func (varr *RampingArrivalRate) Init(ctx context.Context) error ***REMOVED***
// with no work, as determined by their config's HasWork() method.
et, err := varr.BaseExecutor.executionState.ExecutionTuple.GetNewExecutionTupleFromValue(varr.config.MaxVUs.Int64)
varr.et = et
start, offsets, lcd := et.GetStripedOffsets()
varr.iterSegIndex = lib.NewSegmentedIndex(start, lcd, offsets)
varr.iterSegIndex = lib.NewSegmentedIndex(et)

return err //nolint: wrapcheck
***REMOVED***
Expand Down
9 changes: 4 additions & 5 deletions lib/executor/ramping_vus.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ func (vlvc RampingVUsConfig) Validate() []error ***REMOVED***
// More information: https://github.com/k6io/k6/issues/997#issuecomment-484416866
func (vlvc RampingVUsConfig) getRawExecutionSteps(et *lib.ExecutionTuple, zeroEnd bool) []lib.ExecutionStep ***REMOVED***
var (
timeTillEnd time.Duration
fromVUs = vlvc.StartVUs.Int64
start, offsets, lcd = et.GetStripedOffsets()
steps = make([]lib.ExecutionStep, 0, vlvc.precalculateTheRequiredSteps(et, zeroEnd))
index = lib.NewSegmentedIndex(start, lcd, offsets)
timeTillEnd time.Duration
fromVUs = vlvc.StartVUs.Int64
steps = make([]lib.ExecutionStep, 0, vlvc.precalculateTheRequiredSteps(et, zeroEnd))
index = lib.NewSegmentedIndex(et)
)

// Reserve the scaled StartVUs at the beginning
Expand Down
3 changes: 1 addition & 2 deletions lib/executor/shared_iterations.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ func (si *SharedIterations) Init(ctx context.Context) error ***REMOVED***
// with no work, as determined by their config's HasWork() method.
et, err := si.BaseExecutor.executionState.ExecutionTuple.GetNewExecutionTupleFromValue(si.config.VUs.Int64)
si.et = et
start, offsets, lcd := et.GetStripedOffsets()
si.iterSegIndex = lib.NewSegmentedIndex(start, lcd, offsets)
si.iterSegIndex = lib.NewSegmentedIndex(et)

return err
***REMOVED***
Expand Down

0 comments on commit 01a82de

Please sign in to comment.