Esempio n. 1
0
            protected void CopyDataToDestination(LogLineIndex[] sourceIndices, string[] lines, int linesRead)
            {
                // We allow users to quickly cancel read requests, for example because their
                // timeout was reached. When that's the case, then it's possible that we're already
                // trying to fulfill their request. If we were to still copy the data to the destination
                // buffer AFTER cancellation then we could get all kinds of weird race conditions and
                // most of all, break the user's expectation that the buffer must not be modified,
                // when the GetColumn / GetEntries call has returned!
                //
                // Therefore we sync the copy to the destination with the cancellation itself, so that
                // we can make sure that the above doesn't happen.
                lock (this)
                {
                    if (_destination == null)
                    {
                        Log.Debug("Read request cancelled in the mean time, skipping copy to destination buffer");
                        return;
                    }

                    _destination.CopyFrom(Core.Columns.RawContent, _destinationIndex, lines, 0, linesRead);
                    if (_destination.Contains(Core.Columns.Index))
                    {
                        _destination.CopyFrom(Core.Columns.Index, _destinationIndex, sourceIndices, 0, linesRead);
                    }
                }
            }
Esempio n. 2
0
        /// <inheritdoc />
        public void CopyFrom <T>(IColumnDescriptor <T> column, int destinationIndex, IReadOnlyList <T> source, int sourceIndex, int length)
        {
            if (!_columns.Contains(column))
            {
                throw new NoSuchColumnException(column);
            }

            _inner.CopyFrom(column, destinationIndex, source, sourceIndex, length);
        }
Esempio n. 3
0
 /// <inheritdoc />
 public override void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices, ILogBuffer destination, int destinationIndex, LogSourceQueryOptions queryOptions)
 {
     foreach (var column in destination.Columns)
     {
         destination.CopyFrom(column, destinationIndex, this, sourceIndices, queryOptions);
     }
 }
        public void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices,
                               ILogBuffer destination,
                               int destinationIndex,
                               LogSourceQueryOptions queryOptions)
        {
            var source = _source;

            if (source == null)
            {
                destination.FillDefault(destinationIndex, sourceIndices.Count);
                return;
            }

            source.GetEntries(sourceIndices, destination.Except(MaxAdornedColumns), destinationIndex, queryOptions);

            var augmentedColumns = FindAugmentedColumns(destination);

            if (augmentedColumns.Count == 0)
            {
                return;
            }

            if (destinationIndex != 0)
            {
                throw new NotImplementedException();
            }

            foreach (var column in augmentedColumns)
            {
                destination.CopyFrom(column, this, sourceIndices, queryOptions);
            }
        }
Esempio n. 5
0
        public bool TryRead(LogLineIndex sourceStartIndex, int count, ILogBuffer destination, int destinationIndex, bool requiresValidityCheck)
        {
            ++_numReads;
            _lastAccessTime = DateTime.UtcNow;

            var pageSourceIndex = sourceStartIndex - _section.Index;
            var range           = new Int32Range(pageSourceIndex, count);

            foreach (var column in _buffer.Columns)
            {
                if (destination.Contains(column))
                {
                    destination.CopyFrom(column, destinationIndex, _buffer, range);
                }
            }

            if (requiresValidityCheck)
            {
                if (_buffer.ContainsAnyDefault(Columns.Index, range))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 6
0
 /// <inheritdoc />
 public override void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices, ILogBuffer destination, int destinationIndex, LogSourceQueryOptions queryOptions)
 {
     // TODO: This can probably be optimized (why are we translating indices each time for every column?!
     foreach (var column in destination.Columns)
     {
         destination.CopyFrom(column, destinationIndex, this, sourceIndices, queryOptions);
     }
 }
Esempio n. 7
0
 /// <summary>
 ///     Copies the given *non-contiguous* segment of data from the given log file into this buffer in a contiguous block.
 /// </summary>
 /// <remarks>
 ///     This buffer must be large enough already to accomodate the data.
 /// </remarks>
 /// <param name="that"></param>
 /// <param name="column">The column to copy the data from the log file to this buffer</param>
 /// <param name="destinationIndex">The first index in this buffer to which the data from the given <paramref name="source" /> is copied</param>
 /// <param name="source">The log file from which data should be copied from</param>
 /// <param name="sourceIndices">The non-contiguous section of the log file from which to copy from (e.g. from index 5, 10 entries)</param>
 public static void CopyFrom(this ILogBuffer that,
                             IColumnDescriptor column,
                             int destinationIndex,
                             ILogSource source,
                             IReadOnlyList <LogLineIndex> sourceIndices)
 {
     that.CopyFrom(column, destinationIndex, source, sourceIndices, LogSourceQueryOptions.Default);
 }
Esempio n. 8
0
 /// <inheritdoc />
 public void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices, ILogBuffer destination, int destinationIndex, LogSourceQueryOptions queryOptions)
 {
     lock (_syncRoot)
     {
         foreach (var column in destination.Columns)
         {
             destination.CopyFrom(column, destinationIndex, _logBuffer, new Int32View(sourceIndices));
         }
     }
 }
Esempio n. 9
0
 /// <inheritdoc />
 public void GetEntries(LogSourceSection sourceSection, ILogBuffer destination, int destinationIndex, LogSourceQueryOptions queryOptions)
 {
     lock (_syncRoot)
     {
         foreach (var column in destination.Columns)
         {
             destination.CopyFrom(column, destinationIndex, _logBuffer, new Int32View(sourceSection));
         }
     }
 }
Esempio n. 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sourceIndices"></param>
 /// <param name="destination"></param>
 /// <param name="destinationIndex"></param>
 public void CopyTo(IReadOnlyList <int> sourceIndices, ILogBuffer destination, int destinationIndex)
 {
     foreach (var column in destination.Columns)
     {
         if (_dataByColumn.TryGetValue(column, out var data))
         {
             destination.CopyFrom(column, destinationIndex, this, sourceIndices);
         }
         else
         {
             destination.FillDefault(column, destinationIndex, sourceIndices.Count);
         }
     }
 }
Esempio n. 11
0
        /// <inheritdoc />
        public void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices,
                               ILogBuffer destination,
                               int destinationIndex,
                               LogSourceQueryOptions queryOptions)
        {
            var source = _source;

            if (source != null)
            {
                var columnsToCopy = new IColumnDescriptor[] { Core.Columns.Index, Core.Columns.RawContent };
                var tmp           = new LogBufferArray(sourceIndices.Count, columnsToCopy);
                source.GetEntries(sourceIndices, tmp, 0, queryOptions);

                foreach (var column in columnsToCopy)
                {
                    if (destination.Contains(column))
                    {
                        destination.CopyFrom(column, destinationIndex, tmp, new Int32Range(0, sourceIndices.Count));
                    }
                }

                for (var i = 0; i < sourceIndices.Count; ++i)
                {
                    var parsedLogEntry = _parser.Parse(tmp[i]);
                    if (parsedLogEntry != null)
                    {
                        destination[destinationIndex + i].CopyFrom(parsedLogEntry);
                    }
                    else
                    {
                        destination[destinationIndex + i].CopyFrom(_nothingParsed);
                    }
                }
            }
            else
            {
                destination.FillDefault(destinationIndex, sourceIndices.Count);
            }
        }
Esempio n. 12
0
        /// <inheritdoc />
        public override void GetEntries(IReadOnlyList <LogLineIndex> sourceIndices, ILogBuffer destination, int destinationIndex, LogSourceQueryOptions queryOptions)
        {
            if (IsDisposed)
            {
                destination.FillDefault(destinationIndex, sourceIndices.Count);
                return;
            }

            var  remainingColumns   = new List <IColumnDescriptor>();
            bool partiallyRetrieved = false;

            foreach (var column in destination.Columns)
            {
                if (_specialColumns.Contains(column))
                {
                    destination.CopyFrom(column, destinationIndex, this, sourceIndices, queryOptions);
                    partiallyRetrieved = true;
                }
                else
                {
                    remainingColumns.Add(column);
                }
            }

            if (remainingColumns.Count > 0)
            {
                if (partiallyRetrieved)
                {
                    var view = new LogBufferView(destination, remainingColumns);
                    _source.GetEntries(sourceIndices, view, destinationIndex, queryOptions);
                }
                else
                {
                    _source.GetEntries(sourceIndices, destination, destinationIndex, queryOptions);
                }
            }
        }
Esempio n. 13
0
 /// <summary>
 ///     Copies data from the given array into this buffer.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="section"></param>
 /// <param name="column">The column to copy data to</param>
 /// <param name="source">The source from which to copy data from</param>
 public static void CopyFrom <T>(this ILogBuffer section, IColumnDescriptor <T> column, T[] source)
 {
     section.CopyFrom(column, 0, source, 0, source.Length);
 }