[ 
https://issues.apache.org/jira/browse/ARROW-12804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chenxi Li updated ARROW-12804:
------------------------------
    Description: 
I'm not sure if this is a bug or by design.

Array's method {{IsNull()}} and {{IsValid()}} is implemented as follows:
{code:c++}
/// \brief Return true if value at index is null. Does not boundscheck
bool IsNull(int64_t i) const {
  return null_bitmap_data_ != NULLPTR &&
         !BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}

/// \brief Return true if value at index is valid (not null). Does not
/// boundscheck
bool IsValid(int64_t i) const {
  return null_bitmap_data_ == NULLPTR ||
         BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}
{code}
According to the doc, "Arrays having a 0 null count may choose to not allocate 
the null bitmap". But a null type array doesn't have a null bitmap. So for a 
null type array, {{IsNull()}} always returns false, {{IsValid()}} always 
returns true.

If this is by design, maybe additional comments and docs should be added.

  was:
I'm not sure if this is a bug or by design.

Array's method {{IsNull()}} and {{IsValid()}} is implemented as follows:
{code:c++}
/// \brief Return true if value at index is null. Does not boundscheck
bool IsNull(int64_t i) const {
  return null_bitmap_data_ != NULLPTR &&
         !BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}

/// \brief Return true if value at index is valid (not null). Does not
/// boundscheck
bool IsValid(int64_t i) const {
  return null_bitmap_data_ == NULLPTR ||
         BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}
{code}
According to the doc, "Arrays having a 0 null count may choose to not allocate 
the null bitmap". But a null type array doesn't have a null bitmap. So for a 
null type array, {{IsNull()}} always returns false, {{IsValid()}} always 
returns true.

 

If this is by design, maybe additional comments and docs should be added.


> [C++] Array methods IsNull and IsValid is confused for NullType
> ---------------------------------------------------------------
>
>                 Key: ARROW-12804
>                 URL: https://issues.apache.org/jira/browse/ARROW-12804
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>            Reporter: Chenxi Li
>            Priority: Major
>
> I'm not sure if this is a bug or by design.
> Array's method {{IsNull()}} and {{IsValid()}} is implemented as follows:
> {code:c++}
> /// \brief Return true if value at index is null. Does not boundscheck
> bool IsNull(int64_t i) const {
>   return null_bitmap_data_ != NULLPTR &&
>          !BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
> }
> /// \brief Return true if value at index is valid (not null). Does not
> /// boundscheck
> bool IsValid(int64_t i) const {
>   return null_bitmap_data_ == NULLPTR ||
>          BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
> }
> {code}
> According to the doc, "Arrays having a 0 null count may choose to not 
> allocate the null bitmap". But a null type array doesn't have a null bitmap. 
> So for a null type array, {{IsNull()}} always returns false, {{IsValid()}} 
> always returns true.
> If this is by design, maybe additional comments and docs should be added.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to