Skip to content

[proposition] mask-based implementation for missing values #441

Description

@tnielens

Currently, saddle uses one value of each primitive type to represent NA. For floating point numbers, this is straightforward as they already include such a value. For other types (Boolean, Byte, Int, etc), it isn't straightforward and an arbitrary value must be used. Currently the minimum value is used (Byte.MinValue, Short.MinValue, etc).

I think this approach has important drawbacks:

  • users are unlikely to know about that encoding and could use the min values. That leads to surprising behavior.
  • operations resulting in the MinValue would result in a missing value.
  • the binary operations on collections lose in simplicity. Implementation such as if (tag.isMissing(v1)) v1 else v1 + 2 might prevent loop optimizations of the jvm to kick-in.
  • the .raw(i)-like api exposes unnecessary complexity to the user.

An alternative approach would be to use a mask-based implementation for the integer-based Vec[T]s. That is, the vector stores a companion Array[Boolean] indicating missing value. This approach is used by pandas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions