public OldHistorianStream(string oldFileName) { m_key = new HistorianKey(); m_value = new HistorianValue(); m_archiveFile = new OldHistorianReader(); m_archiveFile.Open(oldFileName); m_enumerator = m_archiveFile.Read().GetEnumerator(); }
public static long ConvertVersion1FileHandleDuplicates(string oldFileName, string newFileName, EncodingDefinition compressionMethod, out long readTime, out long sortTime, out long writeTime) { if (!File.Exists(oldFileName)) { throw new ArgumentException("Old file does not exist", "oldFileName"); } if (File.Exists(newFileName)) { throw new ArgumentException("New file already exists", "newFileName"); } HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); long startTime; int count; // Derived SortedPointBuffer class increments EntryNumbers instead of removing duplicates SortedPointBuffer points; startTime = DateTime.UtcNow.Ticks; using (OldHistorianReader archiveFile = new OldHistorianReader()) { archiveFile.Open(oldFileName); count = archiveFile.PointsArchived; points = new SortedPointBuffer(count, false); foreach (OldHistorianReader.DataPoint point in archiveFile.Read()) { key.Timestamp = (ulong)point.Timestamp.Ticks; key.PointID = (ulong)point.PointID; value.Value1 = BitConvert.ToUInt64(point.Value); value.Value3 = (ulong)point.Flags; points.TryEnqueue(key, value); } } readTime = DateTime.UtcNow.Ticks - startTime; startTime = DateTime.UtcNow.Ticks; points.IsReadingMode = true; sortTime = DateTime.UtcNow.Ticks - startTime; startTime = DateTime.UtcNow.Ticks; SortedTreeFileSimpleWriter <HistorianKey, HistorianValue> .Create(Path.Combine(FilePath.GetDirectoryName(newFileName), FilePath.GetFileNameWithoutExtension(newFileName) + ".~d2i"), newFileName, 4096, null, compressionMethod, points); writeTime = DateTime.UtcNow.Ticks - startTime; return(count); }