Skip to content

Commit

Permalink
fix makearray and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joellubi committed Aug 1, 2024
1 parent ccaf250 commit 0ca8901
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/bool8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::shared_ptr<Array> Bool8Type::MakeArray(
DCHECK_EQ(data->type->id(), Type::EXTENSION);
DCHECK_EQ("arrow.bool8",
internal::checked_cast<const ExtensionType&>(*data->type).extension_name());
return std::make_shared<ExtensionArray>(data);
return std::make_shared<Bool8Array>(data);
}

Result<std::shared_ptr<DataType>> Bool8Type::Make() {
Expand Down
14 changes: 13 additions & 1 deletion cpp/src/arrow/extension/bool8.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@
namespace arrow {
namespace extension {

class ARROW_EXPORT Bool8Array : public ExtensionArray {};
/// \brief Bool8 is an alternate representation for boolean
/// arrays using 8 bits instead of 1 bit per value. The underlying
/// storage type is int8.
class ARROW_EXPORT Bool8Array : public ExtensionArray {
public:
using ExtensionArray::ExtensionArray;
};

/// \brief Bool8 is an alternate representation for boolean
/// arrays using 8 bits instead of 1 bit per value. The underlying
/// storage type is int8.
class ARROW_EXPORT Bool8Type : public ExtensionType {
public:
/// \brief Construct a Bool8Type.
Bool8Type(): ExtensionType(int8()) {}

std::string extension_name() const override { return "arrow.bool8"; }
Expand All @@ -37,11 +47,13 @@ class ARROW_EXPORT Bool8Type : public ExtensionType {
std::shared_ptr<DataType> storage_type,
const std::string& serialized_data) const override;

/// Create a Bool8Array from ArrayData
std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;

static Result<std::shared_ptr<DataType>> Make();
};

/// \brief Return a Bool8Type instance.
ARROW_EXPORT std::shared_ptr<DataType> bool8();

} // namespace extension
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/extension/bool8_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ TEST(Bool8Type, BatchRoundTrip) {
ASSERT_BATCHES_EQUAL(*batch, *written);
}

} // namespace arrow
} // namespace arrow

0 comments on commit 0ca8901

Please sign in to comment.