Skip to content

Commit

Permalink
Did some reformatting and hopefully made everything work again.
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 committed Jul 20, 2021
1 parent 130ef9f commit bc51a97
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
32 changes: 14 additions & 18 deletions src/engine/CountAvailablePredicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ void CountAvailablePredicates::computeResult(
const PatternContainerImpl<PredicateId>& pattern_data) {
RuntimeInformation& runtimeInfo = getRuntimeInfo();

const auto& hasPattern = pattern_data.hasPattern();
const auto& hasPredicate = pattern_data.hasPredicate();
const auto& patterns = pattern_data.patterns();
const auto& predicateGlobalIds =
_executionContext->getIndex().getPatternIndex().getPredicateGlobalIds();

if (_subjectEntityName) {
size_t entityId;
// If the entity exists return the all predicates for that entitity,
Expand All @@ -166,35 +172,25 @@ void CountAvailablePredicates::computeResult(
input.push_back({entityId});
int width = input.cols();
CALL_FIXED_SIZE_1(width, CountAvailablePredicates::computePatternTrick,
input, &result->_data, pattern_data.hasPattern(),
pattern_data.hasPredicate(), pattern_data.patterns(),
_executionContext->getIndex()
.getPatternIndex()
.getPredicateGlobalIds(),
0, &runtimeInfo);
input, &result->_data, hasPattern, hasPredicate,
patterns, predicateGlobalIds, 0, &runtimeInfo);
}
} else if (_subtree == nullptr) {
// Compute the predicates for all entities
CountAvailablePredicates::computePatternTrickAllEntities(
&result->_data, pattern_data.hasPattern(), pattern_data.hasPredicate(),
pattern_data.patterns(),

_executionContext->getIndex()
.getPatternIndex()
.getPredicateGlobalIds());
&result->_data, hasPattern, hasPredicate, pattern_data.patterns(),
predicateGlobalIds);
} else {
std::shared_ptr<const ResultTable> subresult = _subtree->getResult();
runtimeInfo.addChild(_subtree->getRootOperation()->getRuntimeInfo());
LOG(DEBUG) << "CountAvailablePredicates subresult computation done."
<< std::endl;

int width = subresult->_data.cols();
CALL_FIXED_SIZE_1(
width, CountAvailablePredicates::computePatternTrick, subresult->_data,
&result->_data, pattern_data.hasPattern(), pattern_data.hasPredicate(),
pattern_data.patterns(),
_executionContext->getIndex().getPatternIndex().getPredicateGlobalIds(),
_subjectColumnIndex, &runtimeInfo);
CALL_FIXED_SIZE_1(width, CountAvailablePredicates::computePatternTrick,
subresult->_data, &result->_data, hasPattern,
hasPredicate, patterns, predicateGlobalIds,
_subjectColumnIndex, &runtimeInfo);
}
LOG(DEBUG) << "CountAvailablePredicates result computation done."
<< std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/global/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ struct hash<Pattern<PredicateId>> {
return std::hash<std::string_view>()(s);
}
};
}
} // namespace std

