bleak.Data.InfiniteDataLoader
2.0.0
See the version list below for details.
dotnet add package bleak.Data.InfiniteDataLoader --version 2.0.0
NuGet\Install-Package bleak.Data.InfiniteDataLoader -Version 2.0.0
<PackageReference Include="bleak.Data.InfiniteDataLoader" Version="2.0.0" />
<PackageVersion Include="bleak.Data.InfiniteDataLoader" Version="2.0.0" />
<PackageReference Include="bleak.Data.InfiniteDataLoader" />
paket add bleak.Data.InfiniteDataLoader --version 2.0.0
#r "nuget: bleak.Data.InfiniteDataLoader, 2.0.0"
#:package bleak.Data.InfiniteDataLoader@2.0.0
#addin nuget:?package=bleak.Data.InfiniteDataLoader&version=2.0.0
#tool nuget:?package=bleak.Data.InfiniteDataLoader&version=2.0.0
bleak.Data.InfiniteDataLoader
Streaming CSV reader, writer and splitter, external sort, and merge join that work on files larger than RAM.
Forward-only, RFC 4180-aware CSV reading and writing with bounded memory, plus the building blocks for working with files that do not fit in RAM:
| Type | Purpose |
|---|---|
CsvReader |
Forward-only, quoted-field-aware reader. |
CsvWriter |
Writer with correct quoting/escaping. |
CsvSplitter |
Splits a huge file into parts by row count. |
ExternalSorter |
Disk-backed external merge sort on a key column. |
MergeJoin |
Streaming merge join of two key-sorted inputs. |
using bleak.Data.InfiniteDataLoader;
using var reader = new CsvReader("customers.csv"); // headers are read up front
int email = reader.IndexOf("email");
foreach (string[] row in reader.ReadRecords()) // one record at a time, bounded memory
{
Console.WriteLine(CsvWriter.FormatRecord(new[] { row[0], row[email] }));
}
Logging
Every entry point takes an optional logger as its last parameter. It defaults to null, which means
no logging. The library depends only on Microsoft.Extensions.Logging.Abstractions, so any provider works.
using Microsoft.Extensions.Logging;
ILoggerFactory loggerFactory = /* from DI, or LoggerFactory.Create(b => b.AddConsole()) */;
var split = CsvSplitter.Split("customers.csv", "out", rowsPerFile: 1_000_000, loggerFactory: loggerFactory);
var sorted = ExternalSorter.SortByLongKey(rows, r => long.Parse(r[0]),
logger: loggerFactory.CreateLogger(typeof(ExternalSorter)));
var joined = MergeJoin.OneToMany(customers, c => long.Parse(c[0]), orders, o => long.Parse(o[1]),
onOrphan: orphan => orphanCount++, // data callback, not logging
logger: loggerFactory.CreateLogger(typeof(MergeJoin)));
using var reader = new CsvReader("customers.csv", logger: loggerFactory.CreateLogger<CsvReader>());
Category (bleak.Data.InfiniteDataLoader.*) |
Parameter | Information | Debug | Trace |
|---|---|---|---|---|
ExternalSorter |
ILogger? logger |
sort started; sort completed (rows, chunks, bytes spilled, DurationMs, rec/s) |
temp directory; chunk-sort phase and merge phase finished, with DurationMs |
one line per spilled chunk (rows, bytes, sort/write ms) |
CsvSplitter |
ILoggerFactory? loggerFactory |
split started; split completed (files, rows, bytes, DurationMs, rec/s) |
input/output paths; one line per part file (rows, bytes, DurationMs) |
- |
MergeJoin |
ILogger? logger |
- | join summary: left rows / matched / without children, right rows / matched / orphans, DurationMs |
- |
CsvReader |
ILogger<CsvReader>? logger |
- | opened (column count); closed (rows, bytes read, DurationMs) |
- |
Warnings: CsvSplitter input with no data rows; ExternalSorter temp directory that could not be deleted.
Errors: a sort or split that throws is logged with the exception (and rethrown).
Event IDs: 1000-1099 CsvReader, 1200-1299 CsvSplitter, 1300-1399 ExternalSorter, 1400-1499 MergeJoin.
CsvWriter is a stateless formatter and does not log.
Notes for performance work:
- Nothing is ever logged per row. Messages use source-generated
[LoggerMessage]methods, so a disabled level costs nothing.CsvReaderonly counts rows while Debug is enabled. ExternalSorterandMergeJoinare lazy, so theirDurationMsis wall-clock time from the first record to the last. It includes producing their input and whatever the caller does between records. TheExternalSortermerge-phase Debug line splits that intoMergeMsandConsumerMs, and the chunk-sort Debug line reportsSortMsandWriteMs(the rest of that phase is time spent reading the input).
Data guarantee: at Debug and above, the library logs only metadata: counts, byte sizes, durations, file names and paths, and column counts. Field values, keys and record contents are never logged at any level.
Upgrading from 1.x
2.0.0 replaces the Action<string>? log callbacks with Microsoft.Extensions.Logging:
| 1.x | 2.0 |
|---|---|
CsvSplitter.Split(..., Action<string>? log = null) |
CsvSplitter.Split(..., ILoggerFactory? loggerFactory = null) |
ExternalSorter.SortByLongKey(..., Action<string>? log = null) |
ExternalSorter.SortByLongKey(..., ILogger? logger = null) |
ExternalSorter.SortByKey<TKey>(..., Action<string>? log = null) |
ExternalSorter.SortByKey<TKey>(..., ILogger? logger = null) |
ExternalSorter.SortByStringKey(..., Action<string>? log = null, IComparer<string>? comparer = null) |
ExternalSorter.SortByStringKey(..., IComparer<string>? comparer = null, ILogger? logger = null) |
MergeJoin.OneToMany and the CsvReader constructors gained an optional logger as their last parameter.
SortByKey, SortByLongKey and SortByStringKey now reject chunkSize <= 0 when called, not on first enumeration.
Install
dotnet add package bleak.Data.InfiniteDataLoader
License
The Unlicense (public domain).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.13)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on bleak.Data.InfiniteDataLoader:
| Package | Downloads |
|---|---|
|
bleak.Data.Transformer
Config-driven, streaming ETL engine: describe sources, joins, typed fields and transform pipelines in JSON and get JSONL out. |
|
|
bleak.Data.Anonymizer
Config-driven PII anonymizer for large delimited files: fake names, emails, phones, dates, addresses, GUIDs and more. |
GitHub repositories
This package is not used by any popular GitHub repositories.