Skip to content

Commit

Permalink
feat(boolean columns): add bool to JsonValueType, update tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
pflanze committed Apr 11, 2024
1 parent 2ad1268 commit 3c990e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/silo/common/json_value_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

namespace silo::common {

using JsonValueType = std::optional<std::variant<std::string, int32_t, double>>;
using JsonValueType = std::optional<std::variant<std::string, bool, int32_t, double>>;

}
18 changes: 18 additions & 0 deletions src/silo/query_engine/actions/tuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ silo::common::JsonValueType tupleFieldToValueType(
*data_pointer += sizeof(decltype(value));
return silo::common::dateToString(value);
}
if (metadata.type == ColumnType::BOOL) {
const OptionalBool value = *reinterpret_cast<const OptionalBool*>(*data_pointer);
*data_pointer += sizeof(decltype(value));
if (value.isNull()) {
return std::nullopt;
}
return value.value();
}
if (metadata.type == ColumnType::INT) {
const int32_t value = *reinterpret_cast<const int32_t*>(*data_pointer);
*data_pointer += sizeof(decltype(value));
Expand Down Expand Up @@ -202,6 +210,13 @@ std::strong_ordering compareTupleFields(
*data_pointer2 += sizeof(decltype(value2));
return value1 <=> value2;
}
if (metadata.type == ColumnType::BOOL) {
const OptionalBool value1 = *reinterpret_cast<const OptionalBool*>(*data_pointer1);
*data_pointer1 += sizeof(decltype(value1));
const OptionalBool value2 = *reinterpret_cast<const OptionalBool*>(*data_pointer2);
*data_pointer2 += sizeof(decltype(value2));
return value1 <=> value2;
}
if (metadata.type == ColumnType::INT) {
const int32_t value1 = *reinterpret_cast<const int32_t*>(*data_pointer1);
*data_pointer1 += sizeof(decltype(value1));
Expand Down Expand Up @@ -288,6 +303,9 @@ size_t getColumnSize(const silo::storage::ColumnMetadata& metadata) {
if (metadata.type == silo::config::ColumnType::FLOAT) {
return sizeof(double);
}
if (metadata.type == silo::config::ColumnType::BOOL) {
return sizeof(OptionalBool);
}
if (metadata.type == silo::config::ColumnType::INT) {
return sizeof(int32_t);
}
Expand Down

0 comments on commit 3c990e2

Please sign in to comment.