Skip to content

Commit

Permalink
defined result pushing macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Learus committed Jan 10, 2019
1 parent 98a4205 commit 5a59e49
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 48 deletions.
70 changes: 70 additions & 0 deletions input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r0
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r1
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r2
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r3
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r4
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r5
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r6
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r7
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r8
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r9
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r10
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r11
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r12
/home/brewknight/Desktop/Application-Development-for-Information-Systems/workload/small/r13
Done
3 0 1|0.2=1.0&0.1=2.0&0.2>3499|1.2 0.1
5 0|0.2=1.0&0.3=9881|1.1 0.2 1.0
9 0 2|0.1=1.0&1.0=2.2&0.0>12472|1.0 0.3 0.4
9 0|0.1=1.0&0.1>1150|0.3 1.0
6 1 12|0.1=1.0&1.0=2.2&0.0<62236|1.0
11 0 5|0.2=1.0&1.0=2.2&0.1=5784|2.3 0.1 0.1
4 1 2 11|0.1=1.0&1.0=2.1&1.0=3.1&0.1>2493|3.2 2.2 2.1
10 0 13 1|0.2=1.0&1.0=2.2&0.1=3.0&0.1=209|0.2 2.5 2.2
6 1 11 5|0.1=1.0&1.0=2.1&1.0=3.1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=1.2&0.0=2.1&0.0=3.2&1.2>295|3.2 0.0
7 1 3|0.2=1.0&1.0=2.1&1.0=0.2&0.2>6082|2.3 2.1
0 7 10 5|0.0=1.1&0.0=2.2&0.0=3.2&1.3=8728|2.0 3.1
1 4 9 8|0.0=1.1&0.0=2.2&0.0=3.1&1.1>2936|1.0 1.0 3.0
4 1|0.1=1.0&0.1<9795|1.2 0.1
11 1|0.1=1.0&0.1<1688|0.1
5 0|0.2=1.0&0.0<1171|1.0 0.3
4 1 6|0.1=1.0&1.0=2.1&0.0<13500|2.1 0.1 0.0
13 13|0.1=1.2&1.6=8220|1.5
F
11 0 8|0.2=1.0&1.0=2.2&0.2>4041|1.0 1.1 1.0
8 0 10|0.2=1.0&1.0=2.2&0.3<9473|0.3 2.0
5 1 8|0.1=1.0&1.0=2.1&0.1<3560|1.2
13 0 2|0.2=1.0&1.0=0.1&1.0=2.2&0.1>4477|2.0 2.3 1.2
8 0 13 13|0.2=1.0&1.0=2.2&2.1=3.2&0.1>7860|3.3 2.1 3.6
F
50 changes: 50 additions & 0 deletions result
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
26468015 32533054
5446 1009 1009
31831879 99876596 96864400
27314139 10766320
901496306
NULL NULL NULL
281654532 282357938 841559324
187822 1036243 187822
1771710026
22766314 22766314
4634779503 627329747 627329747
41316024 267394881 9912745
NULL NULL
9283
760151704 2430170493 2398594221
NULL NULL NULL
NULL NULL
3537544236 319415951 334176745
1645366150 1016283918 788397597
106938127
10014140 6526034 6526034
NULL NULL
81073
265717 299090
179170057
65339549 18594932 12524601
744497 7983214
3377819501 3395449560 3377819501
5032407477 1146864253
255982520
23837499 33633760 23837499
1391837538
42163975 42772523
858534
109050774 109050774
444547
20504095556 20504095556
633080591 1050051803
5304879 1634121
259497861 259497861 1733901713
28536640 19373870
2135404
943464 3320201
178397045 178397045 213214740
852794
203444887 336237721 203444887
230229977 440364776
93772438
840902 45292 63810
103260116758 17416413522 59644305653
77 changes: 29 additions & 48 deletions src/executioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ do \
// Macro definition for consistency with above declaration
#define exit_if_not(condition) assert(condition)


#define PUSH_RESULTS(self, results, pusher_1, arg_1, pusher_2, arg_2) \
do { \
for (const auto &buffer : results) { \
for (std::size_t i = 0; i < buffer.size(); i++) { \
pusher_1(self, arg_1, buffer[i].key1) \
pusher_2(self, arg_2, buffer[i].key2) \
} \
} \
} while (false) \

