Skip to content

Commit

Permalink
Tests not working at all, but the local vocab is messy....
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed Jul 10, 2024
1 parent 13fd1ae commit eae3725
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/index/IndexImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class IndexImpl {
return *globalSingletonComparator_;
}

void setGlobalIndexAndComparatorOnlyForTesting() const {
globalSingletonIndex_ = this;
globalSingletonComparator_ = &vocab_.getCaseComparator();
}

// For a given `Permutation::Enum` (e.g. `PSO`) return the corresponding
// `Permutation` object by reference (`pso_`).
Permutation& getPermutation(Permutation::Enum p);
Expand Down
21 changes: 17 additions & 4 deletions test/util/IndexTestHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,19 @@ Index makeTestIndex(const std::string& indexBasename,

FILE_BUFFER_SIZE = 1000;
BUFFER_SIZE_JOIN_PATTERNS_WITH_OSP = 2;
std::fstream f(inputFilename, std::ios_base::out);
f << turtleInput.value();
f.close();
{
std::fstream f(inputFilename, std::ios_base::out);
f << turtleInput.value();
f.close();
}
{
std::fstream settingsFile(inputFilename + ".settings.json",
std::ios_base::out);
nlohmann::json settingsJson;
settingsJson["prefixes-external"] = std::vector<std::string>{""};
settingsJson["languages-internal"] = std::vector<std::string>{""};
settingsFile << settingsJson.dump();
}
{
Index index = makeIndexWithTestSettings();
// This is enough for 2 triples per block. This is deliberately chosen as a
Expand All @@ -159,6 +169,7 @@ Index makeTestIndex(const std::string& indexBasename,
index.blocksizePermutationsPerColumn() = blocksizePermutations;
index.setOnDiskBase(indexBasename);
index.usePatterns() = usePatterns;
index.setSettingsFile(inputFilename + ".settings.json");
index.loadAllPermutations() = loadAllPermutations;
index.createFromFile(inputFilename);
if (createTextIndex) {
Expand Down Expand Up @@ -259,7 +270,9 @@ QueryExecutionContext* getQec(std::optional<std::string> turtleInput,
blocksizePermutations, createTextIndex)),
std::make_unique<QueryResultCache>()});
}
return contextMap.at(key).qec_.get();
auto* qec = contextMap.at(key).qec_.get();
qec->getIndex().getImpl().setGlobalIndexAndComparatorOnlyForTesting();
return qec;
}

// ___________________________________________________________
Expand Down

0 comments on commit eae3725

Please sign in to comment.