コード例 #1
0
 /// <summary>
 ///     Retrieves a list of cells for a given column from this log file.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="logFile"></param>
 /// <param name="section"></param>
 /// <param name="column"></param>
 /// <param name="buffer"></param>
 public static void GetColumn <T>(this ILogFile logFile,
                                  LogFileSection section,
                                  ILogFileColumn <T> column,
                                  T[] buffer)
 {
     logFile.GetColumn(section, column, buffer, 0);
 }
コード例 #2
0
ファイル: LogEntryList.cs プロジェクト: tr00p3r/Tailviewer
        /// <inheritdoc />
        public void CopyTo <T>(ILogFileColumn <T> column, int sourceIndex, T[] destination, int destinationIndex, int length)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + length > destination.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            IColumnData data;

            if (_dataByColumn.TryGetValue(column, out data))
            {
                ((ColumnData <T>)data).CopyTo(sourceIndex, destination, destinationIndex, length);
            }
            else
            {
                throw new NoSuchColumnException(column);
            }
        }
コード例 #3
0
 /// <summary>
 ///     Retrieves a list of cells for a given column from this log file.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="logFile"></param>
 /// <param name="indices"></param>
 /// <param name="column"></param>
 /// <param name="buffer"></param>
 public static void GetColumn <T>(this ILogFile logFile,
                                  IReadOnlyList <LogLineIndex> indices,
                                  ILogFileColumn <T> column,
                                  T[] buffer)
 {
     logFile.GetColumn(indices, column, buffer, 0);
 }
コード例 #4
0
        /// <inheritdoc />
        public void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (indices == null)
            {
                throw new ArgumentNullException(nameof(indices));
            }
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + indices.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            try
            {
                _logFile.GetColumn(indices, column, buffer, destinationIndex);
            }
            catch (Exception e)
            {
                BlameExceptionOnPlugin(e);
            }
        }
コード例 #5
0
        /// <inheritdoc />
        public void CopyTo <T>(ILogFileColumn <T> column, IReadOnlyList <int> sourceIndices, T[] destination, int destinationIndex)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (sourceIndices == null)
            {
                throw new ArgumentNullException(nameof(sourceIndices));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            IColumnData columnData;

            if (_dataByColumn.TryGetValue(column, out columnData))
            {
                ((ColumnData <T>)columnData).CopyTo(sourceIndices, destination, destinationIndex);
            }
            else
            {
                throw new NoSuchColumnException(column);
            }
        }
コード例 #6
0
ファイル: LogFileProxy.cs プロジェクト: radtek/Tailviewer
        /// <inheritdoc />
        public void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (indices == null)
            {
                throw new ArgumentNullException(nameof(indices));
            }
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + indices.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            ILogFile logFile = _innerLogFile;

            if (logFile != null)
            {
                logFile.GetColumn(indices, column, buffer, destinationIndex);
            }
            else
            {
                buffer.Fill(column.DefaultValue, destinationIndex, indices.Count);
            }
        }
コード例 #7
0
        private static IReadOnlyList <MergedLogFileSection> GetEntries(
            IEnumerable <MergedLogFilePendingModification> pendingModifications)
        {
            var columns = new ILogFileColumn[]
            {
                LogFileColumns.Index,
                LogFileColumns.LogEntryIndex,
                LogFileColumns.Timestamp
            };

            var sections = new List <MergedLogFileSection>();

            foreach (var pendingModification in pendingModifications)
            {
                var logFile = pendingModification.LogFile;
                var section = pendingModification.Section;
                if (!section.IsInvalidate &&
                    !section.IsReset)
                {
                    var entries = logFile.GetEntries(section, columns);
                    sections.Add(new MergedLogFileSection(logFile, section, entries));
                }
                else
                {
                    sections.Add(new MergedLogFileSection(logFile, section));
                }
            }

            return(sections);
        }
コード例 #8
0
 /// <inheritdoc />
 public void GetColumn <T>(IReadOnlyList <LogLineIndex> indices,
                           ILogFileColumn <T> column,
                           T[] buffer,
                           int destinationIndex)
 {
     _buffer.GetColumn(indices, column, buffer, destinationIndex);
 }
コード例 #9
0
        /// <inheritdoc />
        public override void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (indices == null)
            {
                throw new ArgumentNullException(nameof(indices));
            }
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + indices.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            if (!TryGetSpecialColumn(indices, column, buffer, destinationIndex))
            {
                _source.GetColumn(indices, column, buffer, destinationIndex);
            }
        }
