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

Small refactoring changes #1257

Merged
merged 6 commits into from
Feb 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CompilationInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ endif()
message(STATUS "GIT_HASH is ${GIT_HASH}")

# Write the .cpp file.
set(CONSTANTS "#include <string>
set(CONSTANTS "#include \"CompilationInfo.h\"
namespace qlever::version {
const char* GitHash = ${GIT_HASH};
const char* DatetimeOfCompilation = ${DATETIME_OF_COMPILATION};
constexpr std::string_view GitHash = ${GIT_HASH};
constexpr std::string_view GitShortHash = GitHash.substr(0, 6);
constexpr std::string_view DatetimeOfCompilation = ${DATETIME_OF_COMPILATION};
}")

# For some reason `CMAKE_CURRENT_SOURCE_DIR` inside this script is
Expand Down
10 changes: 4 additions & 6 deletions src/CompilationInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
// File `CompilationInfo.cpp` which is created and linked by CMake.

#pragma once
#include <string>
#include <string_view>
namespace qlever::version {
// The git hash of the commit that was used to QLever.
extern const char* GitHash;
// Short version of the hash of the commit that was used to QLever.
extern const std::string_view GitShortHash;
// The date and time at which QLever was compiled.
extern const char* DatetimeOfCompilation;

inline std::string GitShortHash() { return std::string{GitHash}.substr(0, 6); }
extern const std::string_view DatetimeOfCompilation;
} // namespace qlever::version
5 changes: 1 addition & 4 deletions src/ServerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ using std::string;

namespace po = boost::program_options;

#define EMPH_ON "\033[1m"
#define EMPH_OFF "\033[22m"

// Main function.
int main(int argc, char** argv) {
setlocale(LC_CTYPE, "");
Expand Down Expand Up @@ -124,7 +121,7 @@ int main(int argc, char** argv) {

LOG(INFO) << EMPH_ON << "QLever Server, compiled on "
<< qlever::version::DatetimeOfCompilation << " using git hash "
<< qlever::version::GitShortHash() << EMPH_OFF << std::endl;
<< qlever::version::GitShortHash << EMPH_OFF << std::endl;

try {
Server server(port, numSimultaneousQueries, memoryMaxSize,
Expand Down
35 changes: 0 additions & 35 deletions src/engine/Comparators.h

This file was deleted.

10 changes: 3 additions & 7 deletions src/engine/Distinct.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
// Author: Björn Buchhold ([email protected])
#pragma once

#include <list>
#include <utility>
#include <vector>

#include "../parser/ParsedQuery.h"
#include "./Operation.h"
#include "./QueryExecutionTree.h"
#include "engine/Operation.h"
#include "engine/QueryExecutionTree.h"
#include "parser/ParsedQuery.h"

using std::list;

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

class Distinct : public Operation {
Expand Down
4 changes: 0 additions & 4 deletions src/engine/Join.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@

#pragma once

#include <list>

#include "engine/IndexScan.h"
#include "engine/Operation.h"
#include "engine/QueryExecutionTree.h"
#include "util/HashMap.h"
#include "util/HashSet.h"
#include "util/JoinAlgorithms/JoinAlgorithms.h"

using std::list;

class Join : public Operation {
private:
std::shared_ptr<QueryExecutionTree> _left;
Expand Down
8 changes: 2 additions & 6 deletions src/engine/OptionalJoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
// Florian Kramer ([email protected])
#pragma once

#include <list>

#include "./Operation.h"
#include "./QueryExecutionTree.h"

using std::list;
#include "engine/Operation.h"
#include "engine/QueryExecutionTree.h"

class OptionalJoin : public Operation {
private:
Expand Down
1 change: 0 additions & 1 deletion src/engine/OrderBy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <sstream>

#include "engine/CallFixedSize.h"
#include "engine/Comparators.h"
#include "engine/QueryExecutionTree.h"
#include "global/ValueIdComparators.h"

Expand Down
7 changes: 6 additions & 1 deletion src/global/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <limits>
#include <stdexcept>
#include <string>
#include <string_view>

#include "util/MemorySize/MemorySize.h"
#include "util/Parameters.h"
Expand Down Expand Up @@ -267,4 +268,8 @@ auto parallel_sort([[maybe_unused]] Args&&... args) {
using parallel_tag = int;
} // namespace ad_utility
#endif
static constexpr size_t NUM_SORT_THREADS = 4;
constexpr size_t NUM_SORT_THREADS = 4;
/// ANSI escape sequence for bold text in the console
constexpr std::string_view EMPH_ON = "\033[1m";
RobinTF marked this conversation as resolved.
Show resolved Hide resolved
/// ANSI escape sequence to print "normal" text again in the console.
constexpr std::string_view EMPH_OFF = "\033[22m";
5 changes: 1 addition & 4 deletions src/index/IndexBuilderMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

using std::string;

#define EMPH_ON "\033[1m"
#define EMPH_OFF "\033[22m"

namespace po = boost::program_options;

string getStxxlConfigFileName(const string& location) {
Expand Down Expand Up @@ -166,7 +163,7 @@ int main(int argc, char** argv) {

LOG(INFO) << EMPH_ON << "QLever IndexBuilder, compiled on "
<< qlever::version::DatetimeOfCompilation << " using git hash "
<< qlever::version::GitShortHash() << EMPH_OFF << std::endl;
<< qlever::version::GitShortHash << EMPH_OFF << std::endl;

try {
LOG(TRACE) << "Configuring STXXL..." << std::endl;
Expand Down
5 changes: 2 additions & 3 deletions src/index/IndexImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ void IndexImpl::setPrefixCompression(bool compressed) {
void IndexImpl::writeConfiguration() const {
// Copy the configuration and add the current commit hash.
auto configuration = configurationJson_;
configuration["git-hash"] = std::string(qlever::version::GitHash);
configuration["git-hash"] = qlever::version::GitShortHash;
configuration["index-format-version"] = qlever::indexFormatVersion;
auto f = ad_utility::makeOfstream(onDiskBase_ + CONFIGURATION_FILE);
f << configuration;
Expand All @@ -896,8 +896,7 @@ void IndexImpl::readConfiguration() {
f >> configurationJson_;
if (configurationJson_.find("git-hash") != configurationJson_.end()) {
LOG(INFO) << "The git hash used to build this index was "
<< std::string(configurationJson_["git-hash"]).substr(0, 6)
<< std::endl;
<< configurationJson_["git-hash"] << std::endl;
} else {
LOG(INFO) << "The index was built before git commit hashes were stored in "
"the index meta data"
Expand Down
Loading