Optimize structure
This commit is contained in:
@@ -69,14 +69,17 @@ public class FileInputService : IInputService
|
||||
{
|
||||
_logger.LogInformation("Reading file: {FileName}, table: {TableName}", info.FileName, info.TableName);
|
||||
using var source = _dataReaderFactory.CreateReader(info.FileName,info.TableName,info.Headers);
|
||||
|
||||
var count = 0;
|
||||
|
||||
while (await source.ReadAsync())
|
||||
{
|
||||
var record = source.Current;
|
||||
await _producerQueue.EnqueueAsync(record);
|
||||
count++;
|
||||
_context.AddInput();
|
||||
}
|
||||
|
||||
|
||||
_context.AddTableInput(info.TableName, count);
|
||||
_logger.LogInformation("Input of table: '{TableName}' finished", info.TableName);
|
||||
_dataInputOptions.Value.OnTableInputCompleted?.Invoke(info.TableName);
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ using MesETL.App.HostedServices.Abstractions;
|
||||
using MesETL.App.Options;
|
||||
using MesETL.App.Services;
|
||||
using MesETL.App.Services.ErrorRecorder;
|
||||
using MesETL.Shared.Helper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@@ -3,11 +3,12 @@ using MesETL.App.HostedServices.Abstractions;
|
||||
using MesETL.App.Options;
|
||||
using MesETL.App.Services;
|
||||
using MesETL.App.Services.ErrorRecorder;
|
||||
using MesETL.Shared.Helper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MySqlConnector;
|
||||
using MySqlDestination = MesETL.App.Services.ETL.MySqlDestination;
|
||||
using TaskExtensions = MesETL.App.Helpers.TaskExtensions;
|
||||
using TaskExtensions = MesETL.Shared.Helper.TaskExtensions;
|
||||
|
||||
namespace MesETL.App.HostedServices;
|
||||
|
||||
@@ -136,6 +137,7 @@ public class OutputService : IOutputService
|
||||
await output.FlushAsync(_outputOptions.Value.MaxAllowedPacket);
|
||||
foreach (var (key, value) in tableOutput)
|
||||
{
|
||||
_context.AddOutput(value);
|
||||
_context.AddTableOutput(key, value);
|
||||
}
|
||||
_logger.LogTrace("Flushed {Count} records", tableOutput.Values.Sum(i => i));
|
||||
|
@@ -107,24 +107,24 @@ public class TaskMonitorService
|
||||
});
|
||||
|
||||
var dict = _context.TableProgress
|
||||
.ToDictionary(kv => kv.Key, kv => kv.Value.ToString());
|
||||
logger.LogStatus("Monitor: Table output progress", dict, ITaskMonitorLogger.LogLevel.Progress);
|
||||
.ToDictionary(kv => kv.Key, kv => $"{kv.Value.input}/{kv.Value.output}");
|
||||
logger.LogStatus("Monitor: Table progress", dict, ITaskMonitorLogger.LogLevel.Progress);
|
||||
var sb = new StringBuilder("Table Progress: \n");
|
||||
foreach (var kv in _context.TableProgress)
|
||||
foreach (var kv in dict)
|
||||
{
|
||||
sb.AppendLine($"{kv.Key}: {kv.Value}");
|
||||
sb.Append(kv.Key).AppendLine(kv.Value);
|
||||
}
|
||||
|
||||
sb.AppendLine($"LongestCharCount: {_producerQueue.LongestFieldCharCount}");
|
||||
await File.WriteAllTextAsync(_outputPath, sb.ToString(), CancellationToken.None);
|
||||
|
||||
|
||||
logger.LogStatus("Monitor: Process count", new Dictionary<string, string>
|
||||
{
|
||||
{"Input", inputCount.ToString()},
|
||||
{"Transform", transformCount.ToString()},
|
||||
{"Output", outputCount.ToString()}
|
||||
}, ITaskMonitorLogger.LogLevel.Progress);
|
||||
// logger.LogStatus("Monitor: Process count", new Dictionary<string, string>
|
||||
// {
|
||||
// {"Input", inputCount.ToString()},
|
||||
// {"Transform", transformCount.ToString()},
|
||||
// {"Output", outputCount.ToString()}
|
||||
// }, ITaskMonitorLogger.LogLevel.Progress);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,7 +24,7 @@ public class VoidOutputService : IOutputService
|
||||
_logger.LogInformation("***** Void Output Service Started *****");
|
||||
while (!_context.IsTransformCompleted || _queuePool.Queues.Count > 0)
|
||||
{
|
||||
foreach (var pair in _queuePool.Queues) // 内存优化
|
||||
foreach (var pair in _queuePool.Queues)
|
||||
{
|
||||
if (_context.IsTransformCompleted && pair.Value.Count == 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user