Skip to content

Add generic SQLite-backed file indexing - #107

Open
hdclark wants to merge 13 commits into
masterfrom
feature/file-index-sqlite
Open

hdclark wants to merge 13 commits into
masterfrom
feature/file-index-sqlite

Conversation

@hdclark

@hdclark hdclark commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Add a reusable, SQLite-backed file indexing layer to Ygor. The API keeps SQLite details private and exposes runtime-configurable typed measures, extractor registration, freshness tracking, generic predicates, and filename-only queries.

Generic index

  • typed integer, real, text, and range facts
  • versioned/configured measure identities
  • runtime measure extractor registration
  • per-file/per-measure missing, current, stale, failed, and known_empty state
  • missing, stale, and all refresh policies
  • known_only, include_unknown, and require_complete query policies
  • generic exists, equal, between, overlaps, and any_of predicates
  • builtin filesystem extension, size, and modification-time measures
  • transactional replacement of a measure's facts
  • physical SQLite schema versioning via application_id / user_version

GPX measures

  • latitude extent
  • antimeridian-safe longitude extents
  • configurable coverage-cell measures whose configuration is part of the measure identity
  • segment-based grid traversal so sparse GPX samples still index cells crossed by the track
  • helpers for converting geographic query bounds into generic coverage-cell predicates

Tests and build integration

  • add Doctest coverage following the existing tests2 conventions
  • cover generic querying, gradual index population/completeness, stale detection, sparse GPX segment coverage, multiple cell resolutions, and antimeridian behavior
  • add SQLite3 to CMake, GitLab CI, and Arch packaging dependencies
  • all new implementation code targets C++17

Validation

Performed lightweight local C++17 compilation/smoke checks of the new source units and core query/GPX behavior. Per the requested workflow, this PR was prepared without waiting for the full project build or CI test suites to complete.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

sqlite_file_index::status() can incorrectly report measures as current for unreadable/deleted files, and integer any_of query generation can create problematic SQL without consistent binding behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a reusable SQLite-backed file indexing subsystem for Ygor, including a generic query/predicate API, filesystem-derived builtin measures, and GPX-specific measures for geographic extents and coverage-cell indexing.

Changes:

  • Add core SQLite-backed index storage, measure registration/extraction, and query execution with completeness policies.
  • Add GPX indexing measures (latitude/longitude extents and coverage-cell rasterization) plus helpers to build coverage predicates from geographic bounds.
  • Add doctest coverage for generic indexing/querying and GPX behavior, and wire SQLite3 into build/CI/packaging dependencies.
File summaries
File Description
tests2/YgorFileIndex.cc Adds doctest coverage for generic and GPX file-index behaviors.
tests2/compile_and_run.sh Includes the new file-index doctest unit in the tests2 build.
src/YgorFileIndex.h Defines the public file index API (measures, predicates, policies, sqlite_file_index).
src/YgorFileIndex.cc Implements predicate builders, sqlite_file_index orchestration, and builtin filesystem measures.
src/YgorFileIndexPrivate.hpp Introduces internal SQLite helpers, validation, and the sqlite_file_index pimpl definition.
src/YgorFileIndexSQLite.cc Implements SQLite schema init/versioning and fact/state persistence routines.
src/YgorFileIndexQuery.cc Implements query SQL generation/execution, per-measure status, and completion tracking.
src/YgorFileIndexGPX.h Declares GPX-specific measures and coverage predicate helpers.
src/YgorFileIndexGPX.cc Implements GPX parsing, extents computation, and sparse segment coverage-cell rasterization.
src/CMakeLists.txt Adds SQLite3 dependency discovery and links it into the Ygor library.
PKGBUILD Adds sqlite to Arch package dependencies.
.gitlab-ci.yml Installs SQLite dev/runtime packages in CI images.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/YgorFileIndexQuery.cc
Comment on lines +140 to +150
if(predicate.measure.kind == file_index_value_kind::integer){
std::string out = "x.integer_value IN (";
for(std::size_t i = 0; i < values.size(); ++i){
if(i != 0){
out += ',';
}
out += std::to_string(std::get<int64_t>(values[i]));
}
out += ')';
return out;
}
Comment thread src/YgorFileIndexQuery.cc
Comment on lines +258 to +267
auto size = file_statement.column_int64(1);
auto mtime = file_statement.column_int64(2);
if(Does_File_Exist_And_Can_Be_Read(path)){
const auto disk_size = static_cast<int64_t>(Size_of_File(path));
const auto disk_mtime = static_cast<int64_t>(Last_Modification_Time(path));
if((disk_size >= 0) && (disk_mtime >= 0)){
size = disk_size;
mtime = disk_mtime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants