Skip to content

Commit

Permalink
Use the repeated iterator for retreving stacktraces list
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Oct 5, 2022
1 parent 02d7fab commit c02602d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
9 changes: 8 additions & 1 deletion pkg/firedb/query/repeated.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ func NewRepeatedPageIterator[T any](

// seekRowNum the row num to seek to.
func (it *repeatedPageIterator[T]) seekRowNum() int64 {
return any(it.rows.At()).(RowGetter).RowNumber()
switch i := any(it.rows.At()).(type) {
case RowGetter:
return i.RowNumber()
case int64:
return i
default:
panic("unknown type")
}
}

func (it *repeatedPageIterator[T]) Next() bool {
Expand Down
20 changes: 15 additions & 5 deletions pkg/firedb/sample_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,26 @@ func (b *singleBlockQuerier) resolveSymbols(ctx context.Context, stacktraceAggrB

var (
locationIDs = newUniqueIDs[struct{}]()
stacktraces = b.stacktraces.retrieveRows(ctx, iter.NewSliceIterator(stacktraceIDs))
stacktraces = repeatedColumnIter(ctx, b.stacktraces.file, "LocationIDs.list.element", iter.NewSliceIterator(stacktraceIDs))
)

for stacktraces.Next() {
s := stacktraces.At()

locationsByStacktraceID[s.RowNum] = make([]uint64, len(s.Result.LocationIDs))
for i, locationID := range s.Result.LocationIDs {
locationIDs[int64(locationID)] = struct{}{}
locationsByStacktraceID[s.RowNum][i] = locationID
_, ok := locationsByStacktraceID[s.Row]
if !ok {
locationsByStacktraceID[s.Row] = make([]uint64, len(s.Values))
for i, locationID := range s.Values {
locID := locationID.Uint64()
locationIDs[int64(locID)] = struct{}{}
locationsByStacktraceID[s.Row][i] = locID
}
continue
}
for _, locationID := range s.Values {
locID := locationID.Uint64()
locationIDs[int64(locID)] = struct{}{}
locationsByStacktraceID[s.Row] = append(locationsByStacktraceID[s.Row], locID)
}
}
if err := stacktraces.Err(); err != nil {
Expand Down

0 comments on commit c02602d

Please sign in to comment.