public void TestTermStringListAddWrongOrder() { TermStringList tsl1 = new TermStringList(); tsl1.Add(null); tsl1.Add("m"); try { tsl1.Add("a"); } catch (Exception e) { Assert.True(e.Message.Contains("ascending order"), "There should be an exception and the message contains ascending order"); return; } Assert.Fail("There should be an exception and the message contains ascending order"); }
public void TestTermStringListAddCorrectOrder() { TermStringList tsl1 = new TermStringList(); tsl1.Add(null); tsl1.Add(""); try { tsl1.Add("m"); tsl1.Add("s"); tsl1.Add("t"); } catch (Exception e) { Assert.False(e.Message.Contains("ascending order"), "There should NOT be an exception and the message contains ascending order"); return; } tsl1.Seal(); Assert.AreEqual(1, tsl1.IndexOf(""), "Should skip index 0 which is used for dummy null"); }
public BucketFacetCountCollector(string name, DefaultFacetCountCollector subCollector, FacetSpec ospec, IDictionary<string, string[]> predefinedBuckets, int numdocs) { _name = name; _subCollector = subCollector; _ospec = ospec; _numdocs = numdocs; _predefinedBuckets = predefinedBuckets; _collapsedCounts = null; _bucketValues = new TermStringList(); _bucketValues.Add(""); List<string> bucketArray = _predefinedBuckets.Keys.ToList(); bucketArray.Sort(); foreach (string bucket in bucketArray) { _bucketValues.Add(bucket); } _bucketValues.Seal(); }
public BucketFacetCountCollector(string name, DefaultFacetCountCollector subCollector, FacetSpec ospec, IDictionary <string, string[]> predefinedBuckets, int numdocs) { m_name = name; m_subCollector = subCollector; m_ospec = ospec; m_numdocs = numdocs; m_predefinedBuckets = predefinedBuckets; m_collapsedCounts = null; m_bucketValues = new TermStringList(); m_bucketValues.Add(""); List <string> bucketArray = m_predefinedBuckets.Keys.ToList(); bucketArray.Sort(); foreach (string bucket in bucketArray) { m_bucketValues.Add(bucket); } m_bucketValues.Seal(); }
public void TestDefaultFacetIterator() { TermStringList tsl1 = new TermStringList(); tsl1.Add("i"); tsl1.Add("m"); tsl1.Seal(); BigInt32Array count = new BigInt32Array(2); count.Add(0, 1); count.Add(1, 2); DefaultFacetIterator itr1 = new DefaultFacetIterator(tsl1, count, 2, false); TermStringList tsl2 = new TermStringList(); tsl2.Add("i"); tsl2.Add("m"); tsl2.Seal(); BigInt32Array count2 = new BigInt32Array(2); count2.Add(0, 1); count2.Add(1, 5); DefaultFacetIterator itr2 = new DefaultFacetIterator(tsl2, count2, 2, true); List <FacetIterator> list = new List <FacetIterator>(); list.Add(itr1); list.Add(itr2); CombinedFacetIterator ctr = new CombinedFacetIterator(list); string result = ""; while (ctr.HasNext()) { ctr.Next(); result += ctr.Facet; result += ctr.Count; } Assert.AreEqual("i1m7", result, "result should be i1m7"); }
public void TestDefaultFacetIterator() { TermStringList tsl1 = new TermStringList(); tsl1.Add("i"); tsl1.Add("m"); tsl1.Seal(); BigIntArray count = new BigIntArray(2); count.Add(0, 1); count.Add(1, 2); DefaultFacetIterator itr1 = new DefaultFacetIterator(tsl1, count, 2, false); TermStringList tsl2 = new TermStringList(); tsl2.Add("i"); tsl2.Add("m"); tsl2.Seal(); BigIntArray count2 = new BigIntArray(2); count2.Add(0, 1); count2.Add(1, 5); DefaultFacetIterator itr2 = new DefaultFacetIterator(tsl2, count2, 2, true); List<FacetIterator> list = new List<FacetIterator>(); list.Add(itr1); list.Add(itr2); CombinedFacetIterator ctr = new CombinedFacetIterator(list); string result = ""; while (ctr.HasNext()) { ctr.Next(); result += ctr.Facet; result += ctr.Count; } Assert.AreEqual("i1m7", result, "result should be i1m7"); }