FastIngest.Core 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FastIngest.Core --version 0.3.0
                    
NuGet\Install-Package FastIngest.Core -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FastIngest.Core" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastIngest.Core" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="FastIngest.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FastIngest.Core --version 0.3.0
                    
#r "nuget: FastIngest.Core, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FastIngest.Core@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FastIngest.Core&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=FastIngest.Core&version=0.3.0
                    
Install as a Cake Tool

FastIngest

CI/CD License: MIT NuGet

FastIngest is a high-throughput, constant-memory bulk ingestion pipeline for .NET (CSV, XLSX, and NDJSON/JSONL to PostgreSQL, SQL Server, MySQL, SQLite, MongoDB, Cosmos DB, and Elasticsearch). Designed for enterprise workloads processing millions of rows without memory spikes, FastIngest leverages zero-allocation streaming readers, concurrent producer-consumer bounded channels, fluent validation, and native database bulk protocols (such as PostgreSQL binary COPY, SQL Server SqlBulkCopy, and MongoDB unordered BulkWriteAsync).


Architecture Overview

FastIngest processes incoming tabular and line-delimited data using a decoupled producer-consumer pipeline that keeps memory usage constant ($O(1)$) regardless of file size:

Stream (CSV / XLSX / JSONL / NDJSON)
        │
        ▼
┌─────────────────────────────────┐
│ Producer: Streaming Reader      │  <-- Sylvan CSV or PipeReader JSON Lines (CPU)
└──────────────┬──────────────────┘
               │
               ▼
┌─────────────────────────────────┐
│ Producer: Expression / Utf8 JSON│  <-- Zero-reflection binders or Utf8JsonReader
└──────────────┬──────────────────┘
               │
               ▼
┌─────────────────────────────────┐
│ Producer: FluentValidation      │  <-- FailFast or CollectAndContinue
└──────────────┬──────────────────┘
               │
               ▼
┌─────────────────────────────────┐
│ System.Threading.Channels       │  <-- Bounded channel (Capacity: 2 batches)
│ (BoundedChannelFullMode.Wait)   │  <-- Backpressure: strict O(1) memory
└──────────────┬──────────────────┘
               │
               ▼
┌─────────────────────────────────┐
│ Consumer: Native Database Sink  │  <-- High-throughput batch streaming (I/O)
└─────────────────────────────────┘

