예제 #1
0
        void InsertItems(IngestionIndex index, IEnumerable <IngestionItem> items, bool dryRun, bool resetIndex = false)
        {
            int      totalItems    = 0;
            TimeSpan totalDuration = default;
            long     totalSize     = 0;

            IEnumerable <IngestionItem> YieldAndLog()
            {
                foreach (var item in items)
                {
                    Log.Information(
                        "[{TotalItems}] {FilePath} {Duration} @ {Timestamp}",
                        ++totalItems,
                        item.FilePath,
                        item.Duration,
                        item.Timestamp);

                    if (item.Duration.HasValue)
                    {
                        totalDuration += item.Duration.Value;
                    }

                    if (item.FileSize.HasValue)
                    {
                        totalSize += item.FileSize.Value;
                    }

                    yield return(item);
                }
            }

            if (dryRun)
            {
                var enumerator = YieldAndLog().GetEnumerator();
                while (enumerator.MoveNext())
                {
                    ;
                }
            }
            else
            {
                if (resetIndex)
                {
                    index.Reset();
                }
                index.Insert(YieldAndLog());
            }

            Log.Information("Count = {TotalItems}", totalItems);
            Log.Information("Duration = {TotalDuration}", totalDuration);
            Log.Information("Size = {TotalSize} GB", totalSize / 1024.0 / 1024.0 / 1024.0);
        }
예제 #2
0
            protected override int Invoke(ProjectInfo project, IngestionIndex index)
            {
                int      totalItems    = 0;
                TimeSpan totalDuration = default;
                long     totalSize     = 0;

                IEnumerable <IngestionItem> YieldAndLog()
                {
                    foreach (var item in Ingestion.EnumerateIngestionFiles(project, parseMetadataFromFile: !NoMetadata))
                    {
                        Log.Information(
                            "[{TotalItems}] {FilePath} {Duration} @ {Timestamp}",
                            ++totalItems,
                            item.FilePath,
                            item.Duration,
                            item.Timestamp);

                        if (item.Duration.HasValue)
                        {
                            totalDuration += item.Duration.Value;
                        }

                        if (item.FileSize.HasValue)
                        {
                            totalSize += item.FileSize.Value;
                        }

                        yield return(item);
                    }
                }

                if (DryRun)
                {
                    var enumerator = YieldAndLog().GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        ;
                    }
                }
                else
                {
                    index.Reset();
                    index.Insert(YieldAndLog());
                }

                Log.Information("Count = {TotalItems}", totalItems);
                Log.Information("Duration = {TotalDuration}", totalDuration);
                Log.Information("Size = {TotalSize} GB", totalSize / 1024.0 / 1024.0 / 1024.0);

                return(0);
            }
예제 #3
0
 protected override int Invoke(ProjectInfo project, IngestionIndex index)
 {
     index.Insert(Ingestion.EnumerateIngestionFiles(project, InputFiles));
     return(0);
 }