Skip to content
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

Small BQ audit optimization #1099

Merged
merged 1 commit into from
Jan 2, 2025
Merged

Small BQ audit optimization #1099

merged 1 commit into from
Jan 2, 2025

Conversation

Tang8330
Copy link
Contributor

@Tang8330 Tang8330 commented Jan 2, 2025

Instead of calling .Rows() which will iterate over the in-memory database and append rows for which we just call len() on, we can call NumberOfRows which will return us the number of rows and skip the intermediary object.

Code ref:

func (t *TableData) Rows() []map[string]any {
var rows []map[string]any
if t.Mode() == config.History {
// History mode, the data is stored under `rows`
rows = append(rows, t.rows...)
} else {
for _, row := range t.rowsData {
rows = append(rows, row)
}
}
return rows
}
func (t *TableData) NumberOfRows() uint {
if t == nil {
return 0
}
if t.mode == config.History {
return uint(len(t.rows))
}
return uint(len(t.rowsData))
}

@Tang8330 Tang8330 marked this pull request as ready for review January 2, 2025 23:38
@Tang8330 Tang8330 requested a review from a team as a code owner January 2, 2025 23:38
@Tang8330 Tang8330 merged commit fb4c5e0 into master Jan 2, 2025
3 checks passed
@Tang8330 Tang8330 deleted the bq-optimization branch January 2, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants