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

Added GetSize() const method for FixedStringType #355

Merged
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
2 changes: 2 additions & 0 deletions clickhouse/types/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class FixedStringType : public Type {

std::string GetName() const { return std::string("FixedString(") + std::to_string(size_) + ")"; }

inline size_t GetSize() const { return size_; }

private:
size_t size_;
};
Expand Down
16 changes: 16 additions & 0 deletions ut/columns_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ TEST(ColumnsCase, FixedString_Append_LargeString) {
EXPECT_ANY_THROW(col->Append("this is a long string"));
}

TEST(ColumnsCase, FixedString_Type_Size_Eq0) {
const auto col = std::make_shared<ColumnFixedString>(0);
ASSERT_EQ(col->FixedSize(), col->Type()->As<FixedStringType>()->GetSize());
}

TEST(ColumnsCase, FixedString_Type_Size_Eq10) {
const auto col = std::make_shared<ColumnFixedString>(10);
ASSERT_EQ(col->FixedSize(), col->Type()->As<FixedStringType>()->GetSize());
}

TEST(ColumnsCase, StringInit) {
auto values = MakeStrings();
auto col = std::make_shared<ColumnString>(values);
Expand Down Expand Up @@ -866,6 +876,12 @@ TEST(ColumnsCase, ColumnLowCardinalityString_WithEmptyString_3) {
}
}

TEST(ColumnsCase, ColumnLowCardinalityFixedString_Type_Size_Eq) {
const size_t fixed_size = 10;
const auto col = std::make_shared<ColumnLowCardinalityT<ColumnFixedString>>(fixed_size);

ASSERT_EQ(fixed_size, col->GetNestedType()->As<FixedStringType>()->GetSize());
}

TEST(ColumnsCase, ColumnTupleT) {
using TestTuple = ColumnTupleT<ColumnUInt64, ColumnString, ColumnFixedString>;
Expand Down