Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Clang-Format to version 8 which has better support for C++17 … #299

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV LC_ALL C.UTF-8
ENV LC_CTYPE C.UTF-8

FROM base as builder
RUN apt-get update && apt-get install -y build-essential cmake clang-format libsparsehash-dev
RUN apt-get update && apt-get install -y build-essential cmake clang-format-8 libsparsehash-dev
COPY . /app/

# Check formatting with the .clang-format project style
Expand Down
6 changes: 3 additions & 3 deletions misc/format-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ done <sourcelist

ERROR=0
for source in "${SOURCE_FILES[@]}" ;do
clang-format -output-replacements-xml $source | grep "<replacement " &> /dev/null
clang-format-8 -output-replacements-xml $source | grep "<replacement " &> /dev/null
HAS_WRONG_FILES=$?
if [ $HAS_WRONG_FILES -ne 1 ] ; then
# Print an error and exit
printf "\x1b[31mError: "
printf "The source file \x1b[m$source\x1b[31m does not match the code style\n"
printf "Use clang-format with the .clang-format provided in the QLever\n"
printf "repository's root to ensure all code files are formatted "
printf "properly. We currently use the clang-format version in\n"
printf "Ubuntu 18.04.x which is version 6.0\n"
printf "properly. We currently use the clang-format 8.0.0-3\n"
printf "(can be installed as \"clang-format-8\" in Ubuntu 18.04.x\n"
printf "\x1b[m"
ERROR=1
fi
Expand Down
11 changes: 6 additions & 5 deletions src/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ class Engine {
LOG(DEBUG) << "Sorting " << tab->size() << " elements.\n";
IdTableStatic<WIDTH> stab = tab->moveToStatic<WIDTH>();
if constexpr (USE_PARALLEL_SORT) {
__gnu_parallel::sort(stab.begin(), stab.end(),
[keyColumn](const auto& a, const auto& b) {
return a[keyColumn] < b[keyColumn];
},
__gnu_parallel::parallel_tag(NUM_SORT_THREADS));
__gnu_parallel::sort(
stab.begin(), stab.end(),
[keyColumn](const auto& a, const auto& b) {
return a[keyColumn] < b[keyColumn];
},
__gnu_parallel::parallel_tag(NUM_SORT_THREADS));
} else {
std::sort(stab.begin(), stab.end(),
[keyColumn](const auto& a, const auto& b) {
Expand Down
120 changes: 60 additions & 60 deletions src/engine/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,52 +120,52 @@ void Filter::computeFilter(IdTableStatic<WIDTH>* result, size_t lhs, size_t rhs,
const IdTableStatic<WIDTH>& input) const {
switch (_type) {
case SparqlFilter::EQ:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) ==
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) == ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::NE:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) !=
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) != ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::LT:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) < ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::LE:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <=
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <= ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::GT:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) > ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::GE:
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >=
ValueReader<T>::get(e[rhs]);
},
result);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >= ValueReader<T>::get(e[rhs]);
},
result);
break;
case SparqlFilter::LANG_MATCHES:
AD_THROW(ad_semsearch::Exception::NOT_YET_IMPLEMENTED,
Expand Down Expand Up @@ -323,12 +323,12 @@ void Filter::computeFilterFixedValue(
});
res->insert(res->end(), input.begin(), lower);
} else {
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <
ValueReader<T>::get(rhs);
},
res);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) < ValueReader<T>::get(rhs);
},
res);
}
break;
case SparqlFilter::LE:
Expand All @@ -343,12 +343,12 @@ void Filter::computeFilterFixedValue(
});
res->insert(res->end(), input.begin(), upper);
} else {
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <=
ValueReader<T>::get(rhs);
},
res);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) <= ValueReader<T>::get(rhs);
},
res);
}
break;
case SparqlFilter::GT:
Expand All @@ -364,12 +364,12 @@ void Filter::computeFilterFixedValue(
// an element equal to rhs exists in the vector
res->insert(res->end(), upper, input.end());
} else {
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >
ValueReader<T>::get(rhs);
},
res);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) > ValueReader<T>::get(rhs);
},
res);
}
break;
case SparqlFilter::GE:
Expand All @@ -385,12 +385,12 @@ void Filter::computeFilterFixedValue(
// an element equal to rhs exists in the vector
res->insert(res->end(), lower, input.end());
} else {
getEngine().filter(input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >=
ValueReader<T>::get(rhs);
},
res);
getEngine().filter(
input,
[lhs, rhs](const auto& e) {
return ValueReader<T>::get(e[lhs]) >= ValueReader<T>::get(rhs);
},
res);
}
break;
case SparqlFilter::LANG_MATCHES:
Expand Down
42 changes: 16 additions & 26 deletions src/index/IndexMetaDataImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ void IndexMetaData<MapType>::add(const FullRelationMetaData& rmd,

off_t afterExpected =
rmd.hasBlocks() ? bRmd._offsetAfter
: static_cast<off_t>(rmd._startFullIndex +
rmd.getNofBytesForFulltextIndex());
: static_cast<off_t>(rmd._startFullIndex + rmd.getNofBytesForFulltextIndex());
if (rmd.hasBlocks()) {
_blockData[rmd._relId] = bRmd;
}
Expand Down Expand Up @@ -132,15 +131,12 @@ bool IndexMetaData<MapType>::relationExists(Id relId) const {

// _____________________________________________________________________________
template <class MapType>
ad_utility::File& operator<<(ad_utility::File& f,
const IndexMetaData<MapType>& imd) {
ad_utility::File& operator<<(ad_utility::File& f, const IndexMetaData<MapType>& imd) {
// first write magic number
if constexpr (IndexMetaData<MapType>::_isMmapBased) {
f.write(&MAGIC_NUMBER_MMAP_META_DATA_VERSION,
sizeof(MAGIC_NUMBER_MMAP_META_DATA_VERSION));
f.write(&MAGIC_NUMBER_MMAP_META_DATA_VERSION, sizeof(MAGIC_NUMBER_MMAP_META_DATA_VERSION));
} else {
f.write(&MAGIC_NUMBER_SPARSE_META_DATA_VERSION,
sizeof(MAGIC_NUMBER_SPARSE_META_DATA_VERSION));
f.write(&MAGIC_NUMBER_SPARSE_META_DATA_VERSION, sizeof(MAGIC_NUMBER_SPARSE_META_DATA_VERSION));
}
// write version
f.write(&V_CURRENT, sizeof(V_CURRENT));
Expand Down Expand Up @@ -235,10 +231,8 @@ string IndexMetaData<MapType>::statistics() const {

os << "# Elements: " << _totalElements << '\n';
os << "# Blocks: " << _totalBlocks << "\n\n";
os << "Theoretical size of Id triples: " << _totalElements * 3 * sizeof(Id)
<< " bytes \n";
os << "Size of pair index: " << totalPairIndexBytes
<< " bytes \n";
os << "Theoretical size of Id triples: " << _totalElements * 3 * sizeof(Id) << " bytes \n";
os << "Size of pair index: " << totalPairIndexBytes << " bytes \n";
os << "Total Size: " << _totalBytes << " bytes \n";
os << "-------------------------------------------------------------------\n";
return os.str();
Expand All @@ -257,8 +251,7 @@ size_t IndexMetaData<MapType>::getNofBlocksForRelation(const Id id) const {

// _____________________________________________________________________________
template <class MapType>
size_t IndexMetaData<MapType>::getTotalBytesForRelation(
const FullRelationMetaData& frmd) const {
size_t IndexMetaData<MapType>::getTotalBytesForRelation(const FullRelationMetaData& frmd) const {
auto it = _blockData.find(frmd._relId);
if (it != _blockData.end()) {
return static_cast<size_t>(it->second._offsetAfter - frmd._startFullIndex);
Expand Down Expand Up @@ -289,8 +282,7 @@ void IndexMetaData<MapType>::calculateExpensiveStatistics() {

// ___________________________________________________________________
template <class MapType>
VersionInfo IndexMetaData<MapType>::parseMagicNumberAndVersioning(
unsigned char* buf) {
VersionInfo IndexMetaData<MapType>::parseMagicNumberAndVersioning(unsigned char* buf) {
uint64_t magicNumber = *reinterpret_cast<uint64_t*>(buf);
size_t nOfBytes = 0;
bool hasVersion = false;
Expand Down Expand Up @@ -323,12 +315,11 @@ VersionInfo IndexMetaData<MapType>::parseMagicNumberAndVersioning(
hasVersion = true;
nOfBytes = sizeof(uint64_t);
} else {
throw WrongFormatException(
"ERROR: No or wrong magic number found in persistent "
"mmap-based meta data. "
"Please use ./MetaDataConverterMain "
"to convert old indices without rebuilding them (See "
"README.md).Terminating...\n");
throw WrongFormatException("ERROR: No or wrong magic number found in persistent "
"mmap-based meta data. "
"Please use ./MetaDataConverterMain "
"to convert old indices without rebuilding them (See "
"README.md).Terminating...\n");
}
}

Expand All @@ -341,10 +332,9 @@ VersionInfo IndexMetaData<MapType>::parseMagicNumberAndVersioning(
res._nOfBytes += sizeof(uint64_t);
}
if (res._version < V_CURRENT) {
LOG(INFO)
<< "WARNING: your IndexMetaData seems to have an old format (version "
"tag < V_CURRENT). Please consider using ./MetaDataConverterMain to "
"benefit from improvements in the index structure.\n";
LOG(INFO) << "WARNING: your IndexMetaData seems to have an old format (version "
"tag < V_CURRENT). Please consider using ./MetaDataConverterMain to "
"benefit from improvements in the index structure.\n";

} else if (res._version > V_CURRENT) {
LOG(INFO) << "ERROR: version tag does not match any actual version (> "
Expand Down