template <typename PredicateId>
inline std::ostream& operator<<(std::ostream& o,
Expand Down
28 changes: 15 additions & 13 deletions src/index/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <string>
#include <stxxl/vector>
#include <vector>

#include "../engine/ResultTable.h"
#include "../global/Pattern.h"
#include "../parser/NTriplesParser.h"
Expand Down Expand Up @@ -338,16 +339,16 @@ class Index {
* Index class).
*/
template <class Permutation>
void scan(Id key, IdTable* result, const Permutation& p) const {
void scan(Id key, IdTable* result, const Permutation& p,
ad_utility::SharedConcurrentTimeoutTimer timer = nullptr) const {
if (p._meta.relationExists(key)) {
const FullRelationMetaData& rmd = p._meta.getRmd(key)._rmdPairs;
result->reserve(rmd.getNofElements() + 2);
result->resize(rmd.getNofElements());
p._file.read(result->data(), rmd.getNofElements() * 2 * sizeof(Id),
rmd._startFullIndex);
rmd._startFullIndex, std::move(timer));
}
}

/**
* @brief Perform a scan for one key i.e. retrieve all YZ from the XYZ
* permutation for a specific key value of X
Expand All @@ -359,13 +360,14 @@ class Index {
* Index class).
*/
template <class Permutation>
void scan(const string& key, IdTable* result, const Permutation& p) const {
void scan(const string& key, IdTable* result, const Permutation& p,
ad_utility::SharedConcurrentTimeoutTimer timer = nullptr) const {
LOG(DEBUG) << "Performing " << p._readableName
<< " scan for full list for: " << key << "\n";
Id relId;
if (_vocab.getId(key, &relId)) {
LOG(TRACE) << "Successfully got key ID.\n";
scan(relId, result, p);
scan(relId, result, p, std::move(timer));
}
LOG(DEBUG) << "Scan done, got " << result->size() << " elements.\n";
}
Expand Down Expand Up @@ -411,7 +413,7 @@ class Index {
} else {
// If we don't have blocks, scan the whole relation and filter /
// restrict.
IdTable fullRelation(2);
IdTable fullRelation(2, result->getAllocator());
fullRelation.resize(rmd.getNofElements());
p._file.read(fullRelation.data(),
rmd.getNofElements() * 2 * sizeof(Id),
Expand Down Expand Up @@ -494,7 +496,7 @@ class Index {

template <class MetaDataDispatcher>
std::optional<std::pair<typename MetaDataDispatcher::WriteType,
typename MetaDataDispatcher::WriteType>>
typename MetaDataDispatcher::WriteType>>
createPermutationPairImpl(const string& fileName1, const string& fileName2,
const Index::TripleVec& vec, size_t c0, size_t c1,
size_t c2);
Expand All @@ -517,9 +519,9 @@ class Index {
void createPermutationPair(
VocabularyData* vec,
const PermutationImpl<Comparator1, typename MetaDataDispatcher::ReadType>&
p1,
p1,
const PermutationImpl<Comparator2, typename MetaDataDispatcher::ReadType>&
p2,
p2,
bool performUnique = false);

// The pairs of permutations are PSO-POS, OSP-OPS and SPO-SOP
Expand All @@ -541,13 +543,13 @@ class Index {
// the optional is std::nullopt if vec and thus the index is empty
template <class MetaDataDispatcher, class Comparator1, class Comparator2>
std::optional<std::pair<typename MetaDataDispatcher::WriteType,
typename MetaDataDispatcher::WriteType>>
typename MetaDataDispatcher::WriteType>>
createPermutations(
TripleVec* vec,
const PermutationImpl<Comparator1, typename MetaDataDispatcher::ReadType>&
p1,
p1,
const PermutationImpl<Comparator2, typename MetaDataDispatcher::ReadType>&
p2,
p2,
bool performUnique);

void createTextIndex(const string& filename, const TextVec& vec);
Expand Down Expand Up @@ -692,4 +694,4 @@ class Index {
ad_utility::deleteFile(path);
}
}
};
};
8 changes: 2 additions & 6 deletions src/index/PatternIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,8 @@ void PatternIndex::createPatternsImpl(
const Id langPredLowerBound, const Id langPredUpperBound,
Args&... vecReaderArgs) {
IndexMetaDataHmap meta;
typedef ad_utility::HashMap<Pattern<PredicateId>, size_t,
PatternHash<PredicateId>>
PatternsCountMap;
typedef ad_utility::HashMap<Pattern<PredicateId>, PatternID,
PatternHash<PredicateId>>
PatternIdMap;
typedef ad_utility::HashMap<Pattern<PredicateId>, size_t> PatternsCountMap;
typedef ad_utility::HashMap<Pattern<PredicateId>, PatternID> PatternIdMap;
// Used for the entityHasPattern relation
// This struct is 16 bytes, not 12, due to padding (at least on gcc 10)
struct SubjectPatternPair {
Expand Down

0 comments on commit bc51a97

Please sign in to comment.