QuadStore.SparqlServer 1.1.0

dotnet add package QuadStore.SparqlServer --version 1.1.0
                    
NuGet\Install-Package QuadStore.SparqlServer -Version 1.1.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="QuadStore.SparqlServer" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QuadStore.SparqlServer" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="QuadStore.SparqlServer" />
                    
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 QuadStore.SparqlServer --version 1.1.0
                    
#r "nuget: QuadStore.SparqlServer, 1.1.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 QuadStore.SparqlServer@1.1.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=QuadStore.SparqlServer&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=QuadStore.SparqlServer&version=1.1.0
                    
Install as a Cake Tool

โšก QuadStore

A blazingly fast, lightweight RDF quad store for .NET 10 โ€” minimal dependencies, pure performance.

Build Status Tests Passing .NET Version License

๐ŸŒŸ Why QuadStore?

โœจ Sub-microsecond queries โ€” Indexed lookups in <200ns (faster than most in-memory operations)
๐ŸŽฏ Batch load 1M triples in 3.65 seconds โ€” 274K triples/sec throughput
๐Ÿ“ฆ Lightweight โ€” TriG loading without need for external RDF libraries
๐Ÿ” SPARQL support โ€” Full graph pattern matching and variable binding
โœ… Well tested โ€” 200+ passing tests, W3C TriG compliance

๐Ÿš€ Quick Start

1) Use QuadStore through dotNetRDF + Leviathan

QuadStore is the core in-memory quad store. QuadStoreStorageProvider adapts it to the standard dotNetRDF storage interfaces. That means Leviathan can run SPARQL queries against your QuadStore data.

using TripleStore.Core;
using VDS.RDF.Query;
using VDS.RDF.Storage;

// 1) Define a tiny in-memory TriG document with two FOAF name triples.
const string trigContent = """
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

{
  <http://example.org/alice> foaf:name "Alice" .
  <http://example.org/bob> foaf:name "Bob" .
}
""";

// 2) Persist the TriG content to disk so the loader can read it from a file.
var dataFilePath = Path.Combine(AppContext.BaseDirectory, "data.trig");
File.WriteAllText(dataFilePath, trigContent);

// 3) Create/open the QuadStore data directory.
var storePath = Path.Combine(AppContext.BaseDirectory, "store-data");
using var store = new QuadStore(storePath);

// 4) Load TriG quads directly into QuadStore in a single pass.
var loader = new SinglePassTrigLoader(store);
loader.LoadFromFile(dataFilePath);

// 5) Wrap QuadStore with the dotNetRDF storage adapter so Leviathan can query it.
IStorageProvider provider = new QuadStoreStorageProvider(store);
var queryable = (IQueryableStorage)provider;

// 6) Run a SPARQL SELECT query through Leviathan.
var query = @"SELECT ?person ?name
WHERE {
    ?person <http://xmlns.com/foaf/0.1/name> ?name .
}";

var results = (SparqlResultSet)queryable.Query(query);

// 7) Print the SPARQL result rows.
Console.WriteLine("Leviathan query results:");
foreach (var row in results)
{
    Console.WriteLine($"{row["person"]} -> {row["name"]}");
}

2) Minimal ASP.NET endpoint (SPARQL Protocol style)

This example exposes a simple /sparql endpoint that accepts a SPARQL query and returns:

  • SPARQL JSON results for SELECT/ASK
  • Turtle for CONSTRUCT/DESCRIBE
using TripleStore.Core;
using VDS.RDF;
using VDS.RDF.Query;
using VDS.RDF.Storage;
using VDS.RDF.Writing;

var dataDir = args.Length > 0 ? args[0] : "./quadstore-data";
var qs = new QuadStore(dataDir);
var provider = new QuadStoreStorageProvider(qs);
var queryable = (IQueryableStorage)provider;

// ---------------------------------------------------------------------------
// Section B: Seed Data
// ---------------------------------------------------------------------------
// On first run (empty store), load a small set of FOAF triples so the sample
// can be queried immediately without manual data loading.

