统计top n的大key有bug
jayddzjh opened this issue · 7 comments
`
// Append new object into tree set
// time complexity: O(n*log(m)), n is number of redis object, m is heap capacity. m if far less than n
func (h *redisTreeSet) Append(x model.RedisObject) {
// if heap is full && x.Size > minSize, then pop min
if h.set.Size() == h.capacity {
min := h.GetMin()
if min.GetSize() < x.GetSize() {
h.set.Remove(min)
h.set.Add(x)
}
} else {
h.set.Add(x)
}
}
`
请描述具体问题
指定获取top n不起作用,下面这块代码,无论如何都会新增一个元素到集合里面。
func (h *redisTreeSet) Append(x model.RedisObject) { // if heap is full && x.Size > minSize, then pop min if h.set.Size() == h.capacity { min := h.GetMin() if min.GetSize() < x.GetSize() { h.set.Remove(min) } } h.set.Add(x) }
是的,那个value的大小不准的bug,修复了吗,老哥
还早呢,内存占用可不好算
辛苦,老哥是学生还是工作了,可以加个qq或者微信吗
微信也是 hdt3213