1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
//! # OxiRS Core - RDF and SPARQL Foundation
//!
//! [](https://github.com/cool-japan/oxirs/releases)
//! [](https://docs.rs/oxirs-core)
//!
//! **Status**: Production Release (v0.2.4)
//! **Stability**: Public APIs are stabilizing. Production-ready for RDF/SPARQL core operations.
//!
//! ## Overview
//!
//! `oxirs-core` is a high-performance, zero-dependency Rust-native RDF data model and SPARQL foundation
//! for the OxiRS semantic web platform. It provides the fundamental types, traits, and operations that
//! all other OxiRS crates build upon.
//!
//! This crate is designed for:
//! - Building semantic web applications in Rust
//! - Processing large-scale knowledge graphs with minimal memory overhead
//! - Developing SPARQL query engines and triple stores
//! - Creating RDF-based data pipelines and transformations
//!
//! ## Key Features
//!
//! ### Core RDF Support
//! - **RDF 1.2 Compliance** - Full implementation of the RDF 1.2 data model
//! - **Multiple Serialization Formats** - Support for Turtle, N-Triples, TriG, N-Quads, RDF/XML, JSON-LD
//! - **Named Graphs** - Full quad support with named graph management
//! - **RDF-star** - Support for quoted triples (statement reification)
//!
//! ### Performance & Scalability
//! - **Memory Efficiency** - Arena-based allocators and optimized data structures
//! - **Concurrent Operations** - Lock-free data structures for high-throughput workloads
//! - **Parallel Processing** - SIMD and multi-threaded query execution
//! - **Zero-Copy Parsing** - Streaming parsers with minimal allocations
//!
//! ### SPARQL Foundation
//! - **SPARQL 1.1 Query** - SELECT, CONSTRUCT, ASK, DESCRIBE queries
//! - **SPARQL 1.1 Update** - INSERT, DELETE, LOAD, CLEAR operations
//! - **SPARQL 1.2 Features** - Enhanced property paths, aggregations, and functions
//! - **Federation** - SERVICE clause support for distributed queries
//!
//! ### Storage & Persistence
//! - **Pluggable Backends** - In-memory and disk-based storage options
//! - **Persistent Storage** - Automatic N-Quads serialization for durability
//! - **Indexed Access** - Multi-index support (SPO, POS, OSP) for fast pattern matching
//! - **Transaction Support** - ACID-compliant transactions for data integrity
//!
//! ### Production Features
//! - **Monitoring & Metrics** - Built-in performance instrumentation via SciRS2
//! - **Error Handling** - Rich error types with context and suggestions
//! - **Health Checks** - Circuit breakers and resource quotas
//! - **Benchmarking** - Comprehensive benchmark suite for performance validation
//!
//! ## Quick Start
//!
//! ### Creating a Store and Adding Data
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//! use oxirs_core::model::{NamedNode, Triple, Literal};
//!
//! # fn example() -> Result<(), oxirs_core::OxirsError> {
//! // Create an in-memory RDF store
//! let mut store = RdfStore::new()?;
//!
//! // Create RDF terms
//! let alice = NamedNode::new("http://example.org/alice")?;
//! let knows = NamedNode::new("http://xmlns.com/foaf/0.1/knows")?;
//! let bob = NamedNode::new("http://example.org/bob")?;
//! let name = NamedNode::new("http://xmlns.com/foaf/0.1/name")?;
//!
//! // Insert triples
//! store.insert_triple(Triple::new(alice.clone(), knows, bob))?;
//! store.insert_triple(Triple::new(alice, name, Literal::new("Alice")))?;
//!
//! println!("Store contains {} triples", store.len()?);
//! # Ok(())
//! # }
//! ```
//!
//! ### Querying with Pattern Matching
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//! use oxirs_core::model::{NamedNode, Subject, Predicate};
//!
//! # fn query_example() -> Result<(), oxirs_core::OxirsError> {
//! # let mut store = RdfStore::new()?;
//! // Query all triples with a specific predicate
//! let knows = NamedNode::new("http://xmlns.com/foaf/0.1/knows")?;
//! let predicate = Predicate::NamedNode(knows);
//!
//! let triples = store.query_triples(None, Some(&predicate), None)?;
//! for triple in triples {
//! println!("{:?} knows {:?}", triple.subject(), triple.object());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### Executing SPARQL Queries
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//!
//! # fn sparql_example() -> Result<(), oxirs_core::OxirsError> {
//! # let store = RdfStore::new()?;
//! // Execute a SPARQL SELECT query
//! let query = r#"
//! PREFIX foaf: <http://xmlns.com/foaf/0.1/>
//! SELECT ?name WHERE {
//! ?person foaf:name ?name .
//! }
//! "#;
//!
//! let results = store.query(query)?;
//! println!("Query returned {} results", results.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Loading Data from Files
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//! use oxirs_core::parser::{Parser, RdfFormat};
//! use std::fs;
//!
//! # fn load_example() -> Result<(), oxirs_core::OxirsError> {
//! # let mut store = RdfStore::new()?;
//! // Load RDF data from a Turtle file
//! let content = fs::read_to_string("data.ttl")
//! .map_err(|e| oxirs_core::OxirsError::Io(e.to_string()))?;
//!
//! let parser = Parser::new(RdfFormat::Turtle);
//! let quads = parser.parse_str_to_quads(&content)?;
//!
//! for quad in quads {
//! store.insert_quad(quad)?;
//! }
//!
//! println!("Loaded {} quads from file", store.len()?);
//! # Ok(())
//! # }
//! ```
//!
//! ### Persistent Storage
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//! use oxirs_core::model::{NamedNode, Triple, Literal};
//!
//! # fn persistent_example() -> Result<(), oxirs_core::OxirsError> {
//! // Create a persistent store (data saved to disk)
//! let mut store = RdfStore::open("./my_rdf_store")?;
//!
//! // Add data - automatically persisted
//! let subject = NamedNode::new("http://example.org/resource")?;
//! let predicate = NamedNode::new("http://purl.org/dc/terms/title")?;
//! let object = Literal::new("My Resource");
//!
//! store.insert_triple(Triple::new(subject, predicate, object))?;
//!
//! // Data is automatically saved to disk on modifications
//! println!("Data persisted to disk");
//! # Ok(())
//! # }
//! ```
//!
//! ## Advanced Features
//!
//! ### Named Graphs (Quads)
//!
//! ```rust,no_run
//! use oxirs_core::RdfStore;
//! use oxirs_core::model::{NamedNode, Quad, GraphName, Literal};
//!
//! # fn quads_example() -> Result<(), oxirs_core::OxirsError> {
//! # let mut store = RdfStore::new()?;
//! // Create a quad with a named graph
//! let graph = GraphName::NamedNode(NamedNode::new("http://example.org/graph1")?);
//! let subject = NamedNode::new("http://example.org/subject")?;
//! let predicate = NamedNode::new("http://example.org/predicate")?;
//! let object = Literal::new("value");
//!
//! let quad = Quad::new(subject, predicate, object, graph);
//! store.insert_quad(quad)?;
//!
//! // Query specific graph
//! let graph_node = NamedNode::new("http://example.org/graph1")?;
//! let quads = store.graph_quads(Some(&graph_node))?;
//! println!("Graph contains {} quads", quads.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Bulk Operations for Performance
//!
//! ```rust,ignore
//! use oxirs_core::RdfStore;
//! use oxirs_core::model::{NamedNode, Quad, Literal};
//!
//! # fn bulk_example() -> Result<(), oxirs_core::OxirsError> {
//! # let mut store = RdfStore::new()?;
//! // Prepare many quads for bulk insert
//! let mut quads = Vec::new();
//! for i in 0..1000 {
//! let subject = NamedNode::new(&format!("http://example.org/item{}", i))?;
//! let predicate = NamedNode::new("http://example.org/value")?;
//! let object = Literal::new(&i.to_string());
//! quads.push(Quad::from_triple(Triple::new(subject, predicate, object)));
//! }
//!
//! // Bulk insert for better performance
//! let ids = store.bulk_insert_quads(quads)?;
//! println!("Inserted {} quads with IDs: {:?}", ids.len(), &ids[..5]);
//! # Ok(())
//! # }
//! ```
//!
//! ## Module Organization
//!
//! - [`model`] - Core RDF data model types (IRI, Literal, Blank Node, Triple, Quad)
//! - [`rdf_store`] - RDF store implementations with pluggable storage backends
//! - [`parser`] - RDF parsers for multiple serialization formats
//! - [`serializer`] - RDF serializers for exporting data
//! - [`query`] - SPARQL query algebra and execution engine
//! - [`sparql`] - SPARQL query processing and federation
//! - [`storage`] - Storage backends (memory, disk, columnar)
//! - [`indexing`] - Multi-index structures for fast pattern matching
//! - [`concurrent`] - Lock-free data structures for concurrent access
//! - [`optimization`] - Query optimization and execution planning
//! - [`federation`] - SPARQL federation for distributed queries
//! - [`production`] - Production features (monitoring, health checks, circuit breakers)
//!
//! ## Feature Flags
//!
//! - `serde` - Enable serialization support (default)
//! - `parallel` - Enable parallel processing with rayon (default)
//! - `simd` - Enable SIMD optimizations for x86_64
//! - `async` - Enable async I/O support
//! - `rocksdb` - Enable RocksDB storage backend
//! - `rdf-star` - Enable RDF-star (quoted triples) support
//! - `sparql-12` - Enable SPARQL 1.2 features
//!
//! ## Performance Tips
//!
//! 1. **Use bulk operations** - `bulk_insert_quads()` is faster than individual inserts
//! 2. **Choose the right backend** - UltraMemory backend for maximum performance
//! 3. **Enable parallel feature** - Leverage multi-core CPUs for query execution
//! 4. **Use indexed queries** - Pattern matching benefits from multi-index structures
//! 5. **Profile with built-in metrics** - Use SciRS2 metrics for bottleneck identification
//!
//! ## API Stability
//!
//! As of Beta 1 (v0.2.4):
//! - **Stable APIs**: Core RDF model types (`NamedNode`, `Literal`, `Triple`, `Quad`)
//! - **Stable APIs**: Store operations (`RdfStore`, `insert`, `query`, `remove`)
//! - **Stable APIs**: Parser and serializer interfaces
//! - **Unstable APIs**: Advanced optimization features (may change)
//! - **Experimental**: Consciousness, molecular, and quantum modules
//!
//! See [MIGRATION_GUIDE.md](../MIGRATION_GUIDE.md) for migration from alpha versions.
//!
//! ## Architecture
//!
//! For detailed architecture documentation, see [ARCHITECTURE.md](../ARCHITECTURE.md).
//!
//! ## Examples
//!
//! More examples are available in the `examples/` directory:
//! - `basic_store.rs` - Basic store operations
//! - `sparql_query.rs` - SPARQL query examples
//! - `persistent_store.rs` - Persistent storage usage
//! - `bulk_loading.rs` - High-performance bulk data loading
//! - `federation.rs` - Federated SPARQL queries
// Consciousness-inspired computing for intuitive query optimization
// SPARQL query processing modules
// pub mod config;
// Re-enabled after fixing StringInterner method calls
// Oxigraph compatibility layer
// Core abstractions for OxiRS ecosystem
// SIMD-optimized triple pattern matching using SciRS2
// Zero-copy RDF operations using SciRS2-core memory management
// Query optimization enhancements
// Core-level query result cache with LRU and delta invalidation
// Named Graph Management API (Jena Dataset-compatible)
// Runtime feedback-based adaptive query optimization
// W3C PROV-O ontology support for RDF data provenance tracking
// API stability markers and LTS compatibility matrix
// Equi-depth histogram statistics for cardinality estimation
// Incremental view maintenance with delta propagation // W3C DataFactory API for programmatic RDF term construction
// Incremental view maintenance (new: DeltaChange-based API with IncrementalViewMaintainer) // RDF dataset utilities (diff, patch)
// Re-export core types for convenience
pub use *;
pub use ;
pub use ;
/// Core error type for OxiRS operations
// Additional error conversions
// Note: DataFusion, Arrow, and Parquet error conversions removed
// Add these features to Cargo.toml if these integrations are needed
/// Result type alias for OxiRS operations
pub type Result<T> = Result;
/// Version information for OxiRS Core
pub const VERSION: &str = env!;
/// Initialize OxiRS Core with default configuration