Example #1
0
        public void TestFlow()
        {
            // top-k for 3
            var spec = new CountMinSketchSpec();

            spec.HashesSpec = TestCountMinSketchStateHashes.DefaultSpec;
            spec.TopkSpec   = 3;
            spec.Agent      = new CountMinSketchAgentStringUTF16();
            var state = CountMinSketchState.MakeState(spec);

            UpdateAssert(state, "a", "a=1");
            UpdateAssert(state, "b", "a=1,b=1");
            UpdateAssert(state, "a", "a=2,b=1");
            UpdateAssert(state, "c", "a=2,b=1,c=1");
            UpdateAssert(state, "d", "a=2,b=1,c=1");
            UpdateAssert(state, "c", "a=2,b=1,c=2");
            UpdateAssert(state, "a", "a=3,b=1,c=2");
            UpdateAssert(state, "d", "a=3,d=2,c=2");
            UpdateAssert(state, "e", "a=3,d=2,c=2");
            UpdateAssert(state, "e", "a=3,d=2,c=2");
            UpdateAssert(state, "e", "a=3,e=3,c=2");
            UpdateAssert(state, "d", "a=3,e=3,d=3");
            UpdateAssert(state, "c", "a=3,e=3,d=3");
            UpdateAssert(state, "c", "a=3,e=3,c=4");
        }
Example #2
0
        public static CountMinSketchState MakeState(CountMinSketchSpec spec)
        {
            var hashes = CountMinSketchStateHashes.MakeState(spec.HashesSpec);
            CountMinSketchStateTopk topk = null;
            if (spec.TopkSpec != null && spec.TopkSpec > 0) {
                topk = new CountMinSketchStateTopk(spec.TopkSpec.Value);
            }

            return new CountMinSketchState(hashes, topk);
        }