Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit dcfb714

Browse files
committed
Initial Project Skeleton
1 parent 4c67e1c commit dcfb714

File tree

11 files changed

+199
-0
lines changed

11 files changed

+199
-0
lines changed

.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BasedOnStyle: Chromium
2+
BinPackArguments: false
3+
BinPackParameters: false
4+
ColumnLimit: 90
5+
IndentWidth: 2
6+
BreakConstructorInitializers: BeforeComma
7+
IncludeBlocks: Preserve

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*
2+
.vscode

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 3.18.2)
2+
3+
project(
4+
HeterogeneousDataKernels
5+
VERSION 0.1
6+
LANGUAGES CXX
7+
)
8+
9+
# set default build type to "Release w/ Debug Info"
10+
set(default_build_type "RelWithDebInfo")
11+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
12+
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
13+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
14+
STRING "Choose the type of build." FORCE)
15+
# Set the possible values of build type for cmake-gui
16+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
17+
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
18+
endif()
19+
20+
add_subdirectory(src)
21+
22+
add_executable(TestDriver apps/TestDriver.cpp)
23+
24+
target_link_libraries(TestDriver PRIVATE HDK)
25+
target_include_directories(TestDriver PRIVATE src/)

apps/TestDriver.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "HDK.h"
2+
3+
#include <iostream>
4+
#include <memory>
5+
6+
int main(void) {
7+
auto input_data_type = std::make_unique<hdk::Int>();
8+
auto input_data = std::make_unique<hdk::Column>(std::move(input_data_type));
9+
auto output_type = std::make_unique<hdk::Int>();
10+
auto agg_expr = std::make_unique<hdk::Aggregate>(
11+
std::move(output_type), hdk::Aggregate::AggType::kCOUNT, std::move(input_data));
12+
13+
std::cout << "Test program worked: " << agg_expr->toString() << std::endl;
14+
}

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
2+
3+
add_library(HDK HDK.h HDK.cpp Expression/Expression.cpp)
4+

src/Expression/Expression.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "Expression/Expression.h"
2+
3+
namespace hdk {
4+
5+
std::string Column::toString() const {
6+
return "Column: " + type_->toString();
7+
}
8+
9+
std::string Aggregate::toString() const {
10+
return "Aggregate: " + aggTypeToString(agg_type_) + " (" + type_->toString() +
11+
") over " + target_expression_->toString();
12+
}
13+
14+
std::string Aggregate::aggTypeToString(const AggType type) {
15+
switch (type) {
16+
case AggType::kAVG:
17+
return "AVG";
18+
case AggType::kMIN:
19+
return "MIN";
20+
case AggType::kMAX:
21+
return "MAX";
22+
case AggType::kSUM:
23+
return "SUM";
24+
case AggType::kCOUNT:
25+
return "COUNT";
26+
}
27+
return "";
28+
}
29+
30+
} // namespace hdk

src/Expression/Expression.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "Expression/Types.h"
2+
3+
#include <memory>
4+
#include <string>
5+
6+
namespace hdk {
7+
8+
class Expression {
9+
public:
10+
Expression(std::unique_ptr<Type>&& type) : type_(std::move(type)) {}
11+
12+
virtual ~Expression() = default;
13+
14+
virtual std::string toString() const = 0;
15+
16+
Type* getTypeInfo() const { return type_.get(); }
17+
18+
protected:
19+
std::unique_ptr<Type> type_;
20+
};
21+
22+
class Column : public Expression {
23+
public:
24+
Column(std::unique_ptr<Type>&& type) : Expression(std::move(type)) {}
25+
26+
std::string toString() const override;
27+
};
28+
29+
// TODO: consider computing the output type based on the target expression over which we
30+
// are performing the aggregate
31+
class Aggregate : public Expression {
32+
public:
33+
enum class AggType { kAVG, kMIN, kMAX, kSUM, kCOUNT };
34+
35+
Aggregate(std::unique_ptr<Type>&& type,
36+
const AggType aggregate_type,
37+
std::unique_ptr<Expression>&& target_expression)
38+
: Expression(std::move(type))
39+
, agg_type_(aggregate_type)
40+
, target_expression_(std::move(target_expression)) {}
41+
42+
std::string toString() const override;
43+
44+
AggType getAggType() const { return agg_type_; }
45+
static std::string aggTypeToString(const AggType type);
46+
47+
private:
48+
AggType agg_type_;
49+
std::unique_ptr<Expression> target_expression_;
50+
};
51+
52+
} // namespace hdk

src/Expression/Types.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <cstdint>
2+
#include <string>
3+
4+
namespace hdk {
5+
6+
class Type {
7+
public:
8+
virtual ~Type() = default;
9+
10+
virtual int32_t size() const = 0;
11+
virtual std::string toString() const = 0;
12+
};
13+
14+
class TinyInt : public Type {
15+
public:
16+
int32_t size() const override { return 1; }
17+
18+
std::string toString() const override { return "TINYINT"; }
19+
};
20+
21+
class SmallInt : public Type {
22+
public:
23+
int32_t size() const override { return 2; }
24+
25+
std::string toString() const override { return "SMALLINT"; }
26+
};
27+
28+
class Int : public Type {
29+
public:
30+
int32_t size() const override { return 4; }
31+
32+
std::string toString() const override { return "INT"; }
33+
};
34+
35+
class BigInt : public Type {
36+
public:
37+
int32_t size() const override { return 8; }
38+
39+
std::string toString() const override { return "BIGINT"; }
40+
};
41+
42+
class Float : public Type {
43+
public:
44+
int32_t size() const override { return 4; }
45+
46+
std::string toString() const override { return "FLOAT"; }
47+
};
48+
49+
class Double : public Type {
50+
public:
51+
int32_t size() const override { return 8; }
52+
53+
std::string toString() const override { return "DOUBLE"; }
54+
};
55+
56+
class String : public Type {
57+
public:
58+
int32_t size() const override { return -1; }
59+
60+
std::string toString() const override { return "STRING"; }
61+
};
62+
63+
} // namespace hdk

src/HDK.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "HDK.h"

src/HDK.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "Expression/Expression.h"

0 commit comments

Comments
 (0)