/// <summary> /// Returns a new log buffer which acts as a view onto the original buffer. /// If the original buffer already contains the desired column, then the original buffer is returned. /// If it does not, then an additional temporary buffer of equal length is created which /// holds data for the given <paramref name="columns"/> and the returned buffer combines both the /// <paramref name="that" /> as well as the temporary buffer into one view. /// </summary> /// <remarks> /// This method exists for those cases, where, in order to fulfill a certain <see cref="ILogSource.GetEntries(System.Collections.Generic.IReadOnlyList{LogLineIndex}, ILogBuffer, int, LogSourceQueryOptions)"/> /// request, one has to make certain to retrieve a particular column from the source. Nothing needs to be done /// if the caller is also interested in said column, however if the caller is not, then it becomes a one liner /// to create a combined buffer which acts as a proxy for the original for every column but the desired one, /// which is copied into an additional buffer. /// /// If it were permissible to query the source log file countless times, then this method wouldn't need to exist, /// however since we don't want to do exactly that, we'll have to do this procedure to improve performance, now /// that log files are streamed into memory on-demand. /// </remarks> /// <param name="that"></param> /// <param name="columns"></param> /// <returns></returns> public static ILogBuffer CreateViewWithAdditionalColumns(this ILogBuffer that, IReadOnlyList <IColumnDescriptor> columns) { if (columns.Count == 0) { return(that); } var missingColumns = columns.Except(that.Columns).ToList(); if (missingColumns.Count == 0) { return(that); } var temporaryBuffer = new LogBufferArray(that.Count, missingColumns); var combinedView = new CombinedLogBufferView(new[] { that, temporaryBuffer }); return(combinedView); }
public CombinedLogEntryView(CombinedLogBufferView buffer, int index) { _buffer = buffer; _index = index; }