Skip to content

Commit

Permalink
Refactoring and fixing E2E tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed May 3, 2024
1 parent 7be34a7 commit 3600030
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/engine/HasPredicateScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ string HasPredicateScan::getDescriptor() const {
case ScanType::FULL_SCAN:
return "HasPredicateScan full scan";
case ScanType::SUBQUERY_S:
return "HasPredicateScan with a subquery on " + subject_.toRdfLiteral();
return "HasPredicateScan with subquery";

Check warning on line 118 in src/engine/HasPredicateScan.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/HasPredicateScan.cpp#L118

Added line #L118 was not covered by tests
default:
return "HasPredicateScan";
}
Expand Down
5 changes: 5 additions & 0 deletions src/global/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static const std::string HAS_PREDICATE_PREDICATE =
makeInternalIri("has-predicate");
static const std::string HAS_PATTERN_PREDICATE = makeInternalIri("has-pattern");
static const std::string DEFAULT_GRAPH_IRI = makeInternalIri("default-graph");
static const std::string INTERNAL_GRAPH_IRI = makeInternalIri("internal-graph");

static constexpr std::pair<std::string_view, std::string_view> GEOF_PREFIX = {
"geof:", "http://www.opengis.net/def/function/geosparql/"};
Expand Down Expand Up @@ -174,6 +175,10 @@ static constexpr int DEFAULT_MAX_NUM_COLUMNS_STATIC_ID_TABLE = 5;
// `CancellationHandle::throwIfCancelled` is called regularly.
constexpr std::chrono::milliseconds DESIRED_CANCELLATION_CHECK_INTERVAL{50};

// In all permutations, the graph ID of the triple is stored as the fourth
// entry.
constexpr size_t ADDITIONAL_COLUMN_GRAPH_ID = 3;

// In the PSO and PSO permutations the patterns of the subject and object are
// stored at the following indices. Note that the col0 (the P) is not part of
// the result, so the column order for PSO is S O PatternS PatternO.
Expand Down
2 changes: 1 addition & 1 deletion src/global/SpecialIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static const inline ad_utility::HashMap<std::string, Id> specialIds = []() {
{HAS_PREDICATE_PREDICATE, Id::fromBits(1)},
{HAS_PATTERN_PREDICATE, Id::fromBits(2)},
{DEFAULT_GRAPH_IRI, Id::fromBits(3)},
};
{INTERNAL_GRAPH_IRI, Id::fromBits(4)}};

// Perform the following checks: All the special IDs are unique, all of them
// have the `Undefined` datatype, but none of them is equal to the "actual"
Expand Down
2 changes: 2 additions & 0 deletions src/index/ConstantsIndexBuilding.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ inline size_t BUFFER_SIZE_PARTIAL_TO_GLOBAL_ID_MAPPINGS = 10'000;
// infeasible. 250K seems to be a reasonable tradeoff here.
constexpr ad_utility::MemorySize
UNCOMPRESSED_BLOCKSIZE_COMPRESSED_METADATA_PER_COLUMN = 250_kB;

static constexpr size_t NumColumnsIndexBuilding = 4;
41 changes: 21 additions & 20 deletions src/index/IndexBuilderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,7 @@ struct TripleComponentWithIndex {
using TripleComponentOrId = std::variant<PossiblyExternalizedIriOrLiteral, Id>;
// A triple + GraphId that also knows for each entry, whether this entry should
// be part of the external vocabulary.
using Triple = std::array<TripleComponentOrId, 4>;

// Convert a triple of `std::string` to a triple of `TripleComponents`. All
// three entries will have `isExternal()==false` and an uninitialized ID.
inline Triple makeTriple(std::array<std::string, 3>&& t) {
using T = PossiblyExternalizedIriOrLiteral;
return {T{t[0]}, T{t[1]}, T{t[2]}};
}
using Triple = std::array<TripleComponentOrId, NumColumnsIndexBuilding>;

/// The index of a word and the corresponding `SplitVal`.
struct LocalVocabIndexAndSplitVal {
Expand Down Expand Up @@ -177,8 +170,9 @@ struct alignas(256) ItemMapManager {
}

/// call getId for each of the Triple elements.
std::array<Id, 4> getId(const Triple& t) {
return {getId(t[0]), getId(t[1]), getId(t[2]), getId(t[3])};
std::array<Id, NumColumnsIndexBuilding> getId(const Triple& t) {
return std::apply(
[this](const auto&... els) { return std::array{getId(els)...}; }, t);
}
ItemMapAndBuffer map_;
uint64_t minId_ = 0;
Expand Down Expand Up @@ -242,7 +236,8 @@ auto getIdMapLambdas(
itemArray[j]->getId(TripleComponent{
ad_utility::triple_component::Iri::fromIriref(LANGUAGE_PREDICATE)});
}
using OptionalIds = std::array<std::optional<std::array<Id, 4>>, 3>;
using OptionalIds =
std::array<std::optional<std::array<Id, NumColumnsIndexBuilding>>, 3>;

/* given an index idx, returns a lambda that
* - Takes a triple and a language tag
Expand All @@ -253,7 +248,9 @@ auto getIdMapLambdas(
* - All Ids are assigned according to itemArray[idx]
*/
const auto itemMapLamdaCreator = [&itemArray, indexPtr](const size_t idx) {
return [&map = *itemArray[idx], indexPtr](ad_utility::Rvalue auto&& tr) {
auto internalGraph = qlever::specialIds.at(INTERNAL_GRAPH_IRI);
return [&map = *itemArray[idx], indexPtr,
internalGraph](ad_utility::Rvalue auto&& tr) {
auto lt = indexPtr->tripleToInternalRepresentation(AD_FWD(tr));
OptionalIds res;
// get Ids for the actual triple and store them in the result.
Expand All @@ -272,16 +269,20 @@ auto getIdMapLambdas(
auto& spoIds = *res[0]; // ids of original triple
// TODO replace the std::array by an explicit IdTriple class,
// then the emplace calls don't need the explicit type.
using Arr = std::array<Id, NumColumnsIndexBuilding>;
static_assert(NumColumnsIndexBuilding == 4,
" The following lines probably have to be changed when "
"the number of payload columns changes");
// extra triple <subject> @language@<predicate> <object>
res[1].emplace(std::array<Id, 4>{spoIds[0], langTaggedPredId, spoIds[2],
spoIds[3]});
// The additional triples all have the graph ID of the internal graph.
res[1].emplace(
Arr{spoIds[0], langTaggedPredId, spoIds[2], internalGraph});
// extra triple <object> ql:language-tag <@language>
res[2].emplace(std::array<Id, 4>{
spoIds[2],
map.getId(
TripleComponent{ad_utility::triple_component::Iri::fromIriref(
LANGUAGE_PREDICATE)}),
langTagId, spoIds[3]});
res[2].emplace(Arr{spoIds[2],
map.getId(TripleComponent{
ad_utility::triple_component::Iri::fromIriref(
LANGUAGE_PREDICATE)}),
langTagId, internalGraph});
}
return res;
};
Expand Down
2 changes: 1 addition & 1 deletion src/index/IndexFormatVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ struct IndexFormatVersion {
// The actual index version. Change it once the binary format of the index
// changes.
inline const IndexFormatVersion& indexFormatVersion{
1320, DateOrLargeYear{Date{2024, 4, 17}}};
1337, DateOrLargeYear{Date{2024, 5, 7}}};
} // namespace qlever
Loading

0 comments on commit 3600030

Please sign in to comment.