Skip to content

Commit

Permalink
Refactor structure of GetTypeForBuffers for Type::DICTIONARY
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Dec 6, 2024
1 parent a1ad4da commit eb25914
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions cpp/src/arrow/util/align_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,25 @@ namespace {
// Returns the type that controls how the buffers of this ArrayData (not its children)
// should behave
Type::type GetTypeForBuffers(const ArrayData& array) {
Type::type type_id = array.type->id();
Type::type storage_type_id = array.type->storage_id();
if (storage_type_id == Type::DICTIONARY) {
switch (type_id) {
Type::type type_id = array.type->storage_id();
if (type_id == Type::DICTIONARY) {
std::shared_ptr<DataType> dict_type;
switch (array.type->id()) {
case Type::DICTIONARY:
storage_type_id =
::arrow::internal::checked_pointer_cast<DictionaryType>(array.type)
->index_type()
->id();
dict_type = array.type;
break;
case Type::EXTENSION: {
auto dictExtType =
::arrow::internal::checked_pointer_cast<ExtensionType>(array.type);
storage_type_id = ::arrow::internal::checked_pointer_cast<DictionaryType>(
dictExtType->storage_type())
->index_type()
->id();
const auto ext_type = ::arrow::internal::checked_pointer_cast<ExtensionType>(array.type);
dict_type = ext_type->storage_type();
} break;
default:
break;
}
return ::arrow::internal::checked_pointer_cast<DictionaryType>(dict_type)
->index_type()
->id();
}
return storage_type_id;
return type_id;
}

// Checks to see if an array's own buffers are aligned but doesn't check
Expand Down

0 comments on commit eb25914

Please sign in to comment.