Skip to content

[C++] Array methods IsNull and IsValid are not complementary #15721

Closed

Description

@asfimport

Hi, not sure if this is a bug or if I misinterpret the spec. According to the latter, "Arrays having a 0 null count may choose to not allocate the null bitmap". From this I'd infer that the statement also holds in the other direction, i.e. non-allocated bitmaps imply a 0 null count. This would mean that if a bitmap is not allocated, IsValid() should always return true. But at the moment it's doing this:

bool IsNull(int64_t i) const {
  return null_bitmap_data_ != NULLPTR &&
    BitUtil::BitNotSet(null_bitmap_data_, i + data_->offset);
}

bool IsValid(int64_t i) const {
  return null_bitmap_data_ != NULLPTR &&
    BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}

Which leads to a situation where in the case of non-allocated bitmaps values are neither Null nor Valid. Shouldn't it rather be:

bool IsValid(int64_t i) const {
  return null_bitmap_data_ == NULLPTR ||
    BitUtil::GetBit(null_bitmap_data_, i + data_->offset);
}

?

Reporter: Thomas Buhrmann / @buhrmann
Assignee: Antoine Pitrou / @pitrou

Related issues:

Note: This issue was originally created as ARROW-2622. Please see the migration documentation for further details.

Activity

  1. asfimport commented on May 26, 2018

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    Yes, you're right that IsValid seems buggy here. Do you want to propose a PR?

  2. asfimport commented on Feb 6, 2019

    @asfimport
    Author

    Antoine Pitrou / @pitrou:
    Looks like this was fixed in ARROW-2641.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions