/// <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); }
/// <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); } }
/// <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); }
/// <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); } }
/// <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); } }
/// <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); } }
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); }
/// <inheritdoc /> public void GetColumn <T>(IReadOnlyList <LogLineIndex> indices, ILogFileColumn <T> column, T[] buffer, int destinationIndex) { _buffer.GetColumn(indices, column, buffer, destinationIndex); }
/// <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); } }
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 }; }
/// <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); } }
/// <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); } }
/// <inheritdoc /> public override bool TryGetValue(ILogFileColumn column, out object value) { if (!_values.TryGetValue(column, out value)) { value = column.DefaultValue; return(false); } return(true); }
public ColumnData(ILogFileColumn <T> column, int length) { if (column == null) { throw new ArgumentNullException(nameof(column)); } _column = column; _data = new T[length]; }
public override T GetValue <T>(ILogFileColumn <T> column) { T value; if (!TryGetValue(column, out value)) { throw new ColumnNotRetrievedException(column); } return(value); }
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); } }
public override void SetValue(ILogFileColumn column, object value) { IColumnData data; if (!_buffer._dataByColumn.TryGetValue(column, out data)) { throw new ColumnNotRetrievedException(column); } data[_index] = value; }
protected AbstractLogColumnPresenter(ILogFileColumn <T> column) { if (column == null) { throw new ArgumentNullException(nameof(column)); } _column = column; _values = new List <AbstractLogEntryValuePresenter>(); ClipToBounds = true; }
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; }
/// <inheritdoc /> public override object GetValue(ILogFileColumn column) { object value; if (!TryGetValue(column, out value)) { throw new NoSuchColumnException(column); } return(value); }
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); } }
public override object GetValue(ILogFileColumn column) { object value; if (!TryGetValue(column, out value)) { throw new ColumnNotRetrievedException(column); } return(value); }
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); }
/// <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); }
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); }
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); }
/// <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); } }
/// <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); }
/// <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); } }
/// <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); }