Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
5b89eb1
First draft to rebuild the index
RobinTF Oct 1, 2025
daec8e9
First attempt to transform the values
RobinTF Oct 1, 2025
6e83fac
Fix some assertion errors and segfaults in the code
RobinTF Oct 2, 2025
504d144
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Oct 8, 2025
b802ad3
Also re-write internal triples
RobinTF Oct 9, 2025
f8eeb32
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Oct 9, 2025
f9419f4
Properly write metadata json
RobinTF Oct 9, 2025
9853e4b
Also transfer additional columns
RobinTF Oct 9, 2025
3dc0a52
Avoid compilation errors
RobinTF Oct 10, 2025
7ed0553
Also copy patterns if they exist
RobinTF Oct 10, 2025
4fda778
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Oct 10, 2025
d28cf93
Fix build on macOS
RobinTF Oct 16, 2025
4358e8c
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Oct 16, 2025
eb996ed
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Oct 24, 2025
9ef9eca
Improve index building by correct order & honoring missing permutations
RobinTF Oct 24, 2025
ebba3fc
Properly run index-rebuild on worker thread
RobinTF Oct 24, 2025
fb64328
Separate functions a little better
RobinTF Oct 24, 2025
9fc0a57
Fix regression in code
RobinTF Oct 24, 2025
df850df
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Oct 24, 2025
cc3c026
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Oct 26, 2025
577a621
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Oct 30, 2025
b18dfc0
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Nov 3, 2025
19093f6
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Nov 21, 2025
609e666
Fix broken patterns & skip remap for additional cols
RobinTF Nov 21, 2025
ce95ec1
Add missing call to actually write the patterns
RobinTF Nov 21, 2025
c550945
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Nov 29, 2025
acf5607
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Dec 6, 2025
0e6ab4a
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Dec 11, 2025
2ce8fb5
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Dec 16, 2025
2ed7890
Move rebuilder to dedicated file and make rebuild non-blocking
RobinTF Dec 16, 2025
1292865
Avoid redundant string copies
RobinTF Dec 16, 2025
13824e2
Make index name configurable
RobinTF Dec 17, 2025
d0a1fcb
Start implementing stats recompute
RobinTF Dec 18, 2025
7fd1c93
Correctly recompute internal statistics
RobinTF Dec 18, 2025
739af37
Write permutations individually
RobinTF Dec 18, 2025
a503da4
Parallelize processing
RobinTF Dec 18, 2025
bcc533a
Fix compilation
RobinTF Dec 18, 2025
05b5a38
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Dec 20, 2025
3a4ae04
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Dec 24, 2025
ed929cf
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Dec 25, 2025
c9cc426
Separate log file `<name>.rebuild-index-log.txt`
Dec 26, 2025
b4e0d45
Use 6 columns for dummy block
RobinTF Jan 7, 2026
f9a6a62
Avoid use of unique pointer
RobinTF Jan 7, 2026
c01becf
Fix typo
RobinTF Jan 7, 2026
8a097a6
Change test to new size
RobinTF Jan 7, 2026
6960813
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Jan 8, 2026
4015e1b
Resolve conflicts from merging `origin/master`
Jan 8, 2026
5d942d7
Merge branch 'master' into rebuild-index-and-vocab
RobinTF Jan 9, 2026
a4e22b8
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Jan 9, 2026
95e4d90
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Jan 12, 2026
2ee4404
Add documentation
RobinTF Jan 12, 2026
1d85ecd
Make lookup vector more compact
RobinTF Jan 12, 2026
f295b13
Perform some optimizations to speed up rebuilding
RobinTF Jan 12, 2026
0a198d1
Properly handle exceptions in parallel execution
RobinTF Jan 12, 2026
dee6cdb
Unify code and fix issue with missing patterns for OSP/OPS
RobinTF Jan 14, 2026
a94d1ca
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Jan 14, 2026
c7036af
Add future task
RobinTF Jan 14, 2026
93243f6
Simplify function signature
RobinTF Jan 14, 2026
96b96f8
Add runtime parameter `disable-update-graph-metadata`
Jan 15, 2026
c667532
Merge branch 'master' into rebuild-index-and-vocab
RobinTF Jan 19, 2026
c171f6d
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Jan 19, 2026
fcdc22d
Fix blank node remapping
RobinTF Jan 19, 2026
8310c5c
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Jan 20, 2026
c624ee0
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Jan 21, 2026
a85dc07
Merge remote-tracking branch 'ad-freiburg/master' into rebuild-index-…
RobinTF Jan 30, 2026
47ff6db
Merge branch 'master' into rebuild-index-and-vocab
RobinTF Feb 2, 2026
98c5680
Revert "Add runtime parameter `disable-update-graph-metadata`"
RobinTF Feb 2, 2026
7720cde
Implement unit tests for `loadConfigFromOldIndex`
RobinTF Feb 2, 2026
e50da2f
Start implementing unit tests for index rebuilds
RobinTF Feb 2, 2026
2ae2d6f
Merge remote-tracking branch 'origin/master' into rebuild-index-and-v…
Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/engine/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "engine/SparqlProtocol.h"
#include "global/RuntimeParameters.h"
#include "index/IndexImpl.h"
#include "index/IndexRebuilder.h"
#include "parser/SparqlParser.h"
#include "util/AsioHelpers.h"
#include "util/Exception.h"
Expand Down Expand Up @@ -474,6 +475,38 @@ CPP_template_def(typename RequestT, typename ResponseT)(
json[nlohmann::json(key)] = std::move(value);
}
response = createJsonResponse(json, request);
} else if (auto cmd = checkParameter("cmd", "rebuild-index")) {
requireValidAccessToken("rebuild-index");

if (rebuildInProgress_.exchange(true)) {
response = createHttpResponseFromString(
"Another rebuild is currently in progress!",
http::status::too_many_requests, request, MediaType::textPlain);
} else {
absl::Cleanup cleanup{[this]() { rebuildInProgress_.store(false); }};
logCommand(cmd, "rebuilding index");
auto fileName =
checkParameter("index-name", std::nullopt).value_or("new_index");
// There is no mechanism to actually cancel the handle.
auto handle = std::make_shared<ad_utility::CancellationHandle<>>();
// We don't directly `co_await` because of lifetime issues (bugs) in the
// Conan setup.
auto coroutine = computeInNewThread(
queryThreadPool_,
[this, &handle, fileName = std::move(fileName)] {
auto logFileName = fileName + ".rebuild-index-log.txt";
auto [currentSnapshot, localVocabCopy, ownedBlocks] =
index_.deltaTriplesManager()
.getCurrentLocatedTriplesSharedStateWithVocab();
qlever::materializeToIndex(index_.getImpl(), fileName,
currentSnapshot, localVocabCopy,
ownedBlocks, handle, logFileName);
},
handle);
co_await std::move(coroutine);
response =
createOkResponse("Done writing", request, MediaType::textPlain);
}
} else if (auto cmd = checkParameter("cmd", "write-materialized-view")) {
requireValidAccessToken("write-materialized-view");
logCommand(cmd, "write materialized view");
Expand Down
4 changes: 4 additions & 0 deletions src/engine/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class Server {
/// Executor with a single thread that is used to run timers asynchronously.
boost::asio::static_thread_pool timerExecutor_{1};

// Indicates if an index rebuild is currently in progress so that we prevent
// triggering this twice.
std::atomic_bool rebuildInProgress_{false};

template <typename T>
using Awaitable = boost::asio::awaitable<T>;

Expand Down
2 changes: 1 addition & 1 deletion src/index/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ add_library(index
PrefixHeuristic.cpp CompressedRelation.cpp
PatternCreator.cpp ScanSpecification.cpp
DeltaTriples.cpp LocalVocabEntry.cpp TextScoring.cpp TextScoringEnum.cpp TextIndexReadWrite.cpp
TextIndexBuilder.cpp GraphFilter.cpp)
TextIndexBuilder.cpp GraphFilter.cpp IndexRebuilder.cpp)
qlever_target_link_libraries(index util parser vocabulary global)
26 changes: 24 additions & 2 deletions src/index/IndexImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ constexpr std::string_view BLANK_NODE_ALLOCATION_START =
"num-blank-nodes-total";

// _____________________________________________________________________________
IndexImpl::IndexImpl(ad_utility::AllocatorWithLimit<Id> allocator)
IndexImpl::IndexImpl(ad_utility::AllocatorWithLimit<Id> allocator,
bool registerSingleton)
: allocator_{std::move(allocator)} {
globalSingletonIndex_ = this;
if (registerSingleton) {
globalSingletonIndex_ = this;
}
deltaTriples_.emplace(*this);
}

Expand Down Expand Up @@ -1138,6 +1141,9 @@ void IndexImpl::setKeepTempFiles(bool keepTempFiles) {
// _____________________________________________________________________________
bool& IndexImpl::usePatterns() { return usePatterns_; }

// _____________________________________________________________________________
bool IndexImpl::usePatterns() const { return usePatterns_; }

// _____________________________________________________________________________
bool& IndexImpl::loadAllPermutations() { return loadAllPermutations_; }

Expand Down Expand Up @@ -1900,6 +1906,22 @@ void IndexImpl::writePatternsToFile() const {
statistics);
}

// _____________________________________________________________________________
void IndexImpl::loadConfigFromOldIndex(const std::string& newName,
const IndexImpl& other,
const nlohmann::json& newStats) {
setOnDiskBase(newName);
setKbName(other.getKbName());
blocksizePermutationPerColumn() = other.blocksizePermutationPerColumn();
configurationJson_ = newStats;
numTriples_ = static_cast<NumNormalAndInternal>(newStats["num-triples"]);
numPredicates_ =
static_cast<NumNormalAndInternal>(newStats["num-predicates"]);
numSubjects_ = static_cast<NumNormalAndInternal>(newStats["num-subjects"]);
numObjects_ = static_cast<NumNormalAndInternal>(newStats["num-objects"]);
writeConfiguration();
}

// _____________________________________________________________________________
void IndexImpl::countDistinct(std::optional<Id>& lastId, size_t& counter,
const IdTable& table) {
Expand Down
21 changes: 20 additions & 1 deletion src/index/IndexImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ class IndexImpl {
std::optional<DeltaTriplesManager> deltaTriples_;

public:
explicit IndexImpl(ad_utility::AllocatorWithLimit<Id> allocator);
explicit IndexImpl(ad_utility::AllocatorWithLimit<Id> allocator,
bool registerSingleton = true);

// Forbid copying.
IndexImpl& operator=(const IndexImpl&) = delete;
Expand Down Expand Up @@ -273,6 +274,10 @@ class IndexImpl {

const auto& getScoreData() const { return scoreData_; }

const ad_utility::AllocatorWithLimit<Id>& allocator() const {
return allocator_;
};

ad_utility::BlankNodeManager* getBlankNodeManager() const;

DeltaTriplesManager& deltaTriplesManager() { return deltaTriples_.value(); }
Expand Down Expand Up @@ -442,6 +447,8 @@ class IndexImpl {

bool& usePatterns();

bool usePatterns() const;

bool& loadAllPermutations();

bool& doNotLoadPermutations();
Expand All @@ -464,6 +471,10 @@ class IndexImpl {
return blocksizePermutationPerColumn_;
}

const ad_utility::MemorySize& blocksizePermutationPerColumn() const {
return blocksizePermutationPerColumn_;
}

void setOnDiskBase(const std::string& onDiskBase);

void setSettingsFile(const std::string& filename);
Expand Down Expand Up @@ -698,6 +709,7 @@ class IndexImpl {
friend class CreatePatternsFixture_createPatterns_Test;
FRIEND_TEST(IndexImpl, recomputeStatistics);
FRIEND_TEST(IndexImpl, writePatternsToFile);
FRIEND_TEST(IndexImpl, loadConfigFromOldIndex);

bool isLiteral(std::string_view object) const;

Expand Down Expand Up @@ -862,6 +874,13 @@ class IndexImpl {
void storeTextScoringParamsInConfiguration(TextScoringMetric scoringMetric,
float b, float k);

// Overwrite the config of this instance of `IndexImpl` with the config of
// `other`, adjusting the name to `newName` and the statistics to
// `newStats`.
void loadConfigFromOldIndex(const std::string& newName,
const IndexImpl& other,
const nlohmann::json& newStats);

// Write the stored in-memory patterns to a pattern file.
void writePatternsToFile() const;

Expand Down
Loading
Loading