if (!qs.Query().Any())
{
    var seedTriG = """
        @prefix foaf: <http://xmlns.com/foaf/0.1/> .
        @prefix ex:   <http://example.org/> .

        {
          ex:alice foaf:name "Alice" ;
                   foaf:knows ex:bob .
          ex:bob   foaf:name "Bob" ;
                   foaf:knows ex:alice .
        }
        """;

    var loader = new SinglePassTrigLoader(qs);
    loader.LoadFromString(seedTriG);
    qs.SaveAll();
}

// ---------------------------------------------------------------------------
// Section C: Host Configuration
// ---------------------------------------------------------------------------
// Build the ASP.NET Core minimal API host and register QuadStore and its
// storage provider as singletons so they are available to the request pipeline.

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton(qs);
builder.Services.AddSingleton(provider);
builder.Services.AddSingleton<IQueryableStorage>(provider);

var app = builder.Build();

app.MapSparqlEndpoints();

// ---------------------------------------------------------------------------
// Section G: Shutdown
// ---------------------------------------------------------------------------
// Dispose the QuadStore when the application is stopping to release
// memory-mapped file handles cleanly.

app.Lifetime.ApplicationStopping.Register(() =>
{
    qs.Dispose();
});

app.Run();

โš ๏ธ Current Limitations

QuadStore + QuadStoreStorageProvider is intentionally append-only currently:

  • โŒ No graph deletion (DeleteGraph is not supported)
  • โŒ No triple removal in UpdateGraph (additions only)
  • โŒ No SPARQL Update (IUpdateableStorage.Update throws)
  • โ„น๏ธ Per-query in-memory snapshot for Leviathan queries (simple and correct, but can be slower on very large datasets)

๐Ÿ“Š Performance at a Glance

Query Performance (Latency)

Operation 10K Triples 100K Triples 1M Triples
Subject lookup <200ns <200ns <200ns
Predicate query 36ยตs 536ยตs 4.4ms
Object lookup <200ns <200ns <200ns
Graph filter 138ยตs 1.9ms 17.6ms
Multiple patterns 1.6ยตs 21ยตs 285ยตs
Full enumeration 852ยตs 7.9ms 80.3ms

Load Performance (Throughput)

Dataset Time Throughput
10K triples 370ms 27K/sec
100K triples 299ms 335K/sec
1M triples 3.65s 274K/sec

Benchmarks on Intel Core Ultra 7 265H, .NET 10.0. See detailed benchmark analysis for all metrics.

๐Ÿ› ๏ธ Installation

QuadStore is built for .NET 10.0 and ships as a library. Add it to your project:

# If published to NuGet (coming soon)
dotnet add package QuadStore.Core

For now, clone and reference locally:

git clone https://github.com/aabs/QuadStore.git
# Add project reference in your .csproj:
# <ProjectReference Include="path/to/src/TripleStore.Core/TripleStore.Core.csproj" />

Indexing Strategy

QuadStore maintains roaring bitmap indexes for fast intersection:

  • Subject index โ†’ O(1) lookup by URI
  • Predicate index โ†’ O(1) lookup by property
  • Object index โ†’ O(1) lookup by resource
  • Graph index โ†’ O(1) lookup by named graph

Multi-dimensional queries use two-pointer intersection over sorted result sets, keeping complex queries sub-millisecond even at scale.

๐Ÿ“š Documentation

๐Ÿ”ฌ Building & Testing

# Build
dotnet build -c Release

# Run all tests
dotnet test -c Release --nologo

# Run benchmarks
dotnet run -c Release --project benchmark/TripleStore.Benchmarks/TripleStore.Benchmarks.csproj

๐Ÿ’ญ Feedback & Contributing

Have ideas? Found a bug? Jump in!

All contributions welcome, from bug reports to performance improvements.

๐Ÿ“ License

MIT โ€” Use freely in commercial and personal projects.

Made with โšก for .NET developers who demand performance.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 74 3/15/2026
1.0.0 76 3/14/2026