public void TestWithRenumber(int count) { List <int> correctList = new List <int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(10000000)); } CustomSortHelper <int> items = new CustomSortHelper <int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int i = 0; i < Math.Min(count, 100); i++) { int adder = r.Next(10000000); correctList[i] += adder; items[i] += adder; correctList.Sort(); items.SortAssumingIncreased(i); for (int x = 0; x < count; x++) { if (correctList[x] != items[x]) { throw new Exception(); } } } }
public void TestWithRenumber(int count) { List<int> correctList = new List<int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(10000000)); } CustomSortHelper<int> items = new CustomSortHelper<int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int i = 0; i < Math.Min(count, 100); i++) { int adder = r.Next(10000000); correctList[i] += adder; items[i] += adder; correctList.Sort(); items.SortAssumingIncreased(i); for (int x = 0; x < count; x++) if (correctList[x] != items[x]) throw new Exception(); } }
public void Test(int count) { List<int> correctList = new List<int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(1000000000)); } CustomSortHelper<int> items = new CustomSortHelper<int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int x = 0; x < count; x++) if (correctList[x] != items[x]) throw new Exception(); }
public UnionReader(List <ArchiveTableSummary <TKey, TValue> > tables) { m_tablesOrigList = new List <BufferedArchiveStream <TKey, TValue> >(); foreach (var table in tables) { m_tablesOrigList.Add(new BufferedArchiveStream <TKey, TValue>(0, table)); } m_sortedArchiveStreams = new CustomSortHelper <BufferedArchiveStream <TKey, TValue> >(m_tablesOrigList, IsLessThan); m_readWhileUpperBounds.SetMin(); SeekToKey(m_readWhileUpperBounds); }
public void Test(int count) { List <int> correctList = new List <int>(); Random r = new Random(); for (int x = 0; x < count; x++) { correctList.Add(r.Next(1000000000)); } CustomSortHelper <int> items = new CustomSortHelper <int>(correctList, (x, y) => x.CompareTo(y) < 0); correctList.Sort(); for (int x = 0; x < count; x++) { if (correctList[x] != items[x]) { throw new Exception(); } } }
public SequentialReaderStream(ArchiveList <TKey, TValue> archiveList, SortedTreeEngineReaderOptions readerOptions = null, SeekFilterBase <TKey> keySeekFilter = null, MatchFilterBase <TKey, TValue> keyMatchFilter = null, WorkerThreadSynchronization workerThreadSynchronization = null) { if (readerOptions is null) { readerOptions = SortedTreeEngineReaderOptions.Default; } if (keySeekFilter is null) { keySeekFilter = new SeekFilterUniverse <TKey>(); } if (keyMatchFilter is null) { keyMatchFilter = new MatchFilterUniverse <TKey, TValue>(); } if (workerThreadSynchronization is null) { m_ownsWorkerThreadSynchronization = true; workerThreadSynchronization = new WorkerThreadSynchronization(); } m_workerThreadSynchronization = workerThreadSynchronization; m_pointCount = 0; m_keySeekFilter = keySeekFilter; m_keyMatchFilter = keyMatchFilter; m_keyMatchIsUniverse = m_keyMatchFilter as MatchFilterUniverse <TKey, TValue> != null; if (readerOptions.Timeout.Ticks > 0) { m_timeout = new TimeoutOperation(); m_timeout.RegisterTimeout(readerOptions.Timeout, () => m_timedOut = true); } m_snapshot = archiveList.CreateNewClientResources(); m_snapshot.UpdateSnapshot(); m_tablesOrigList = new List <BufferedArchiveStream <TKey, TValue> >(); for (int x = 0; x < m_snapshot.Tables.Count(); x++) { ArchiveTableSummary <TKey, TValue> table = m_snapshot.Tables[x]; if (table != null) { if (table.Contains(keySeekFilter.StartOfRange, keySeekFilter.EndOfRange)) { try { m_tablesOrigList.Add(new BufferedArchiveStream <TKey, TValue>(x, table)); } catch (Exception e) { //ToDo: Make sure firstkey.tostring doesn't ever throw an exception. StringBuilder sb = new StringBuilder(); sb.AppendLine($"Archive ID {table.FileId}"); sb.AppendLine($"First Key {table.FirstKey.ToString()}"); sb.AppendLine($"Last Key {table.LastKey.ToString()}"); sb.AppendLine($"File Size {table.SortedTreeTable.BaseFile.ArchiveSize}"); sb.AppendLine($"File Name {table.SortedTreeTable.BaseFile.FilePath}"); Log.Publish(MessageLevel.Error, "Error while reading file", sb.ToString(), null, e); } } else { m_snapshot.Tables[x] = null; } } } m_sortedArchiveStreams = new CustomSortHelper <BufferedArchiveStream <TKey, TValue> >(m_tablesOrigList, IsLessThan); m_keySeekFilter.Reset(); if (m_keySeekFilter.NextWindow()) { SeekToKey(m_keySeekFilter.StartOfFrame); } else { Dispose(); } }
public SequentialReaderStream(ArchiveList <TKey, TValue> archiveList, SortedTreeEngineReaderOptions readerOptions = null, SeekFilterBase <TKey> keySeekFilter = null, MatchFilterBase <TKey, TValue> keyMatchFilter = null, WorkerThreadSynchronization workerThreadSynchronization = null) { if (readerOptions == null) { readerOptions = SortedTreeEngineReaderOptions.Default; } if (keySeekFilter == null) { keySeekFilter = new SeekFilterUniverse <TKey>(); } if (keyMatchFilter == null) { keyMatchFilter = new MatchFilterUniverse <TKey, TValue>(); } if (workerThreadSynchronization == null) { m_ownsWorkerThreadSynchronization = true; workerThreadSynchronization = new WorkerThreadSynchronization(); } m_workerThreadSynchronization = workerThreadSynchronization; m_pointCount = 0; m_keySeekFilter = keySeekFilter; m_keyMatchFilter = keyMatchFilter; m_keyMatchIsUniverse = (m_keyMatchFilter as MatchFilterUniverse <TKey, TValue>) != null; if (readerOptions.Timeout.Ticks > 0) { m_timeout = new TimeoutOperation(); m_timeout.RegisterTimeout(readerOptions.Timeout, () => m_timedOut = true); } m_snapshot = archiveList.CreateNewClientResources(); m_snapshot.UpdateSnapshot(); m_tablesOrigList = new List <BufferedArchiveStream <TKey, TValue> >(); for (int x = 0; x < m_snapshot.Tables.Count(); x++) { ArchiveTableSummary <TKey, TValue> table = m_snapshot.Tables[x]; if (table != null) { if (table.Contains(keySeekFilter.StartOfRange, keySeekFilter.EndOfRange)) { m_tablesOrigList.Add(new BufferedArchiveStream <TKey, TValue>(x, table)); } else { m_snapshot.Tables[x] = null; } } } m_sortedArchiveStreams = new CustomSortHelper <BufferedArchiveStream <TKey, TValue> >(m_tablesOrigList, IsLessThan); m_keySeekFilter.Reset(); if (m_keySeekFilter.NextWindow()) { SeekToKey(m_keySeekFilter.StartOfFrame); } else { Dispose(); } }