//AddSignal: Updates the counter and signals completion on a channel func (cms *CMSketch) AddSignal(start_row int64, end_row int64, position int64, count int64, ch chan int64) { var h hashes.Hash for row := start_row; row < end_row; row++ { h = cms.Hash[row] cms.Counter.Add(row, h.Apply(position)%cms.Width, count) } ch <- 1 }
//PointQuery: query the value at position func (cms *CMSketch) PointQuery(position int64) int64 { temp := make([]int64, cms.Depth) var h hashes.Hash var i int64 for i = 0; i < cms.Depth; i++ { h = cms.Hash[i] temp[i] = cms.Counter.Read(i, h.Apply(position)%cms.Width) } mini := temp[0] for i = 0; i < cms.Depth; i++ { if mini > temp[i] { mini = temp[i] } } return mini }