public void ShouldBucketByHundreds() { var buckets = new Dictionary <string, string> { { "someInt", "100s" } }; var builder = new DigestBuilder(buckets); builder.Add("id1", new Dictionary <string, string> { { "someInt", "123" } }, "vsn1"); builder.Add("id2", new Dictionary <string, string> { { "someInt", "234" } }, "vsn2"); builder.Add("id3", new Dictionary <string, string> { { "someInt", "125" } }, "vsn3"); var expected = new List <AggregateDigest> { new AggregateDigest(new List <string> { "100" }, DigestUtils.Md5Hex("vsn1" + "vsn3")), new AggregateDigest(new List <string> { "200" }, DigestUtils.Md5Hex("vsn2")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }
protected override IEnumerable <ScanResultEntry> Query(IEnumerable <IQueryConstraint> constraints, IEnumerable <ICategoryFunction> aggregations) { var constrainedData = _data.Where(d => d.Satisfies(constraints)); if (aggregations.Count() > 0) { var digester = new DigestBuilder(aggregations); foreach (var d in constrainedData) { digester.Add(d.Id, d.Attributes, d.Version); } return(digester.GetScanResults().ToArray()); } else { return(constrainedData.Select(d => new ScanResultEntry(d.Id, d.Attributes, null, d.Version))); } }
public void ShouldBucketByThousands() { var buckets = new Dictionary<string, string> {{"someInt", "1000s"}}; var builder = new DigestBuilder(buckets); builder.Add("id1", new Dictionary<string, string> { { "someInt", "1234" } }, "vsn1"); builder.Add("id2", new Dictionary<string, string> { { "someInt", "2345" } }, "vsn2"); builder.Add("id3", new Dictionary<string, string> { { "someInt", "1235" } }, "vsn3" ); var expected = new List<AggregateDigest> { new AggregateDigest(new List<string> {"1000"}, DigestUtils.Md5Hex("vsn1"+"vsn3")), new AggregateDigest(new List<string> {"2000"}, DigestUtils.Md5Hex("vsn2")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }
public void ShouldBucketByMonth() { var buckets = new Dictionary<string, string> { { "bizDate", "monthly" } }; var builder = new DigestBuilder(buckets); var lastUpdated = DateTime.Parse("2011-02-02T14:23:44.426Z"); builder.Add("id1", new Dictionary<string, string> { { "bizDate", "2010-08-16" } }, "vsn1"); builder.Add("id2", new Dictionary<string, string> { { "bizDate", "2010-07-14" } }, "vsn2"); builder.Add("id3", new Dictionary<string, string> { { "bizDate", "2010-08-09" } }, "vsn3"); var expected = new List<AggregateDigest> { new AggregateDigest(new List<string> {"2010-07"}, DigestUtils.Md5Hex("vsn2")), new AggregateDigest(new List<string> {"2010-08"}, DigestUtils.Md5Hex("vsn1"+"vsn3")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }
public void ShouldBucketByMonth() { var buckets = new Dictionary <string, string> { { "bizDate", "monthly" } }; var builder = new DigestBuilder(buckets); var lastUpdated = DateTime.Parse("2011-02-02T14:23:44.426Z"); builder.Add("id1", new Dictionary <string, string> { { "bizDate", "2010-08-16" } }, "vsn1"); builder.Add("id2", new Dictionary <string, string> { { "bizDate", "2010-07-14" } }, "vsn2"); builder.Add("id3", new Dictionary <string, string> { { "bizDate", "2010-08-09" } }, "vsn3"); var expected = new List <AggregateDigest> { new AggregateDigest(new List <string> { "2010-07" }, DigestUtils.Md5Hex("vsn2")), new AggregateDigest(new List <string> { "2010-08" }, DigestUtils.Md5Hex("vsn1" + "vsn3")) }; var aggregateDigests = builder.GetDigests(); // TODO fudged because Assert.AreEqual did not seem to work as expected on the actual AggregateDigest objects Assert.AreEqual(expected[0].Attributes, aggregateDigests[0].Attributes); Assert.AreEqual(expected[0].Digest, aggregateDigests[0].Digest); Assert.AreEqual(expected[1].Attributes, aggregateDigests[1].Attributes); Assert.AreEqual(expected[1].Digest, aggregateDigests[1].Digest); }
public TcsDigest Digest(DigestBuilder builder) { throw new NotImplementedException(); }
protected override IEnumerable<ScanResultEntry> Query(IEnumerable<IQueryConstraint> constraints, IEnumerable<ICategoryFunction> aggregations) { var constrainedData = _data.Where(d => d.Satisfies(constraints)); if (aggregations.Count() > 0) { var digester = new DigestBuilder(aggregations); foreach (var d in constrainedData) digester.Add(d.Id, d.Attributes, d.Version); return digester.GetScanResults().ToArray(); } else { return constrainedData.Select(d => new ScanResultEntry(d.Id, d.Attributes, null, d.Version)); } }