Skip to content

Commit

Permalink
Fixed the compilation. TODO: At least in GroupBy there is a commit mi…
Browse files Browse the repository at this point in the history
…ssing.
  • Loading branch information
joka921 committed Apr 10, 2021
1 parent abedd60 commit 33dc9e0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 45 deletions.
46 changes: 9 additions & 37 deletions src/engine/GroupBy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
if (inputTypes[a._inCol] == ResultTable::ResultType::VERBATIM) {
if (a._distinct) {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -202,7 +201,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
res += input(i, a._inCol);
}
}
Expand All @@ -211,7 +209,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
float tmpF;
if (a._distinct) {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -222,7 +219,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
std::memcpy(&tmpF, &input(i, a._inCol), sizeof(float));
res += tmpF;
}
Expand All @@ -233,7 +229,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
} else {
if (a._distinct) {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -252,7 +247,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
// load the string, parse it as an xsd::int or float
// TODO(schnelle): What's the correct way to handle OPTIONAL here
std::string entity =
Expand All @@ -276,7 +270,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
if (a._distinct) {
size_t count = 0;
for (size_t i = blockStart; i <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
count++;
Expand All @@ -295,7 +288,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
if (inputTypes[a._inCol] == ResultTable::ResultType::VERBATIM) {
if (a._distinct) {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -309,7 +301,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
out << input(i, a._inCol) << *delim;
}
out << input(blockEnd, a._inCol);
Expand All @@ -318,7 +309,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
float f;
if (a._distinct) {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -334,7 +324,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
std::memcpy(&f, &input(i, a._inCol), sizeof(float));
out << f << *delim;
}
Expand All @@ -344,7 +333,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
} else if (inputTypes[a._inCol] == ResultTable::ResultType::TEXT) {
if (a._distinct) {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -358,15 +346,13 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
out << index.getTextExcerpt(input(i, a._inCol)) << *delim;
}
out << index.getTextExcerpt(input(blockEnd, a._inCol));
}
} else if (inputTypes[a._inCol] == ResultTable::ResultType::LOCAL_VOCAB) {
if (a._distinct) {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand All @@ -385,7 +371,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
// TODO(schnelle): What's the correct way to handle OPTIONAL here
out << inTable->idToOptionalString(input(i, a._inCol)).value_or("")
<< *delim;
Expand All @@ -396,7 +381,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
} else {
if (a._distinct) {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
const auto it = distinctHashSet.find(input(i, a._inCol));
if (it == distinctHashSet.end()) {
distinctHashSet.insert(input(i, a._inCol));
Expand Down Expand Up @@ -426,7 +410,6 @@ void GroupBy::processGroup(const GroupBy::Aggregate& a, size_t blockStart,
distinctHashSet.clear();
} else {
for (size_t i = blockStart; i + 1 <= blockEnd; i++) {
check(i);
// TODO(schnelle): What's the correct way to handle OPTIONAL here
std::string entity =
index.idToOptionalString(input(i, a._inCol)).value_or("");
Expand Down Expand Up @@ -643,9 +626,6 @@ void GroupBy::doGroupBy(const IdTable& dynInput,
size_t blockStart = 0;
size_t blockEnd = 0;
for (size_t pos = 1; pos < input.size(); pos++) {
if (pos % 32768 == 0) {
checkTimeout();
}
bool rowMatchesCurrentBlock = true;
for (size_t i = 0; i < currentGroupBlock.size(); i++) {
if (input(pos, currentGroupBlock[i].first) !=
Expand Down Expand Up @@ -789,24 +769,16 @@ void GroupBy::computeResult(ResultTable* result) {

int inWidth = subresult->_data.cols();
int outWidth = result->_data.cols();

auto cleanup = [&]() {
// Free the user data used by GROUP_CONCAT aggregates.
for (Aggregate& a : aggregates) {
if (a._type == ParsedQuery::AggregateType::GROUP_CONCAT) {
delete static_cast<std::string*>(a._userData);
}
CALL_FIXED_SIZE_2(inWidth, outWidth, doGroupBy, subresult->_data,
inputResultTypes, groupByCols, aggregates, &result->_data,
subresult.get(), result, getIndex());

// Free the user data used by GROUP_CONCAT aggregates.
for (Aggregate& a : aggregates) {
if (a._type == ParsedQuery::AggregateType::GROUP_CONCAT) {
delete static_cast<std::string*>(a._userData);
}
};
try {
CALL_FIXED_SIZE_2(inWidth, outWidth, doGroupBy, subresult->_data,
inputResultTypes, groupByCols, aggregates, &result->_data,
subresult.get(), result, getIndex());
} catch (...) {
cleanup();
throw;
}
cleanup();
LOG(DEBUG) << "GroupBy result computation done." << std::endl;

LOG(DEBUG) << "GroupBy result computation done." << std::endl;
}
4 changes: 2 additions & 2 deletions src/engine/GroupBy.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ class GroupBy : public Operation {
std::vector<ParsedQuery::Alias> _aliases;
ad_utility::HashMap<string, size_t> _varColMap;

virtual void computeResult(ResultTable* result) override;
void computeResult(ResultTable* result) override;

template <int IN_WIDTH, int OUT_WIDTH>
void processGroup(const GroupBy::Aggregate& a, size_t blockStart,
size_t blockEnd, const IdTableStatic<IN_WIDTH>& input,
size_t blockEnd, const IdTableView<IN_WIDTH>& input,
const vector<ResultTable::ResultType>& inputTypes,
IdTableStatic<OUT_WIDTH>* result, size_t resultRow,
const ResultTable* inTable, ResultTable* outTable,
Expand Down
2 changes: 0 additions & 2 deletions src/engine/TransitivePath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ void TransitivePath::computeTransitivePathLeftBound(
size_t last_elem = std::numeric_limits<size_t>::max();
size_t last_result_begin = 0;
size_t last_result_end = 0;
size_t elements_handled =
0; // only there for checking timeouts every now and then
size_t elements_inner_loop =
0; // only there for checking timeouts every now and then
for (size_t i = 0; i < left.size(); i++) {
Expand Down
12 changes: 8 additions & 4 deletions test/EngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ ad_utility::AllocatorWithLimit<Id>& allocator() {
}

TEST(EngineTest, joinTest) {

// this operation makes no sense, but because of the timeout checks,
// we need a join object.
Join J(nullptr, nullptr, nullptr, 0 , 0 , true);
IdTable a(2, allocator());
a.push_back({1, 1});
a.push_back({1, 3});
Expand All @@ -33,7 +37,7 @@ TEST(EngineTest, joinTest) {
int lwidth = a.cols();
int rwidth = b.cols();
int reswidth = a.cols() + b.cols() - 1;
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, Join::join, a, 0, b, 0, &res);
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, J.join, a, 0, b, 0, &res);

ASSERT_EQ(1u, res(0, 0));
ASSERT_EQ(1u, res(0, 1));
Expand Down Expand Up @@ -64,7 +68,7 @@ TEST(EngineTest, joinTest) {
a.push_back({400000, 200000});
b.push_back({400000, 200000});

CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, Join::join, a, 0, b, 0, &res);
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, J.join, a, 0, b, 0, &res);
ASSERT_EQ(6u, res.size());

a.clear();
Expand All @@ -82,7 +86,7 @@ TEST(EngineTest, joinTest) {
}
a.push_back({4000001, 200000});
b.push_back({4000001, 200000});
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, Join::join, a, 0, b, 0, &res);
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, J.join, a, 0, b, 0, &res);
ASSERT_EQ(2u, res.size());

a.clear();
Expand All @@ -102,7 +106,7 @@ TEST(EngineTest, joinTest) {
reswidth = b.cols() + c.cols() - 1;
// reset the IdTable.
res = IdTable(reswidth, allocator());
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, Join::join, b, 0, c, 0, &res);
CALL_FIXED_SIZE_3(lwidth, rwidth, reswidth, J.join, b, 0, c, 0, &res);

ASSERT_EQ(2u, res.size());

Expand Down

0 comments on commit 33dc9e0

Please sign in to comment.