Key Features

  • Concurrent Producer-Consumer Pipelining: Decouples CPU parsing/validation from database I/O socket operations using bounded System.Threading.Channels with backpressure.
  • Constant-Memory Streaming: Stream arbitrarily large files (gigabytes to tens of gigabytes) with strict $O(1)$ memory guarantees.
  • Line-Delimited JSON (NDJSON / JSONL): High-speed streaming parser over System.IO.Pipelines.PipeReader and System.Text.Json.Utf8JsonReader with automatic format heuristics (.jsonl, .ndjson, or { content peeking).
  • 7 Native Database Sinks: Direct bulk protocol integrations for PostgreSQL (COPY), SQL Server (SqlBulkCopy), MySQL (MySqlBulkCopy), SQLite (WAL), MongoDB (BulkWriteAsync), Azure Cosmos DB, and Elasticsearch.
  • Validation Strategies:
    • FailFast: Immediately halts ingestion on the first invalid record.
    • CollectAndContinue: Collects invalid row details and exports an error report CSV while allowing valid records to proceed.
  • Fluent Pipeline API: Composable, chainable pipeline configuration with channel capacity tuning (WithChannelCapacity), custom JSON serializer options (WithJsonOptions), and progress tracking.
  • SemVer 2.0 Driven by Git Tags: Automated versioning via MinVer and seamless CI/CD publishing.

Quickstart

1. Installation

dotnet add package FastIngest.Core
dotnet add package FastIngest.PostgreSql

2. Define Record & Validator

using FluentValidation;

public record CustomerRecord(int Id, string Email, string FullName, decimal Balance);

public class CustomerValidator : AbstractValidator<CustomerRecord>
{
    public CustomerValidator()
    {
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
        RuleFor(x => x.FullName).NotEmpty().MaximumLength(100);
        RuleFor(x => x.Balance).GreaterThanOrEqualTo(0);
    }
}

3. Run Pipeline with PostgreSQL COPY

using FastIngest.Core.Common;
using FastIngest.Core.Pipeline;
using FastIngest.PostgreSql.Extensions;
using Npgsql;

await using var stream = File.OpenRead("large_customers.csv");
await using var connection = new NpgsqlConnection("Host=localhost;Database=mydb;Username=postgres;Password=secret");
await connection.OpenAsync();

var result = await FastIngestPipeline<CustomerRecord>.Create()
    .FromStream(stream, FileType.Csv)
    .WithMapping(mapping =>
    {
        mapping.Map(x => x.Id, "customer_id");
        mapping.Map(x => x.Email, "email");
        mapping.Map(x => x.FullName, "full_name");
        mapping.Map(x => x.Balance, "balance");
    })
    .ValidateWith<CustomerValidator>(options =>
    {
        options.ErrorStrategy = ErrorStrategy.CollectAndContinue;
    })
    .WithBatchSize(5000)
    .WithChannelCapacity(2)
    .OnProgress(progress =>
    {
        Console.WriteLine($"Processed {progress.RowsProcessed} rows ({progress.PercentComplete:F1}%)...");
    })
    .WriteToPostgresAsync(connection, "customers", CancellationToken.None);

Console.WriteLine($"Ingestion Complete! Succeeded: {result.TotalSucceeded}, Failed: {result.TotalFailed}");

if (!result.IsSuccess)
{
    var errorCsv = result.ExportErrorsToCsv();
    await File.WriteAllBytesAsync("ingest_errors.csv", errorCsv);
}

4. Stream Line-Delimited JSON (NDJSON / JSONL)

FastIngest natively streams .jsonl / .ndjson files without loading the entire document into RAM:

await using var jsonlStream = File.OpenRead("customers.jsonl");

var jsonlResult = await FastIngestPipeline<CustomerRecord>.Create()
    .FromStream(jsonlStream, FileType.JsonLines) // Or FileType.Ndjson
    .WithJsonOptions(opt => opt.PropertyNameCaseInsensitive = true)
    .ValidateWith<CustomerValidator>(opt => opt.ErrorStrategy = ErrorStrategy.CollectAndContinue)
    .WithBatchSize(5000)
    .WriteToPostgresAsync(connection, "customers");

Performance Benchmarks

Official BenchmarkDotNet suite results comparing FastIngest streaming binary COPY against Entity Framework Core 9 (net9.0, Apple M4, PostgreSQL 16 Alpine via Testcontainers):

Method RowCount Mean Ratio Gen 0 Gen 1 Gen 2 Allocated Alloc Ratio
FastIngest_Pipeline 25,000 143.2 ms 0.14 (7.2x faster) 2,000 1,000 - 18.64 MB 0.08 (-92%)
EfCore_Naive (Baseline) 25,000 1,029.0 ms 1.00 25,000 9,000 2,000 222.15 MB 1.00
EfCore_Batched (1k) 25,000 1,190.8 ms 1.16 26,000 12,000 3,000 210.10 MB 0.95
FastIngest_Pipeline 100,000 439.6 ms 0.16 (6.1x faster) 10,000 4,000 1,000 73.59 MB 0.08 (-92%)
EfCore_Batched (1k) 100,000 2,442.1 ms 0.91 107,000 53,000 17,000 825.17 MB 0.94
EfCore_Naive (Baseline) 100,000 2,691.6 ms 1.00 95,000 32,000 3,000 876.09 MB 1.00

Run the benchmarks yourself with ./benchmarks/run-benchmarks.sh. See full analysis in docs/benchmarks/performance.md.


Repository Structure

├── .github/workflows/ci.yml       # GitHub Actions CI/CD Pipeline
├── Directory.Build.props          # Centralized MSBuild & MinVer configuration
├── FastIngest.sln
├── benchmarks/
│   └── FastIngest.Benchmarks/     # BenchmarkDotNet performance suite
├── docs/                          # VitePress documentation website
├── src/
│   ├── FastIngest.Core/           # Core pipeline, channels, binders, CSV & NDJSON/JSONL streaming readers
│   ├── FastIngest.PostgreSql/     # PostgreSQL native binary COPY sink
│   ├── FastIngest.SqlServer/      # Microsoft SQL Server SqlBulkCopy sink
│   ├── FastIngest.MySql/          # MySQL MySqlBulkCopy sink
│   ├── FastIngest.Sqlite/         # SQLite WAL batch sink
│   ├── FastIngest.MongoDb/        # MongoDB unordered BulkWrite sink
│   ├── FastIngest.CosmosDb/       # Azure Cosmos DB bulk executor sink
│   ├── FastIngest.Elasticsearch/  # Elasticsearch BulkAsync sink
│   └── FastIngest.Extensions.DependencyInjection/ # Engine, DI, and profile registry
├── samples/
│   └── FastIngest.SampleApi/      # Minimal Web API demonstrating ingestion
└── tests/
    └── FastIngest.Tests/          # Unit and integration test suites

License

This project is licensed under the MIT License - see the LICENSE file for details.

Developed & Maintained by Paul Abib Camano (Aebibtech).

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on FastIngest.Core:

Package Downloads
FastIngest.SqlServer

SQL Server bulk copy ingestion sink for FastIngest using high-performance SqlBulkCopy.

FastIngest.Elasticsearch

Elasticsearch bulk indexing sink for FastIngest using Elastic.Clients.Elasticsearch.

FastIngest.MySql

MySQL bulk copy ingestion sink for FastIngest using high-performance MySqlBulkCopy.

FastIngest.Sqlite

SQLite batch transaction ingestion sink for FastIngest using prepared statements.

FastIngest.PostgreSql

PostgreSQL bulk copy ingestion sink for FastIngest using high-performance Npgsql binary COPY.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 203 10/1/2026
0.4.0 180 10/1/2026
0.3.2 180 9/26/2026
0.3.1 185 9/25/2026
0.3.0 185 9/25/2026
0.2.0 193 9/24/2026
0.1.1 178 9/24/2026
0.1.0 186 9/24/2026