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"); }
public CountMinSketchAggState( CountMinSketchState state, CountMinSketchAgent agent) { this.state = state; this.agent = agent; add = new CountMinSketchAgentContextAdd(state); estimate = new CountMinSketchAgentContextEstimate(state); fromBytes = new CountMinSketchAgentContextFromBytes(state); }
private void UpdateAssert( CountMinSketchState state, string value, string expected) { state.Add(value.GetUTF8Bytes(), 1); var topkValues = state.TopKValues; IList <Pair <long, object> > topkList = new List <Pair <long, object> >(); foreach (var topkValue in topkValues) { var frequency = state.Frequency(topkValue.Array); var text = Encoding.UTF8.GetString(topkValue.Array); topkList.Add(new Pair <long, object>(frequency, text)); } AssertList(expected, topkList); }
public CountMinSketchAggState MakeAggState() { return new CountMinSketchAggState(CountMinSketchState.MakeState(this), Agent); }