diff --git a/src/value.cpp b/src/value.cpp index afff4a7f1..c8a2239b4 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -210,18 +210,8 @@ Value::Value(const DataType::ConstPtr& data_type, Decoder decoder) bool Value::update(const Decoder& decoder) { decoder_ = decoder; is_null_ = decoder_.is_null(); - if (!is_null_) { - if (data_type_->is_collection()) { - return decoder_.decode_int32(count_); - } else if (data_type_->is_tuple()) { - const CompositeType& composite_type = static_cast(*data_type_); - count_ = composite_type.types().size(); - } else if (data_type_->is_user_type()) { - const UserType& user_type = static_cast(*data_type_); - count_ = user_type.fields().size(); - } - } else { - count_ = 0; + if (!is_null_ && data_type_->is_collection()) { + return decoder_.decode_int32(count_); } return true; } diff --git a/src/value.hpp b/src/value.hpp index 109a677a5..5145cea0f 100644 --- a/src/value.hpp +++ b/src/value.hpp @@ -102,27 +102,15 @@ class Value { bool is_null() const { return is_null_; } - bool is_collection() const { - if (!data_type_) return false; - return data_type_->is_collection(); - } + bool is_collection() const { return data_type_ && data_type_->is_collection(); } - bool is_map() const { - if (!data_type_) return false; - return data_type_->is_map(); - } + bool is_map() const { return data_type_ && data_type_->is_map(); } - bool is_tuple() const { - if (!data_type_) return false; - return data_type_->is_tuple(); - } + bool is_tuple() const { return data_type_ && data_type_->is_tuple(); } - bool is_user_type() const { - if (!data_type_) return false; - return data_type_->is_user_type(); - } + bool is_user_type() const { return data_type_ && data_type_->is_user_type(); } - int32_t count() const { return count_; } + int32_t count() const { return count_ * !is_null_; } StringRef to_string_ref() const { if (is_null()) return StringRef();