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

Move the ResultType enum to a separate file #437

Merged
merged 2 commits into from
Jul 22, 2021
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 src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ add_library(engine
IdTable.h
../util/Random.h
Minus.h Minus.cpp
)
ResultType.h)

target_link_libraries(engine index parser SortPerformanceEstimator absl::flat_hash_set)
19 changes: 2 additions & 17 deletions src/engine/ResultTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../global/Id.h"
#include "../util/Exception.h"
#include "IdTable.h"
#include "ResultType.h"

using std::array;
using std::condition_variable;
Expand All @@ -23,23 +24,7 @@ using std::vector;
class ResultTable {
public:
enum Status { IN_PROGRESS = 0, FINISHED = 1, ABORTED = 2 };

/**
* @brief Describes the type of a columns data
*/
enum class ResultType {
// An entry in the knowledgebase
KB,
// An unsigned integer (size_t)
VERBATIM,
// A byte offset in the text index
TEXT,
// A 32 bit float, stored in the first 4 bytes of the entry. The last four
// bytes have to be zero.
FLOAT,
// An entry in the ResultTable's _localVocab
LOCAL_VOCAB
};
using ResultType = qlever::ResultType;

/**
* @brief This vector contains a list of column indices by which the result
Expand Down
27 changes: 27 additions & 0 deletions src/engine/ResultType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Created by johannes on 09.05.21.
//

#ifndef QLEVER_RESULTTYPE_H
#define QLEVER_RESULTTYPE_H

namespace qlever {
/**
* @brief Describes the type of a columns data
*/
enum class ResultType {
// An entry in the knowledgebase
KB,
// An unsigned integer (size_t)
VERBATIM,
// A byte offset in the text index
TEXT,
// A 32 bit float, stored in the first 4 bytes of the entry. The last four
// bytes have to be zero.
FLOAT,
// An entry in the ResultTable's _localVocab
LOCAL_VOCAB
};
} // namespace qlever

#endif // QLEVER_RESULTTYPE_H
9 changes: 4 additions & 5 deletions src/parser/ParsedQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <variant>
#include <vector>

#include "../engine/ResultTable.h"
#include "../engine/ResultType.h"
#include "../util/Exception.h"
#include "../util/HashMap.h"
#include "../util/StringUtils.h"
Expand Down Expand Up @@ -397,8 +397,7 @@ struct GraphPatternOperation {
struct Constant {
int64_t _intValue = 0; // the Value of an integer constant (VERBATIM)
string _kbValue; // the value of a knowledge base entity or literal (KB)
ResultTable::ResultType
_type; // the type, currently always KB or VERBATIM
qlever::ResultType _type; // the type, currently always KB or VERBATIM

Constant() = default;

Expand All @@ -407,12 +406,12 @@ struct GraphPatternOperation {
explicit Constant(int64_t val)
: _intValue(val),
_kbValue(std::to_string(val)),
_type(ResultTable::ResultType::VERBATIM) {}
_type(qlever::ResultType::VERBATIM) {}
// Initialize a KB constant. If the argument string is not part of the KB
// this will lead to an error later on (currently no possibility to
// already check this during parsing
explicit Constant(std::string entry)
: _kbValue(std::move(entry)), _type(ResultTable::ResultType::KB) {}
: _kbValue(std::move(entry)), _type(qlever::ResultType::KB) {}
// TODO<joka921> in c++ 20 we have constexpr strings.
static constexpr const char* Name = "Constant";
// Some other functions need this interface, for example,
Expand Down