|
1 | | -/* |
2 | | - * Copyright 2015 Ben Manes. All Rights Reserved. |
3 | | - * |
4 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | - * you may not use this file except in compliance with the License. |
6 | | - * You may obtain a copy of the License at |
7 | | - * |
8 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
10 | | - * Unless required by applicable law or agreed to in writing, software |
11 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | - * See the License for the specific language governing permissions and |
14 | | - * limitations under the License. |
15 | | - */ |
16 | | - |
17 | | -using System; |
| 1 | +using System; |
18 | 2 | using System.Collections.Generic; |
19 | | -using System.Text; |
20 | 3 |
|
21 | 4 | namespace BitFaster.Caching.Lfu |
22 | 5 | { |
23 | | - // https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch#:~:text=In%20computing%2C%20the%20count%E2%80%93min,some%20events%20due%20to%20collisions. |
24 | | - // Parallel count min: https://www.atlantis-press.com/proceedings/mmebc-16/25859036 |
25 | | - // SIMD: https://thlujy.github.io/papers/Lujianyuan-tpds-ufbf.pdf |
26 | | - // https://github.com/ben-manes/caffeine/blob/master/caffeine/src/main/java/com/github/benmanes/caffeine/cache/FrequencySketch.java |
27 | | - // https://github.com/ben-manes/caffeine/blob/master/caffeine/src/test/java/com/github/benmanes/caffeine/cache/FrequencySketchTest.java |
28 | | - public class CmSketch<T> |
| 6 | + /// <summary> |
| 7 | + /// A probabilistic data structure used to estimate the frequency of a given value. Periodic aging reduces the |
| 8 | + /// accumulated count across all values over time, such that a historic popular value will decay to zero frequency |
| 9 | + /// over time if it is not accessed. |
| 10 | + /// </summary> |
| 11 | + /// <remarks> |
| 12 | + /// This is a direct C# translation of FrequencySketch in the Caffeine library by ben.manes@gmail.com (Ben Manes). |
| 13 | + /// http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + /// </remarks> |
| 15 | + public sealed class CmSketch<T> |
29 | 16 | { |
30 | 17 | // A mixture of seeds from FNV-1a, CityHash, and Murmur3 |
31 | 18 | private static ulong[] Seed = { 0xc3a5c85c97cb3127L, 0xb492b66fbe98f273L, 0x9ae16a3b2f90404fL, 0xcbf29ce484222325L}; |
|
0 commit comments