public void AssertAddInit(int index_bits, int minhash_bits) { client.Delete(null, key); string msg = "Fail - index_bits " + index_bits + " minhash_bits " + minhash_bits; HLLPolicy p = HLLPolicy.Default; Operation[] ops = new Operation[] { HLLOperation.Add(p, binName, entries, index_bits, minhash_bits), HLLOperation.GetCount(binName), HLLOperation.RefreshCount(binName), HLLOperation.Describe(binName), HLLOperation.Add(p, binName, entries) }; if (!CheckBits(index_bits, minhash_bits)) { AssertThrows(msg, key, typeof(AerospikeException), ResultCode.PARAMETER_ERROR, ops); return; } Record record = AssertSuccess(msg, key, ops); IList result_list = record.GetList(binName); long count = (long)result_list[1]; long count1 = (long)result_list[2]; IList description = (IList)result_list[3]; long n_added = (long)result_list[4]; AssertDescription(msg, description, index_bits, minhash_bits); AssertHLLCount(msg, index_bits, count, entries.Count); Assert.AreEqual(count, count1); Assert.AreEqual(n_added, 0); }
public void AssertInit(int index_bits, int minhash_bits, bool should_pass) { string msg = "Fail - index_bits " + index_bits + " minhash_bits " + minhash_bits; HLLPolicy p = HLLPolicy.Default; Operation[] ops = new Operation[] { HLLOperation.Init(p, binName, index_bits, minhash_bits), HLLOperation.GetCount(binName), HLLOperation.RefreshCount(binName), HLLOperation.Describe(binName) }; if (!should_pass) { AssertThrows(msg, key, typeof(AerospikeException), ResultCode.PARAMETER_ERROR, ops); return; } Record record = AssertSuccess(msg, key, ops); IList result_list = record.GetList(binName); long count = (long)result_list[1]; long count1 = (long)result_list[2]; IList description = (IList)result_list[3]; AssertDescription(msg, description, index_bits, minhash_bits); Assert.AreEqual(0, count); Assert.AreEqual(0, count1); }
public void AssertFold(IList vals0, IList vals1, int index_bits) { string msg = "Fail - index_bits " + index_bits; HLLPolicy p = HLLPolicy.Default; for (int ix = minIndexBits; ix <= index_bits; ix++) { if (!CheckBits(index_bits, 0) || !CheckBits(ix, 0)) { Assert.IsTrue(false, "Expected valid inputs: " + msg); } Record recorda = AssertSuccess(msg, key, Operation.Delete(), HLLOperation.Add(p, binName, vals0, index_bits), HLLOperation.GetCount(binName), HLLOperation.RefreshCount(binName), HLLOperation.Describe(binName)); IList resulta_list = recorda.GetList(binName); long counta = (long)resulta_list[1]; long counta1 = (long)resulta_list[2]; IList descriptiona = (IList)resulta_list[3]; AssertDescription(msg, descriptiona, index_bits, 0); AssertHLLCount(msg, index_bits, counta, vals0.Count); Assert.AreEqual(counta, counta1); Record recordb = AssertSuccess(msg, key, HLLOperation.Fold(binName, ix), HLLOperation.GetCount(binName), HLLOperation.Add(p, binName, vals0), HLLOperation.Add(p, binName, vals1), HLLOperation.GetCount(binName), HLLOperation.Describe(binName) ); IList resultb_list = recordb.GetList(binName); long countb = (long)resultb_list[1]; long n_added0 = (long)resultb_list[2]; long countb1 = (long)resultb_list[4]; IList descriptionb = (IList)resultb_list[5]; Assert.AreEqual(0, n_added0); AssertDescription(msg, descriptionb, ix, 0); AssertHLLCount(msg, ix, countb, vals0.Count); AssertHLLCount(msg, ix, countb1, vals0.Count + vals1.Count); } }
public void AssertSimilarityOp(double overlap, IList common, IList <IList> vals, int index_bits, int minhash_bits) { IList <Value.HLLValue> hlls = new List <Value.HLLValue>(); for (int i = 0; i < keys.Length; i++) { Record record = AssertSuccess("init other keys", keys[i], Operation.Delete(), HLLOperation.Add(HLLPolicy.Default, binName, vals[i], index_bits, minhash_bits), HLLOperation.Add(HLLPolicy.Default, binName, common, index_bits, minhash_bits), Operation.Get(binName) ); IList result_list = record.GetList(binName); hlls.Add((Value.HLLValue)result_list[2]); } // Keep record around win binName is removed. Record r = AssertSuccess("other bin", key, Operation.Delete(), HLLOperation.Init(HLLPolicy.Default, binName + "other", index_bits, minhash_bits), HLLOperation.SetUnion(HLLPolicy.Default, binName, hlls), HLLOperation.Describe(binName) ); IList rlist = r.GetList(binName); IList description = (IList)rlist[1]; AssertDescription("check desc", description, index_bits, minhash_bits); r = AssertSuccess("similarity and intersect_count", key, HLLOperation.GetSimilarity(binName, hlls), HLLOperation.GetIntersectCount(binName, hlls) ); rlist = r.GetList(binName); double sim = (double)rlist[0]; long intersect_count = (long)rlist[1]; double expected_similarity = overlap; long expected_intersect_count = common.Count; AssertHMHSimilarity("check sim", index_bits, minhash_bits, sim, expected_similarity, intersect_count, expected_intersect_count); }
public void GetPut() { foreach (List <int> desc in legalDescriptions) { int index_bits = desc[0]; int minhash_bits = desc[1]; AssertSuccess("init record", key, Operation.Delete(), HLLOperation.Init(HLLPolicy.Default, binName, index_bits, minhash_bits)); Record record = client.Get(null, key); Value.HLLValue hll = record.GetHLLValue(binName); client.Delete(null, key); client.Put(null, key, new Bin(binName, hll)); record = AssertSuccess("describe", key, HLLOperation.GetCount(binName), HLLOperation.Describe(binName)); IList result_list = record.GetList(binName); long count = (long)result_list[0]; IList description = (IList)result_list[1]; Assert.AreEqual(0, count); AssertDescription("Check description", description, index_bits, minhash_bits); } }