public void CountNoReturn(int id, BigSegmentedArray count) { int[] page = m_list[id >> PAGEID_SHIFT]; if (page == null) { count.Add(0, count.Get(0) + 1); return; } int val = page[id & SLOTID_MASK]; if (val >= 0) { count.Add(val, count.Get(val) + 1); return; } else if (val != MISSING) { int idx = -(val >> VALIDX_SHIFT); // signed shift, remember val is a negative number int cnt = (val & COUNT_MASK); int end = idx + cnt; while (idx < end) { count.Add(page[idx], count.Get(page[idx]) + 1); idx++; } return; } count.Add(0, count.Get(0) + 1); return; }
private static void FindValueHelper(BigSegmentedArray array) { int a = array.MaxValue / 16; int b = a * 2; int c = a * 3; array.Add(1000, a); array.Add(2000, b); Assert.AreEqual(1000, array.FindValue(a, 0, 2000)); Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, array.FindValue(a, 1001, 2000)); Assert.AreEqual(2000, array.FindValue(b, 2000, 3000)); array.Fill(c); Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, array.FindValue(b, 2000, 3000)); Assert.AreEqual(4000, array.FindValue(c, 4000, 4000)); }
public static BigSegmentedArray Initialize(BigSegmentedArray array) { for (int i = 0; i < array.Length; i++) { array.Add(i, i % array.MaxValue); } return(array); }
private BigSegmentedArray GetCollapsedCounts() { if (_collapsedCounts == null) { _collapsedCounts = new LazyBigIntArray(_bucketValues.Count); FacetDataCache dataCache = _subCollector.DataCache; ITermValueList subList = dataCache.ValArray; BigSegmentedArray subcounts = _subCollector.Count; BitVector indexSet = new BitVector(subcounts.Size()); int c = 0; int i = 0; foreach (string val in _bucketValues) { if (val.Length > 0) { string[] subVals = _predefinedBuckets.Get(val); int count = 0; foreach (string subVal in subVals) { int index = subList.IndexOf(subVal); if (index > 0) { int subcount = subcounts.Get(index); count += subcount; if (!indexSet.Get(index)) { indexSet.Set(index); c += dataCache.Freqs[index]; } } } _collapsedCounts.Add(i, count); } i++; } _collapsedCounts.Add(0, (_numdocs - c)); } return _collapsedCounts; }
public void CountNoReturnWithFilter(int id, BigSegmentedArray count, OpenBitSet filter) { int[] page = _list[id >> PAGEID_SHIFT]; if (page == null) { count.Add(0, count.Get(0) + 1); return; } int val = page[id & SLOTID_MASK]; if (val >= 0) { if (filter.FastGet(val)) { count.Add(val, count.Get(val) + 1); } return; } else if (val != MISSING) { int idx = -(val >> VALIDX_SHIFT); // signed shift, remember val is a negative number int cnt = (val & COUNT_MASK); int end = idx + cnt; while (idx < end) { int value = page[idx++]; if (filter.FastGet(value)) { count.Add(value, count.Get(value) + 1); } } return; } count.Add(0, count.Get(0) + 1); return; }
private static void FindValueRangeHelper(BigSegmentedArray array) { int a = array.MaxValue / 16; int b = a * 2; int d = a * 4; int e = a * 5; array.Add(10000, b); Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, array.FindValueRange(d, e, 0, array.Length)); Assert.AreEqual(10000, array.FindValueRange(a, e, 0, array.Length)); Assert.AreEqual(10000, array.FindValueRange(a, e, 10000, array.Length)); Assert.AreEqual(10000, array.FindValueRange(a, e, 0, 10000)); Assert.AreEqual(10000, array.FindValueRange(a, b, 9000, 10100)); Assert.AreEqual(10000, array.FindValueRange(b, e, 9000, 10000)); Assert.AreEqual(10000, array.FindValueRange(b, b, 9000, 10000)); }
private static void FillTestHelper(BigSegmentedArray array) { int a = array.MaxValue / 4; int b = array.MaxValue / 2; int c = array.MaxValue - 1; Assert.AreEqual(0, array.Get(20000)); array.Fill(a); Assert.AreEqual(a, array.Get(20000)); array.Add(20000, b); Assert.AreEqual(b, array.Get(20000)); Assert.AreEqual(a, array.Get(20001)); Assert.AreEqual(20000, array.FindValue(b, 0, 21000)); array.Fill(c); Assert.AreEqual(c, array.Get(20000)); Assert.AreEqual(c, array.Get(40000)); Assert.AreEqual(c, array.Get(0)); }
private static void FindValueRangeHelper(BigSegmentedArray array) { int a = array.MaxValue / 16; int b = a * 2; int c = a * 3; int d = a * 4; int e = a * 5; int f = a * 6; array.Add(10000, b); Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, array.FindValueRange(d, e, 0, array.Size())); Assert.AreEqual(10000, array.FindValueRange(a, e, 0, array.Size())); Assert.AreEqual(10000, array.FindValueRange(a, e, 10000, array.Size())); Assert.AreEqual(10000, array.FindValueRange(a, e, 0, 10000)); Assert.AreEqual(10000, array.FindValueRange(a, b, 9000, 10100)); Assert.AreEqual(10000, array.FindValueRange(b, e, 9000, 10000)); Assert.AreEqual(10000, array.FindValueRange(b, b, 9000, 10000)); }
public static BigSegmentedArray Initialize(BigSegmentedArray array) { for (int i = 0; i < array.Size(); i++) { array.Add(i, i % array.MaxValue); } return array; }
public void CountNoReturn(int id, BigSegmentedArray count) { int[] page = _list[id >> PAGEID_SHIFT]; if (page == null) { count.Add(0, count.Get(0) + 1); return; } int val = page[id & SLOTID_MASK]; if (val >= 0) { count.Add(val, count.Get(val) + 1); return; } else if (val != MISSING) { int idx = -(val >> VALIDX_SHIFT); // signed shift, remember val is a negative number int cnt = (val & COUNT_MASK); int end = idx + cnt; while (idx < end) { count.Add(page[idx], count.Get(page[idx]) + 1); idx++; } return; } count.Add(0, count.Get(0) + 1); return; }