修复错误的试运行模式

This commit is contained in:
陈梓阳 2025-01-24 16:46:57 +08:00
parent c049e092e4
commit ab9f7a8253
2 changed files with 20 additions and 7 deletions

View File

@ -65,7 +65,10 @@ public class FileInputService : IInputService
var file = Path.GetFileName(info.FileName);
_logger.LogInformation("正在读取文件:{FileName}, 对应的数据表:{TableName}", file, info.TableName);
using var source = _dataReaderFactory.CreateReader(info.FileName, info.TableName, info.Headers);
var count = 0;
var countBuffer = 0;
if (_dryRun && _context.TableProgress.GetValueOrDefault(info.TableName, (input: 0, output: 0)).input >= _dryRunCount)
continue;
while (await source.ReadAsync())
{
@ -78,13 +81,23 @@ public class FileInputService : IInputService
}
var record = source.Current;
await _producerQueue.EnqueueAsync(record);
count++;
countBuffer++;
_context.AddInput();
if (_dryRun && count >= _dryRunCount)
break;
// 避免影响性能每1000条更新一次表输入进度
if (countBuffer >= 1000)
{
_context.AddTableInput(info.TableName, countBuffer);
countBuffer = 0;
// 试运行模式下,超出了指定行数则停止输入
if (_dryRun && _context.TableProgress[info.TableName].input >= _dryRunCount)
{
break;
}
}
}
_context.AddTableInput(info.TableName, count);
_context.AddTableInput(info.TableName, countBuffer);
_logger.LogInformation("文件 {File} 输入完成", file);
_dataInputOptions.Value.OnTableInputCompleted?.Invoke(info.TableName);
}

View File

@ -2,7 +2,7 @@
"MemoryThreshold": 6,
"GCIntervalMilliseconds": -1,
"UnsafeVariable": true,
"DryRun": false, // 100000
"DryRun": true, // 100000
"Logging": {
"LogLevel": {
"Default": "Trace"
@ -27,7 +27,7 @@
"MaxAllowedPacket": 67108864,
"FlushCount": 10000, //
"MaxDatabaseOutputTask" : 4, //
"TreatJsonAsHex": false, // json16(0x)json
"TreatJsonAsHex": false, // 使Json"0x"
"NoOutput": [], //
"ForUpdate":
{