h*9
3 楼
I would do as below.
61 buckets -- one for each minute. last bucket is for the current minute.
every hit will increase the counter in current bucket by 1. at the end of
the minute, phase out the oldest bucket and create a new bucket as the
current bucket.
最后一分钟点击量 = bucket[60] + interpolate(bucket[59])
最后一小时的点击量 = interpolate(bucket[0]) + sum(bucket[1] ... bucket[60])
61 buckets -- one for each minute. last bucket is for the current minute.
every hit will increase the counter in current bucket by 1. at the end of
the minute, phase out the oldest bucket and create a new bucket as the
current bucket.
最后一分钟点击量 = bucket[60] + interpolate(bucket[59])
最后一小时的点击量 = interpolate(bucket[0]) + sum(bucket[1] ... bucket[60])
C*U
6 楼
我开始是这么和他说的
但是他后来又有写问题
说如果是1分零1秒怎么办
然后我就改到tree结构了
【在 h**********9 的大作中提到】
: I would do as below.
: 61 buckets -- one for each minute. last bucket is for the current minute.
: every hit will increase the counter in current bucket by 1. at the end of
: the minute, phase out the oldest bucket and create a new bucket as the
: current bucket.
: 最后一分钟点击量 = bucket[60] + interpolate(bucket[59])
: 最后一小时的点击量 = interpolate(bucket[0]) + sum(bucket[1] ... bucket[60])
但是他后来又有写问题
说如果是1分零1秒怎么办
然后我就改到tree结构了
【在 h**********9 的大作中提到】
: I would do as below.
: 61 buckets -- one for each minute. last bucket is for the current minute.
: every hit will increase the counter in current bucket by 1. at the end of
: the minute, phase out the oldest bucket and create a new bucket as the
: current bucket.
: 最后一分钟点击量 = bucket[60] + interpolate(bucket[59])
: 最后一小时的点击量 = interpolate(bucket[0]) + sum(bucket[1] ... bucket[60])
p*2
10 楼
把精确度先搞定,然后用滚动数组+counter就可以了。
C*U
13 楼
那就和我的那个树结构是一个道理。
e*s
15 楼
可以用24×60×60 Queue吗?
相关阅读
onsite 后求bless【急】EB1A, AOS期间H1B如果被雷的若干问题数学博士毕业念cs opt怎么算?h1b trans也问background check和reference checkfacebook明年上半年不招fresh了?关于phone screen面试问个H1B Extend pending期间换公司的问题郁闷吐槽,拿到offer,但是因为身份问题又被收回了有没有人知情SanDisk的情况阿Epic是health care那个么?Work AuthorizationHM给我写信让我等结果,抄送给大老板,啥意思?要不要申请opt延期,大家是怎么做的?hr居然给我发了这么诚实的email问一下去工业界的CS PHD关于OPT中的part time,请教各位?请教一个H1B签证的问题现在工资都开的好高啊有人找新能源相关行业工作的吗?