Skip to content

Commit

Permalink
fix(cpp-client): Correctly process Deephaven NULL convention for type…
Browse files Browse the repository at this point in the history
…s with underlying int64 representation (#6137)
  • Loading branch information
kosak authored Sep 26, 2024
1 parent 2d7e09d commit e8e0c88
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cpp-client/deephaven/dhcore/src/utility/cython_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using deephaven::dhcore::column::StringArrayColumnSource;
namespace deephaven::dhcore::utility {
namespace {
void populateArrayFromPackedData(const uint8_t *src, bool *dest, size_t num_elements, bool invert);
void populateNullsFromDeephavenConvention(const int64_t *data_begin, bool *dest, size_t num_elements);
} // namespace

std::shared_ptr<ColumnSource>
Expand Down Expand Up @@ -61,9 +62,9 @@ CythonSupport::CreateDateTimeColumnSource(const int64_t *data_begin, const int64
auto nulls = std::make_unique<bool[]>(num_elements);

for (size_t i = 0; i != num_elements; ++i) {
elements[i] = DateTime(data_begin[i]);
elements[i] = DateTime::FromNanos(data_begin[i]);
}
populateArrayFromPackedData(validity_begin, nulls.get(), num_elements, true);
populateNullsFromDeephavenConvention(data_begin, nulls.get(), num_elements);
return DateTimeArrayColumnSource::CreateFromArrays(std::move(elements), std::move(nulls),
num_elements);
}
Expand All @@ -75,9 +76,9 @@ CythonSupport::CreateLocalDateColumnSource(const int64_t *data_begin, const int6
auto nulls = std::make_unique<bool[]>(num_elements);

for (size_t i = 0; i != num_elements; ++i) {
elements[i] = LocalDate(data_begin[i]);
elements[i] = LocalDate::FromMillis(data_begin[i]);
}
populateArrayFromPackedData(validity_begin, nulls.get(), num_elements, true);
populateNullsFromDeephavenConvention(data_begin, nulls.get(), num_elements);
return LocalDateArrayColumnSource::CreateFromArrays(std::move(elements), std::move(nulls),
num_elements);
}
Expand All @@ -89,9 +90,9 @@ CythonSupport::CreateLocalTimeColumnSource(const int64_t *data_begin, const int6
auto nulls = std::make_unique<bool[]>(num_elements);

for (size_t i = 0; i != num_elements; ++i) {
elements[i] = LocalTime(data_begin[i]);
elements[i] = LocalTime::FromNanos(data_begin[i]);
}
populateArrayFromPackedData(validity_begin, nulls.get(), num_elements, true);
populateNullsFromDeephavenConvention(data_begin, nulls.get(), num_elements);
return LocalTimeArrayColumnSource::CreateFromArrays(std::move(elements), std::move(nulls),
num_elements);
}
Expand Down Expand Up @@ -174,5 +175,11 @@ void populateArrayFromPackedData(const uint8_t *src, bool *dest, size_t num_elem
--num_elements;
}
}

void populateNullsFromDeephavenConvention(const int64_t *data_begin, bool *dest, size_t num_elements) {
for (size_t i = 0; i != num_elements; ++i) {
dest[i] = data_begin[i] == DeephavenConstants::kNullLong;
}
}
} // namespace
} // namespace deephaven::dhcore::utility

0 comments on commit e8e0c88

Please sign in to comment.