public void TestBigIntArray() { int count = 5000000; var test = new BigIntArray(count); var test2 = new int[count]; for (int i = 0; i < count; i++) { test.Add(i, i); test2[i] = i; } for (int i = 0; i < count; i++) { Assert.AreEqual(0, test.Get(0)); } int k = 0; var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < count; i++) { k = test.Get(i); } sw.Stop(); Console.WriteLine("Big array took: " + sw.ElapsedMilliseconds.ToString()); sw.Reset(); sw.Start(); for (int i = 0; i < count; i++) { k = test2[i]; } sw.Stop(); Console.WriteLine("int[] took: " + sw.ElapsedMilliseconds.ToString()); }
public void TestBigIntArray() { int count = 5000000; var test = new BigIntArray(count); var test2 = new int[count]; for (int i = 0; i < count; i++) { test.Add(i, i); test2[i] = i; } for (int i = 0; i < count; i++) { Assert.AreEqual(0, test.Get(0)); } int k = 0; long start = System.Environment.TickCount; for (int i = 0; i < count; i++) { k = test.Get(i); } long end = System.Environment.TickCount; Console.WriteLine("Big array took: " + (end - start)); start = System.Environment.TickCount; for (int i = 0; i < count; i++) { k = test2[i]; } end = System.Environment.TickCount; Console.WriteLine("int[] took: " + (end - start)); }
public BufferedLoader(int size, int maxItems, BigIntBuffer buffer) { _size = size; _maxItems = Math.Min(maxItems, BigNestedIntArray.MAX_ITEMS); _info = new BigIntArray(size << 1); // pointer and count _info.Fill(EOD); _buffer = buffer; }
public static BigSegmentedArray FromArray(int[] original) { BigIntArray result = new BigIntArray(original.Length); int i = 0; foreach (int c in original) { result.Add(i++, c); } return(result); }
static void Time1(int[][] array) { int iter = array.Length; BigIntArray bigArray = new BigIntArray(max); Thread[] threads = new Thread[iter]; RunnerThread2[] threadStates = new RunnerThread2[iter]; for (int i = 0; i < iter; ++i) { threadStates[i] = new RunnerThread2(array[i], bigArray); threads[i] = new Thread(new ThreadStart(threadStates[i].Run)); } foreach (Thread t in threads) { t.Start(); } }
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"); }
public void TestDefaultIntFacetIterator() { string format = "00"; List<IntFacetIterator> list = new List<IntFacetIterator>(); for (int seg = 0; seg < 5; seg++) { TermIntList tsl1 = new TermIntList(format); int limit = 25; BigIntArray count = new BigIntArray(limit); string[] terms = new string[limit]; for (int i = limit - 1; i >= 0; i--) { terms[i] = i.ToString(format); } Array.Sort(terms); for (int i = 0; i < limit; i++) { tsl1.Add(terms[i]); count.Add(i, i); } tsl1.Seal(); DefaultIntFacetIterator itr1 = new DefaultIntFacetIterator(tsl1, count, limit, true); list.Add(itr1); } CombinedIntFacetIterator ctr = new CombinedIntFacetIterator(list); string result = ""; while (ctr.HasNext()) { ctr.Next(); result += (ctr.Facet + ":" + ctr.Count + " "); } string expected = "1:5 2:10 3:15 4:20 5:25 6:30 7:35 8:40 9:45 10:50 11:55 12:60 13:65 14:70 15:75 16:80 17:85 18:90 19:95 20:100 21:105 22:110 23:115 24:120 "; Assert.AreEqual(expected, result); }
public RunnerThread2(int[] a, BigIntArray b) { array = a; bigarray = b; }
public static BigSegmentedArray FromArray(int[] original) { BigIntArray result = new BigIntArray(original.Length); int i = 0; foreach (int c in original) { result.Add(i++, c); } return result; }
public override void Load(BoboIndexReader reader) { int maxDoc = reader.MaxDoc; BigIntArray order = new BigIntArray(maxDoc); ITermValueList mterms = _termListFactory == null ? new TermStringList() : _termListFactory.CreateTermList(); List<int> minIDList = new List<int>(); List<int> maxIDList = new List<int>(); List<int> freqList = new List<int>(); TermDocs termDocs = null; TermEnum termEnum = null; int t = 0; // current term number mterms.Add(null); minIDList.Add(-1); maxIDList.Add(-1); freqList.Add(0); t++; try { termDocs = reader.TermDocs(); termEnum = reader.Terms(new Term(_indexFieldName, "")); do { if (termEnum == null) break; Term term = termEnum.Term; if (term == null || !_indexFieldName.Equals(term.Field)) break; // store term text // we expect that there is at most one term per document if (t > MAX_VAL_COUNT) { throw new IOException("maximum number of value cannot exceed: " + MAX_VAL_COUNT); } string val = term.Text; mterms.Add(val); int bit = (0x00000001 << (t - 1)); termDocs.Seek(termEnum); //freqList.add(termEnum.docFreq()); // removed because the df doesn't take into account the num of deletedDocs int df = 0; int minID = -1; int maxID = -1; if (termDocs.Next()) { df++; int docid = termDocs.Doc; order.Add(docid, order.Get(docid) | bit); minID = docid; while (termDocs.Next()) { df++; docid = termDocs.Doc; order.Add(docid, order.Get(docid) | bit); } maxID = docid; } freqList.Add(df); minIDList.Add(minID); maxIDList.Add(maxID); t++; } while (termEnum.Next()); } finally { try { if (termDocs != null) { termDocs.Dispose(); } } finally { if (termEnum != null) { termEnum.Dispose(); } } } mterms.Seal(); _dataCache = new FacetDataCache(order, mterms, freqList.ToArray(), minIDList.ToArray(), maxIDList.ToArray(), TermCountSize.Large); }