Skip to content

Add qlever upgrade-index command - #335

Merged
hannahbast merged 2 commits into
mainfrom
add-upgrade-index-command
Sep 1, 2026
Merged

Add qlever upgrade-index command#335
hannahbast merged 2 commits into
mainfrom
add-upgrade-index-command

Conversation

@hannahbast

@hannahbast hannahbast commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Complements ad-freiburg/qlever#3159, which changes the index format and introduces the qlever-upgrade-index binary to convert an index from the previous format to the new format.

All the new command does is call the binary. It works for all settings of SYSTEM (native, docker, podman). In particular, it is useful when qlever-* binaries are not installed on the user's system but only in the Docker image.

So far, upgrading an index to the new format introduced on 2026-09-01 required running the `qlever-upgrade-index` binary by hand. For a setup that runs QLever with Docker or Podman, that binary is inside the image and not on the user's machine, so the command from the error message did not work there.

There is now `qlever upgrade-index`, which runs the binary natively or in a container, depending on the `SYSTEM` from the Qleverfile, just like `qlever index` does. The output is also written to a log file. The command only converts from the previous index format to the one introduced on 2026-09-01, which is also stated in its help text.
Copilot AI lite review requested due to automatic review settings September 1, 2026 02:29

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.

Pull request overview

Adds a new qlever upgrade-index CLI command to upgrade an existing index to the format introduced on 2026-09-01, supporting both native execution and containerized execution (Docker/Podman), and capturing output to a log file.

Changes:

  • Introduce UpgradeIndexCommand (qlever upgrade-index) with optional --upgrade-index-binary override.
  • Implement container wrapping via Containerize when SYSTEM is a container engine.
  • Add unit tests covering native/container/show/failure paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/qlever/commands/upgrade_index.py Implements the new upgrade-index command, command construction, optional containerization, and binary existence checks.
test/qlever/commands/test_upgrade_index_execute.py Adds unit tests for the new command’s execution logic in multiple scenarios.

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

Comment on lines +49 to +56
upgrade_index_binary = args.upgrade_index_binary
if upgrade_index_binary is None:
directory, slash, _ = args.index_binary.rpartition("/")
upgrade_index_binary = (
f"{directory}/qlever-upgrade-index"
if slash
else "qlever-upgrade-index"
)
Comment on lines +81 to +84
if not binary_exists(
upgrade_index_binary, "upgrade-index-binary", args
):
return False
@hannahbast hannahbast changed the title Add a qlever upgrade-index command Add qlever upgrade-index command Sep 1, 2026
@hannahbast
hannahbast merged commit 2c4b308 into main Sep 1, 2026
10 checks passed
@hannahbast
hannahbast deleted the add-upgrade-index-command branch September 1, 2026 03:26
hannahbast added a commit to ad-freiburg/qlever that referenced this pull request Sep 1, 2026
… the resulting new index format (#3159)

The vocabulary of an index is fixed once the index is built. For new words created later, there are so-called local vocabularies. An entry in such a vocabulary is an `Id` that holds a `LocalVocabIndex`: a pointer into memory, which is expensive to compare and cannot be persisted to disk.

This change adds the new datatype `SecondaryVocabIndex` for words in a secondary vocabulary. The words in that vocabulary are kept in sorted order and can be persisted to disk. It behaves much like the original vocabulary, but can grow dynamically. It will be the vocabulary of choice for SPARQL updates, materialized views, and other precomputed results. This is the first change in the series that implements this vocabulary and the features that need it. For now, nothing but the unit tests creates such a vocabulary.

The new datatype is inserted directly after `LocalVocabIndex` in the `Datatype` enum. With this placement, comparing `Id`s stays cheap, and the new datatype can later join the contiguous block of the string datatypes. All operations that depend on the internal order of `Id`s (`JOIN`, `GROUP BY`, `DISTINCT`, exporting) already work correctly with it. The semantically correct comparison of its words (for `ORDER BY` and `FILTER`) is deliberately left to a follow-up. That follow-up comes before the secondary vocabulary is actually used.

**THIS IS AN INDEX BREAKING CHANGE:**

Inserting a datatype in the middle of the enum renumbers the datatypes after it. The index format version is raised, and an old binary refuses a new index (and vice versa) with a clear error message. **Existing indexes must be upgraded, but do not have to be rebuilt from scratch.** The new binary `qlever-upgrade-index <basename>` (and the associated new `qlever upgrade-index`, see qlever-dev/qlever-control#335) upgrades an index in place. It rewrites the index `Id` by `Id` into a temporary subdirectory (without re-sorting anything, because the insertion preserves the relative order of all existing datatypes), checks that the result can be loaded and has the right number of triples, and only then moves the original index to the subdirectory `index-in-old-format.<date of its build>` and puts the upgraded index in its place. The upgrade is more than 10 times faster than a rebuild from scratch. The upgrade is not byte-deterministic because the blocks of the permutations are compressed in parallel.

Co-authored-by: Hannah Bast <bast@informatik.uni-freiburg.de>
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