コード例 #10
0
        static LogFileColumns()
        {
            RawContent             = new WellKnownLogFileColumn <string>("raw_content");
            Index                  = new WellKnownLogFileColumn <LogLineIndex>("index", LogLineIndex.Invalid);
            OriginalIndex          = new WellKnownLogFileColumn <LogLineIndex>("original_index", LogLineIndex.Invalid);
            LogEntryIndex          = new WellKnownLogFileColumn <LogEntryIndex>("log_entry_index", Tailviewer.LogEntryIndex.Invalid);
            LineNumber             = new WellKnownLogFileColumn <int>("line_number");
            OriginalLineNumber     = new WellKnownLogFileColumn <int>("original_line_number");
            OriginalDataSourceName = new WellKnownLogFileColumn <string>("original_data_source_name");
            LogLevel               = new WellKnownLogFileColumn <LevelFlags>("log_level");
            Timestamp              = new WellKnownLogFileColumn <DateTime?>("timestamp");
            ElapsedTime            = new WellKnownLogFileColumn <TimeSpan?>("elapsed_time");
            DeltaTime              = new WellKnownLogFileColumn <TimeSpan?>("delta_time");
            Message                = new WellKnownLogFileColumn <string>("message");

            RawContentMaxPresentationWidth = new WellKnownLogFileColumn <float>("raw_content_max_presentation_width");
            PresentationStartingLineNumber = new WellKnownLogFileColumn <int>("presentation_line_number");
            PresentationLineCount          = new WellKnownLogFileColumn <int>("presentation_line_count");

            Minimum = new ILogFileColumn[]
            {
                RawContent,
                Index,
                OriginalIndex,
                LogEntryIndex,
                LineNumber,
                OriginalLineNumber,
                LogLevel,
                Timestamp,
                ElapsedTime,
                DeltaTime
            };
        }
コード例 #11
0
        /// <inheritdoc />
        public override void GetColumn <T>(LogFileSection section, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + section.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            if (Equals(column, LogFileColumns.Timestamp))
            {
                var firstLineIndices = GetFirstLineIndices(section);
                _source.GetColumn(firstLineIndices, column, buffer, destinationIndex);
            }
            else
            {
                _source.GetColumn(section, column, buffer, destinationIndex);
            }
        }
コード例 #12
0
ファイル: LogEntryList.cs プロジェクト: tr00p3r/Tailviewer
        /// <inheritdoc />
        public void CopyTo <T>(ILogFileColumn <T> column, IReadOnlyList <int> sourceIndices, T[] destination, int destinationIndex)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (sourceIndices == null)
            {
                throw new ArgumentNullException(nameof(sourceIndices));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (destinationIndex + sourceIndices.Count > destination.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            IColumnData data;

            if (_dataByColumn.TryGetValue(column, out data))
            {
                ((ColumnData <T>)data).CopyTo(sourceIndices, destination, destinationIndex);
            }
            else
            {
                throw new NoSuchColumnException(column);
            }
        }
コード例 #13
0
        /// <inheritdoc />
        public override bool TryGetValue(ILogFileColumn column, out object value)
        {
            if (!_values.TryGetValue(column, out value))
            {
                value = column.DefaultValue;
                return(false);
            }

            return(true);
        }
コード例 #14
0
            public ColumnData(ILogFileColumn <T> column, int length)
            {
                if (column == null)
                {
                    throw new ArgumentNullException(nameof(column));
                }

                _column = column;
                _data   = new T[length];
            }
コード例 #15
0
            public override T GetValue <T>(ILogFileColumn <T> column)
            {
                T value;

                if (!TryGetValue(column, out value))
                {
                    throw new ColumnNotRetrievedException(column);
                }

                return(value);
            }
コード例 #16
0
 public override void GetColumn <T>(LogFileSection section, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
 {
     if (IsIndexedColumn(column))
     {
         _indices.CopyTo(column, (int)section.Index, buffer, destinationIndex, section.Count);
     }
     else
     {
         _source.GetColumn(section, column, buffer, destinationIndex);
     }
 }
コード例 #17
0
            public override void SetValue(ILogFileColumn column, object value)
            {
                IColumnData data;

                if (!_buffer._dataByColumn.TryGetValue(column, out data))
                {
                    throw new ColumnNotRetrievedException(column);
                }

                data[_index] = value;
            }
コード例 #18
0
        protected AbstractLogColumnPresenter(ILogFileColumn <T> column)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }

            _column      = column;
            _values      = new List <AbstractLogEntryValuePresenter>();
            ClipToBounds = true;
        }
コード例 #19
0
            public override void SetValue <T>(ILogFileColumn <T> column, T value)
            {
                IColumnData data;

                if (!_buffer._dataByColumn.TryGetValue(column, out data))
                {
                    throw new ColumnNotRetrievedException(column);
                }

                ((ColumnData <T>)data)[_index] = value;
            }
コード例 #20
0
        /// <inheritdoc />
        public override object GetValue(ILogFileColumn column)
        {
            object value;

            if (!TryGetValue(column, out value))
            {
                throw new NoSuchColumnException(column);
            }

            return(value);
        }
コード例 #21
0
 public override void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
 {
     if (IsIndexedColumn(column))
     {
         _indices.CopyTo(column, new Int32View(indices), buffer, destinationIndex);
     }
     else
     {
         _source.GetColumn(indices, column, buffer, destinationIndex);
     }
 }
コード例 #22
0
            public override object GetValue(ILogFileColumn column)
            {
                object value;

                if (!TryGetValue(column, out value))
                {
                    throw new ColumnNotRetrievedException(column);
                }

                return(value);
            }
コード例 #23
0
        private AbstractLogColumnPresenter CreatePresenterFor(ILogFileColumn column)
        {
            if (_columnPresenterFactories.TryGetValue(column, out var factory))
            {
                return(factory(_textSettings));
            }

            var columnPresenterType = typeof(AnyColumnPresenter <>).MakeGenericType(column.DataType);
            var presenter           = (AbstractLogColumnPresenter)Activator.CreateInstance(columnPresenterType, new object[] { column, _textSettings });

            return(presenter);
        }
コード例 #24
0
        /// <inheritdoc />
        public override bool TryGetValue <T>(ILogFileColumn <T> column, out T value)
        {
            object tmp;

            if (!TryGetValue(column, out tmp))
            {
                value = column.DefaultValue;
                return(false);
            }

            value = (T)tmp;
            return(true);
        }
コード例 #25
0
            public override bool TryGetValue(ILogFileColumn column, out object value)
            {
                IColumnData data;

                if (!_buffer._dataByColumn.TryGetValue(column, out data))
                {
                    value = column.DefaultValue;
                    return(false);
                }

                value = data[_index];
                return(true);
            }
コード例 #26
0
            public override bool TryGetValue <T>(ILogFileColumn <T> column, out T value)
            {
                IColumnData data;

                if (!_buffer._dataByColumn.TryGetValue(column, out data))
                {
                    value = column.DefaultValue;
                    return(false);
                }

                value = ((ColumnData <T>)data)[_index];
                return(true);
            }
コード例 #27
0
ファイル: MergedLogFile.cs プロジェクト: radtek/Tailviewer
        /// <inheritdoc />
        public override void GetColumn <T>(LogFileSection section, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + section.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            if (Equals(column, LogFileColumns.DeltaTime))
            {
                GetDeltaTime(section, (TimeSpan?[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.Index) ||
                     Equals(column, LogFileColumns.OriginalIndex))
            {
                _index.GetLogLineIndices(section, (LogLineIndex[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.LogEntryIndex))
            {
                _index.GetLogEntryIndices(section, (LogEntryIndex[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.LineNumber) ||
                     Equals(column, LogFileColumns.OriginalLineNumber))
            {
                _index.GetLineNumbers(section, (int[])(object)buffer, destinationIndex);
            }
            else
            {
                // We want to minimize the amount of GetColumn calls to our source files.
                // The best we can achieve is up to one call per source, which is what the following
                // code achieves:
                // At first, we want to build the list of indices we need to retrieve per source
                var sourceIndices = _index.GetOriginalLogLineIndices <T>(section);
                // Then we want to retrieve the column values per source
                GetSourceColumnValues(column, sourceIndices);
                // And finally we want to copy those column values back to the destination
                // buffer IN THEIR CORRECT ORDER.
                CopyColumnValuesToBuffer(sourceIndices, buffer, destinationIndex);
            }
        }
コード例 #28
0
        /// <summary>
        /// Returns an enumeration which iterates over all values in the given column.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="column"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">When this buffer doesn't hold the given column</exception>
        /// <exception cref="ArgumentNullException">When <paramref name="column"/> is null</exception>
        public IEnumerable <T> Column <T>(ILogFileColumn <T> column)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }

            if (!_dataByColumn.TryGetValue(column, out var data))
            {
                throw new ArgumentException(string.Format("No such column: {0}", column));
            }

            return((ColumnData <T>)data);
        }
コード例 #29
0
ファイル: MergedLogFile.cs プロジェクト: radtek/Tailviewer
        /// <inheritdoc />
        public override void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex)
        {
            if (indices == null)
            {
                throw new ArgumentNullException(nameof(indices));
            }
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (destinationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(destinationIndex));
            }
            if (destinationIndex + indices.Count > buffer.Length)
            {
                throw new ArgumentException("The given buffer must have an equal or greater length than destinationIndex+length");
            }

            if (Equals(column, LogFileColumns.DeltaTime))
            {
                GetDeltaTime(indices, (TimeSpan?[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.Index) ||
                     Equals(column, LogFileColumns.OriginalIndex))
            {
                _index.GetLogLineIndices(indices, (LogLineIndex[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.LogEntryIndex))
            {
                _index.GetLogEntryIndices(indices, (LogEntryIndex[])(object)buffer, destinationIndex);
            }
            else if (Equals(column, LogFileColumns.LineNumber) ||
                     Equals(column, LogFileColumns.OriginalLineNumber))
            {
                _index.GetLineNumbers(indices, (int[])(object)buffer, destinationIndex);
            }
            else
            {
                var sourceIndices = _index.GetOriginalLogLineIndices <T>(indices);
                GetSourceColumnValues(column, sourceIndices);
                CopyColumnValuesToBuffer(sourceIndices, buffer, destinationIndex);
            }
        }
コード例 #30
0
        /// <inheritdoc />
        public void FillDefault(ILogFileColumn column, int destinationIndex, int length)
        {
            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }

            IColumnData columnData;

            if (!_dataByColumn.TryGetValue(column, out columnData))
            {
                throw new NoSuchColumnException(column);
            }

            columnData.FillDefault(destinationIndex, length);
        }