Skip to content

Commit

Permalink
LineMerger: Log current state of of all scanners in case of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brawer committed May 19, 2024
1 parent 2034bc4 commit ffd7191
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/qrank-builder/linemerger.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,26 @@ func (m *LineMerger) Advance() bool {
return true
}
item := m.heap[0]

// TODO: This is just hack to investigate a bug. Remove it.
// https://github.com/brawer/wikidata-qrank/issues/40
lastLine := item.scanner.Text()

if item.scanner.Scan() {
heap.Fix(&m.heap, 0)
} else {
heap.Remove(&m.heap, 0)
}
if err := item.scanner.Err(); err != nil {
m.err = err
logger.Printf(`LineMerger: scanner "%s" failed, err=%v`, item.name, err)

// TODO: Make logging less verbose again once this bug is resolved.
// https://github.com/brawer/wikidata-qrank/issues/40
logger.Printf(`LineMerger: scanner "%s" failed, lastLine=%q, err=%v`, item.name, lastLine, err)
for i, mg := range m.heap {
logger.Printf(`LineMerger: scanner "%s" (#%d) at %q`, mg.name, i, mg.scanner.Text())
}

return false
}
return len(m.heap) > 0
Expand Down

0 comments on commit ffd7191

Please sign in to comment.