Skip to content

fix: close rows iterator #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/infra/pull/datasource_ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,7 @@ func (rs *ResultStream) Value() pull.Row {
func (rs *ResultStream) Error() error {
return rs.err
}

func (rs *ResultStream) Close() error {
return nil
}
2 changes: 2 additions & 0 deletions internal/infra/pull/http_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func (ds *HTTPDataSource) Read(source pull.Table, filter pull.Filter) (pull.RowS
return nil, err
}

defer reader.Close()

result := pull.RowSet{}
for reader.Next() {
result = append(result, reader.Value())
Expand Down
4 changes: 4 additions & 0 deletions internal/infra/pull/rowreader_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ func (jrr *JSONRowReader) Value() pull.Row {
func (jrr *JSONRowReader) Error() error {
return jrr.err
}

func (jrr *JSONRowReader) Close() error {
return nil
}
7 changes: 7 additions & 0 deletions internal/infra/pull/sql_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func (ds *SQLDataSource) Read(source pull.Table, filter pull.Filter) (pull.RowSe
return nil, err
}

defer reader.Close()

result := pull.RowSet{}
for reader.Next() {
result = append(result, reader.Value())
Expand Down Expand Up @@ -250,3 +252,8 @@ func (di *SQLDataIterator) Value() pull.Row {
func (di *SQLDataIterator) Error() error {
return di.err
}

// Close returns the iterator
func (di *SQLDataIterator) Close() error {
return di.rows.Close()
}
1 change: 1 addition & 0 deletions pkg/pull/driven.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type RowReader interface {
Next() bool
Value() Row
Error() error
Close() error
}

// TraceListener receives diagnostic trace.
Expand Down
3 changes: 3 additions & 0 deletions pkg/pull/driven_DatasourceInMemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func (ds DataSourceInMemory) Read(source Table, filter Filter) (RowSet, error) {
return nil, err
}

defer reader.Close()

result := RowSet{}
for reader.Next() {
result = append(result, reader.Value())
Expand Down Expand Up @@ -104,3 +106,4 @@ func (rr *RowReaderInMemory) Value() Row {
return row
}
func (rr *RowReaderInMemory) Error() error { return nil }
func (rr *RowReaderInMemory) Close() error { return nil }
3 changes: 3 additions & 0 deletions pkg/pull/driven_OneEmptyRowReader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ func (r OneEmptyRowReader) Value() Row { return Row{} }

// Error return always nil
func (r OneEmptyRowReader) Error() error { return nil }

// Close return always nil
func (r OneEmptyRowReader) Close() error { return nil }
2 changes: 2 additions & 0 deletions pkg/pull/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func (p *puller) Pull(start Table, filter Filter, filterCohort RowReader, exclud
return fmt.Errorf("%w", err)
}

defer reader.Close()

for reader.Next() {
IncLinesPerStepCount(string(start.Name))
row := start.export(reader.Value())
Expand Down
2 changes: 2 additions & 0 deletions pkg/pull/driver_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func (p *pullerParallel) Pull(start Table, filter Filter, filterCohort RowReader
return fmt.Errorf("%w", err)
}

defer reader.Close()

for reader.Next() {
IncLinesPerStepCount(string(start.Name))
p.inChan <- reader.Value()
Expand Down