Skip to content

Commit

Permalink
corrects upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Nov 17, 2023
1 parent e4a1981 commit a0b3292
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions flow/connectors/eventhub/hub_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,12 @@ func (h *HubBatches) flushAllBatches(
log.WithFields(log.Fields{
"flowName": flowName,
}).Infof("pushed %d events to event hub: %s", numEvents, tblName)
rowCount, ok := tableNameRowsMapping.Get(tblName.ToString())
if !ok {
rowCount = uint32(0)
}
rowCount += uint32(numEvents)
tableNameRowsMapping.Upsert(tblName.ToString(), rowCount,
func(exist bool, valueInMap, newValue uint32) uint32 {
if exist {
return valueInMap
tableNameRowsMapping.Upsert(tblName.ToString(), uint32(numEvents),
func(exist bool, rowCount uint32, newRows uint32) uint32 {
if !exist {
return newRows
}
return newValue
return rowCount + newRows
})
return nil
})
Expand Down

0 comments on commit a0b3292

Please sign in to comment.