优化性能

This commit is contained in:
2024-02-08 17:38:23 +08:00
parent 20cc78c667
commit 8db7c71170
10 changed files with 67 additions and 58 deletions

View File

@@ -17,7 +17,7 @@ public class DataRecordQueue : IDisposable
public event Action? OnRecordWrite;
public event Action? OnRecordRead;
public DataRecordQueue() : this(1000000) // 默认容量最大1M
public DataRecordQueue() : this(500_000) // 默认容量最大500K
{
}

View File

@@ -16,7 +16,6 @@ public class CsvReader : IDataReader
public DataRecord Current { get; protected set; } = null!;
public string[] Headers { get; }
public string? CurrentRaw { get; protected set; }
public string Delimiter { get; }
public char QuoteChar { get; }
@@ -50,10 +49,8 @@ public class CsvReader : IDataReader
if (string.IsNullOrWhiteSpace(str))
return false;
CurrentRaw = str;
var fields = ParseRow(str, QuoteChar, Delimiter);
Current = new DataRecord(fields, TableName, Headers){RawField = str};
Current = new DataRecord(fields, TableName, Headers);
return true;
}

View File

@@ -31,10 +31,8 @@ public class ZstReader : CsvReader
if (string.IsNullOrWhiteSpace(str))
return false;
CurrentRaw = str;
var fields = ParseRow(str, QuoteChar, Delimiter);
Current = new DataRecord(fields, TableName, Headers) {RawField = str};
Current = new DataRecord(fields, TableName, Headers);
return true;
}

View File

@@ -24,7 +24,7 @@ public class ErrorRecorder
Directory.CreateDirectory(outputDir);
var content = $"""
### {exception.Message}
{record.RawField}
{string.Join(',', record.Fields)}
""";
var path = Path.Combine(outputDir, $"{record.TableName}.errlog");
await File.AppendAllTextAsync(path, content);
@@ -57,7 +57,7 @@ public class ErrorRecorder
var content =
$"""
### {exception.Message}
{record.RawField}
{string.Join(',', record.Fields)}
""";
await writer.WriteLineAsync(content);
if (token.IsCancellationRequested)