Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
sql/plan: correctly count processed index rows globally instead of pe…
Browse files Browse the repository at this point in the history
…r partition

Signed-off-by: Miguel Molina <[email protected]>
(cherry picked from commit 22c8983)
  • Loading branch information
erizocosmico authored and ajnavarro committed Oct 17, 2018
1 parent cdea792 commit 22dbafa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sql/index/pilosa/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (idx *pilosaIndex) Expressions() []string {
return idx.expressions
}

func (pilosaIndex) Driver() string { return DriverID }
func (*pilosaIndex) Driver() string { return DriverID }

func (idx *pilosaIndex) AscendGreaterOrEqual(keys ...interface{}) (sql.IndexLookup, error) {
if len(keys) != len(idx.expressions) {
Expand Down
13 changes: 8 additions & 5 deletions sql/plan/create_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ type loggingPartitionKeyValueIter struct {
ctx *sql.Context
log *logrus.Entry
iter sql.PartitionIndexKeyValueIter
rows uint64
}

func newLoggingPartitionKeyValueIter(
Expand All @@ -418,7 +419,7 @@ func (i *loggingPartitionKeyValueIter) Next() (sql.Partition, sql.IndexKeyValueI
return nil, nil, err
}

return p, newLoggingKeyValueIter(i.ctx, i.log, iter), nil
return p, newLoggingKeyValueIter(i.ctx, i.log, iter, &i.rows), nil
}

func (i *loggingPartitionKeyValueIter) Close() error {
Expand All @@ -430,20 +431,22 @@ type loggingKeyValueIter struct {
span opentracing.Span
log *logrus.Entry
iter sql.IndexKeyValueIter
rows uint64
rows *uint64
start time.Time
}

func newLoggingKeyValueIter(
ctx *sql.Context,
log *logrus.Entry,
iter sql.IndexKeyValueIter,
rows *uint64,
) *loggingKeyValueIter {
return &loggingKeyValueIter{
ctx: ctx,
log: log,
iter: iter,
start: time.Now(),
rows: rows,
}
}

Expand All @@ -456,13 +459,13 @@ func (i *loggingKeyValueIter) Next() ([]interface{}, []byte, error) {
)
}

i.rows++
if i.rows%sql.IndexBatchSize == 0 {
(*i.rows)++
if *i.rows%sql.IndexBatchSize == 0 {
duration := time.Since(i.start)

i.log.WithFields(logrus.Fields{
"duration": duration,
"rows": i.rows,
"rows": *i.rows,
}).Debugf("still creating index")

if i.span != nil {
Expand Down

0 comments on commit 22dbafa

Please sign in to comment.