#define PUSH_RESULT(self, relation, value) self->inteResults.back().map[relation].push_back(value);

#define PUSH_INTERNAL_RESULTS(self, iterator, value) \
for (const auto &item : (*iterator).map) { \
PUSH_RESULT(self, item.first, item.second[value]) \
} \


static struct Meta
{
__off_t mappingSize;
Expand Down Expand Up @@ -235,8 +254,7 @@ RHJ::Relation RHJ::Executioner::getExternalData(const Query& query, Query::Predi

std::vector<std::string> RHJ::Executioner::execute(const Query& query) {

if (!inteResults.empty())
inteResults.clear();
inteResults.clear();

std::sort(query.predicates, query.predicates + query.preCount, [](Query::Predicate a, Query::Predicate b) {
if ( a.type == Query::Predicate::Type::join_t && b.type == Query::Predicate::Type::join_t ) {
Expand Down Expand Up @@ -414,24 +432,16 @@ bool RHJ::Executioner::externalJoin(const Query& query, Query::Predicate::Operan

RHJ::Results results = RHJ::Relation::RadixHashJoin(left, right);

std::vector<tuple_key_t> leftVector;
std::vector<tuple_key_t> rightVector;


for (auto &buffer : results) {
for (std::size_t i = 0; i < buffer.size(); i++) {
std::unordered_map<std::size_t, std::vector<tuple_key_t>> map;

leftVector.push_back(buffer[i].key1);
rightVector.push_back(buffer[i].key2);

}
}
inteResults.emplace_back(-1, -1, map);
inteResults.back().map[inner.rel] = std::vector<tuple_key_t>();
inteResults.back().map[outer.rel] = std::vector<tuple_key_t>();

std::unordered_map<std::size_t, std::vector<tuple_key_t>> map;
PUSH_RESULTS(this, results, PUSH_RESULT, inner.rel, PUSH_RESULT, outer.rel);

inteResults.emplace_back(map.size(), leftVector.size(), map);
inteResults.back().map[inner.rel] = leftVector;
inteResults.back().map[outer.rel] = rightVector;
inteResults.back().columnNum = inteResults.back().map.size();
inteResults.back().columnSize = inteResults.back().map.begin()->second.size();

#if !defined (__QUIET__)
std::cerr << inteResults.back().columnSize << " rows\n" << std::endl;
Expand Down Expand Up @@ -467,21 +477,7 @@ bool RHJ::Executioner::semiInternalJoin(const Query& query, Query::Predicate::Op
}
inteResults.back().map[outer.rel] = std::vector<tuple_key_t>();


for (auto &buffer : results) {

for (std::size_t i = 0; i < buffer.size(); i++) {

for (auto &item : (*innerIt).map) {

tuple_key_t innerRowID = item.second[buffer[i].key1];
inteResults.back().map[item.first].push_back( innerRowID );
}

tuple_key_t outerRowID = buffer[i].key2;
inteResults.back().map[outer.rel].push_back( outerRowID );
}
}
PUSH_RESULTS(this, results, PUSH_INTERNAL_RESULTS, innerIt, PUSH_RESULT, outer.rel);

inteResults.back().columnNum = inteResults.back().map.size();
if (inteResults.back().columnNum)
Expand Down Expand Up @@ -532,22 +528,7 @@ bool RHJ::Executioner::internalJoin(const Query& query, Query::Predicate::Operan
inteResults.back().map[item.first] = std::vector<tuple_key_t>();
}


for (auto &buffer : results) {
for (std::size_t i = 0; i < buffer.size(); i++) {

for (auto &item : (*innerIt).map) {
tuple_key_t innerRowID = item.second[buffer[i].key1];
inteResults.back().map[item.first].push_back( innerRowID );
}

for (auto &item : (*outerIt).map) {
tuple_key_t outerRowID = item.second[buffer[i].key2];
inteResults.back().map[item.first].push_back( outerRowID );
}
}
}

PUSH_RESULTS(this, results, PUSH_INTERNAL_RESULTS, innerIt, PUSH_INTERNAL_RESULTS, outerIt);

inteResults.back().columnNum = inteResults.back().map.size();
if (inteResults.back().columnNum)
Expand Down

0 comments on commit 5a59e49

Please sign in to comment.