Skip to content

Commit

Permalink
Merge pull request #193 from floriankramer/better_result_tables
Browse files Browse the repository at this point in the history
Better result tables
  • Loading branch information
niklas88 committed Mar 9, 2019
2 parents fac0a2a + 2e1ac17 commit 6b71b66
Show file tree
Hide file tree
Showing 50 changed files with 3,708 additions and 4,301 deletions.
26 changes: 1 addition & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ add_definitions(-DLOGLEVEL=${LOG_LEVEL_${LOGLEVEL}})
add_subdirectory(src/parser)
add_subdirectory(src/engine)
add_subdirectory(src/index)
enable_testing()
add_subdirectory(test)


Expand Down Expand Up @@ -154,28 +155,3 @@ target_link_libraries(Bzip2WrapperMain -lbz2)
#add_executable(TextFilterComparison src/experiments/TextFilterComparison.cpp)
#target_link_libraries (TextFilterComparison experiments)

enable_testing()
add_test(SparqlParserTest test/SparqlParserTest)
add_test(StringUtilsTest test/StringUtilsTest)
add_test(LRUCacheTest test/LRUCacheTest)
add_test(FileTest test/FileTest)
add_test(Simple8bTest test/Simple8bTest)
add_test(VocabularyTest test/VocabularyTest)
add_test(ExternalVocabularyTest test/ExternalVocabularyTest)
add_test(TsvParserTest test/TsvParserTest)
add_test(NTriplesParserTest test/NTriplesParserTest)
add_test(ContextFileParserTest test/ContextFileParserTest)
add_test(IndexMetaDataTest test/IndexMetaDataTest)
add_test(IndexTest test/IndexTest)
add_test(EngineTest test/EngineTest)
add_test(FTSAlgorithmsTest test/FTSAlgorithmsTest)
add_test(QueryPlannerTest test/QueryPlannerTest)
add_test(ConversionsTest test/ConversionsTest)
add_test(HashMapTest test/HashMapTest)
add_test(HashSetTest test/HashSetTest)
add_test(VocabularyGeneratorTest test/VocabularyGeneratorTest)
add_test(MmapVectorTest test/MmapVectorTest)
add_test(BufferedVectorTest test/BufferedVectorTest)
add_test(TokenTest test/TokenTest)
add_test(TurtleParserTest test/TurtleParserTest)
add_test(MultiColumnJoinTest test/MultiColumnJoinTest)
7 changes: 3 additions & 4 deletions src/WriteIndexListsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ int main(int argc, char** argv) {
auto qet = queryPlanner.createExecutionTree(q);
const auto res = qet.getResult();
AD_CHECK(res->size() > 0);
AD_CHECK(res->_nofColumns == 1);
AD_CHECK(res->_data.cols() == 1);
string personlistFile = indexName + ".list.scientists";
std::vector<std::array<Id, 1>>& ids =
*static_cast<std::vector<std::array<Id, 1>>*>(res->_fixedSizeData);
std::ofstream f(personlistFile.c_str());
const IdTable& ids = res->_data;
for (size_t i = 0; i < ids.size(); ++i) {
f << ids[i][0] << ' ';
f << ids(i, 0) << ' ';
}
f.close();

Expand Down
1 change: 1 addition & 0 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library(engine
HasPredicateScan.cpp HasPredicateScan.h
Union.cpp Union.h
MultiColumnJoin.cpp MultiColumnJoin.h
IdTable.h
)

target_link_libraries(engine index parser)
115 changes: 115 additions & 0 deletions src/engine/CallFixedSize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright 2019, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Florian Kramer (florian.kramer@mail.uni-freiburg.de)

#pragma once

// The macros in this file provide automatic generation of if clauses that
// enable transformation of runtime variables to a limited range of compile
// time values and a default case. Currently this means that
// CALL_FIXED_SIZE_1(i, func, ...) calls func with i as the first template
// parameter if i is in the range [1;5] and with 0 as the first template
// parameter otherwise. Any further template parameters can currently only be
// set by the compiler using template argument deduction.
// This feature is implemented using macros as passing templated but not
// instantiated functions as function or template parameters is not possible
// in C++ 17.

// =============================================================================
// One Variable
// =============================================================================
#define CALL_FIXED_SIZE_1(i, func, ...) \
if (i == 1) { \
func<1>(__VA_ARGS__); \
} else if (i == 2) { \
func<2>(__VA_ARGS__); \
} else if (i == 3) { \
func<3>(__VA_ARGS__); \
} else if (i == 4) { \
func<4>(__VA_ARGS__); \
} else if (i == 5) { \
func<5>(__VA_ARGS__); \
} else { \
func<0>(__VA_ARGS__); \
}

// =============================================================================
// Two Variables
// =============================================================================
#define _CALL_FIXED_SIZE_2_i(i, j, func, ...) \
if (j == 1) { \
func<i, 1>(__VA_ARGS__); \
} else if (j == 2) { \
func<i, 2>(__VA_ARGS__); \
} else if (j == 3) { \
func<i, 3>(__VA_ARGS__); \
} else if (j == 4) { \
func<i, 4>(__VA_ARGS__); \
} else if (j == 5) { \
func<i, 5>(__VA_ARGS__); \
} else { \
func<i, 0>(__VA_ARGS__); \
}

#define CALL_FIXED_SIZE_2(i, j, func, ...) \
if (i == 1) { \
_CALL_FIXED_SIZE_2_i(1, j, func, __VA_ARGS__) \
} else if (i == 2) { \
_CALL_FIXED_SIZE_2_i(2, j, func, __VA_ARGS__) \
} else if (i == 3) { \
_CALL_FIXED_SIZE_2_i(3, j, func, __VA_ARGS__) \
} else if (i == 4) { \
_CALL_FIXED_SIZE_2_i(4, j, func, __VA_ARGS__) \
} else if (i == 5) { \
_CALL_FIXED_SIZE_2_i(5, j, func, __VA_ARGS__) \
} else { \
_CALL_FIXED_SIZE_2_i(0, j, func, __VA_ARGS__) \
}

// =============================================================================
// Three Variables
// =============================================================================
#define _CALL_FIXED_SIZE_3_i_j(i, j, k, func, ...) \
if (k == 1) { \
func<i, j, 1>(__VA_ARGS__); \
} else if (k == 2) { \
func<i, j, 2>(__VA_ARGS__); \
} else if (k == 3) { \
func<i, j, 3>(__VA_ARGS__); \
} else if (k == 4) { \
func<i, j, 4>(__VA_ARGS__); \
} else if (k == 5) { \
func<i, j, 5>(__VA_ARGS__); \
} else { \
func<i, j, 0>(__VA_ARGS__); \
}

#define _CALL_FIXED_SIZE_3_i(i, j, k, func, ...) \
if (j == 1) { \
_CALL_FIXED_SIZE_3_i_j(i, 1, k, func, __VA_ARGS__) \
} else if (j == 2) { \
_CALL_FIXED_SIZE_3_i_j(i, 2, k, func, __VA_ARGS__) \
} else if (j == 3) { \
_CALL_FIXED_SIZE_3_i_j(i, 3, k, func, __VA_ARGS__) \
} else if (j == 4) { \
_CALL_FIXED_SIZE_3_i_j(i, 4, k, func, __VA_ARGS__) \
} else if (j == 5) { \
_CALL_FIXED_SIZE_3_i_j(i, 5, k, func, __VA_ARGS__) \
} else { \
_CALL_FIXED_SIZE_3_i_j(i, 0, k, func, __VA_ARGS__) \
}

#define CALL_FIXED_SIZE_3(i, j, k, func, ...) \
if (i == 1) { \
_CALL_FIXED_SIZE_3_i(1, j, k, func, __VA_ARGS__) \
} else if (i == 2) { \
_CALL_FIXED_SIZE_3_i(2, j, k, func, __VA_ARGS__) \
} else if (i == 3) { \
_CALL_FIXED_SIZE_3_i(3, j, k, func, __VA_ARGS__) \
} else if (i == 4) { \
_CALL_FIXED_SIZE_3_i(4, j, k, func, __VA_ARGS__) \
} else if (i == 5) { \
_CALL_FIXED_SIZE_3_i(5, j, k, func, __VA_ARGS__) \
} else { \
_CALL_FIXED_SIZE_3_i(0, j, k, func, __VA_ARGS__) \
}
8 changes: 5 additions & 3 deletions src/engine/Comparators.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@

#include <utility>
#include <vector>
#include "IdTable.h"

using std::pair;
using std::vector;

template <typename E>
class OBComp {
public:
OBComp(const vector<pair<size_t, bool>>& sortIndices)
: _sortIndices(sortIndices) {}

bool operator()(const E& a, const E& b) const {
template <int I>
bool operator()(const typename IdTableImpl<I>::Row& a,
const typename IdTableImpl<I>::Row& b) const {
for (auto& entry : _sortIndices) {
if (a[entry.first] < b[entry.first]) {
return !entry.second;
Expand All @@ -29,4 +31,4 @@ class OBComp {

private:
vector<pair<size_t, bool>> _sortIndices;
};
};

0 comments on commit 6b71b66

Please sign in to comment.