Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Client: some cleanups found while working on Windows port #4797

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cpp-client/deephaven/dhclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ set(ALL_FILES

src/impl/aggregate_impl.cc
src/impl/client_impl.cc
src/impl/escape_utils.cc
src/impl/table_handle_impl.cc
src/impl/table_handle_manager_impl.cc
src/impl/update_by_operation_impl.cc

include/private/deephaven/client/impl/aggregate_impl.h
include/private/deephaven/client/impl/client_impl.h
include/private/deephaven/client/impl/escape_utils.h
include/private/deephaven/client/impl/table_handle_impl.h
include/private/deephaven/client/impl/table_handle_manager_impl.h
include/private/deephaven/client/impl/update_by_operation_impl.h
Expand Down

This file was deleted.

61 changes: 0 additions & 61 deletions cpp-client/deephaven/dhclient/src/impl/escape_utils.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct ImmerColumnSourceImpls {
for (const T *current = data_begin; current != data_end; ++current) {
auto value = *current;
*dest_datap++ = value;
if constexpr(kTypeIsNumeric) {
if constexpr(deephaven::dhcore::DeephavenTraits<T>::kIsNumeric) {
if (dest_nullp != nullptr) {
*dest_nullp++ = value == deephaven::dhcore::DeephavenTraits<T>::kNullValue;
}
Expand All @@ -74,16 +74,16 @@ struct ImmerColumnSourceImpls {
}
};

auto copyOuter = [&src_data, src_null_flags, dest_nullp, &copy_data_inner,
&copy_nulls_inner](uint64_t srcBegin, uint64_t srcEnd) {
auto src_beginp = src_data.begin() + srcBegin;
auto src_endp = src_data.begin() + srcEnd;
auto copy_outer = [&src_data, src_null_flags, dest_nullp, &copy_data_inner,
&copy_nulls_inner](uint64_t src_begin, uint64_t src_end) {
auto src_beginp = src_data.begin() + src_begin;
auto src_endp = src_data.begin() + src_end;
immer::for_each_chunk(src_beginp, src_endp, copy_data_inner);

if constexpr(!kTypeIsNumeric) {
if constexpr(!deephaven::dhcore::DeephavenTraits<T>::kIsNumeric) {
if (dest_nullp != nullptr) {
auto nulls_begin = src_null_flags->begin() + srcBegin;
auto nulls_end = src_null_flags->begin() + srcEnd;
auto nulls_begin = src_null_flags->begin() + src_begin;
auto nulls_end = src_null_flags->begin() + src_end;
immer::for_each_chunk(nulls_begin, nulls_end, copy_nulls_inner);
}
} else {
Expand All @@ -93,7 +93,7 @@ struct ImmerColumnSourceImpls {
(void)copy_nulls_inner;
}
};
rows.ForEachInterval(copyOuter);
rows.ForEachInterval(copy_outer);
}

template<typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,9 @@ class DateTime {
[[nodiscard]]
int64_t Nanos() const { return nanos_; }

/**
* Used internally to serialize this object to Deephaven.
*/
void StreamIrisRepresentation(std::ostream &result) const;

private:
int64_t nanos_ = 0;

friend std::ostream &operator<<(std::ostream &s, const DateTime &o) {
o.StreamIrisRepresentation(s);
return s;
}
friend std::ostream &operator<<(std::ostream &s, const DateTime &o);
};
} // namespace deephaven::dhcore
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ internal::SeparatedListAdaptor<Iterator, Callback> separatedList(Iterator begin,
#define DEEPHAVEN_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__GNUC__)
#define DEEPHAVEN_PRETTY_FUNCTION __PRETTY_FUNCTION__
#elif defined(__MSC_VER)
#elif defined(_MSC_VER)
#define DEEPHAVEN_PRETTY_FUNCTION __FUNCSIG__
#else
# error Unsupported compiler
#error "Don't have a specialization of DEEPHAVEN_PRETTY_FUNCTION for your compiler"
#endif

class DebugInfo {
Expand All @@ -186,8 +186,8 @@ std::string FormatDebugString(const char *func, const char *file, size_t line,
* containing with __PRETTY_FUNCTION__, __FILE__, __LINE__ and the stringified arguments. This is
* useful for functions who want to throw an exception with caller information.
*/
#define DEEPHAVEN_LOCATION_EXPR(ARGS...) \
::deephaven::dhcore::utility::DebugInfo(DEEPHAVEN_PRETTY_FUNCTION, __FILE__, __LINE__, #ARGS),ARGS
#define DEEPHAVEN_LOCATION_EXPR(...) \
::deephaven::dhcore::utility::DebugInfo(DEEPHAVEN_PRETTY_FUNCTION, __FILE__, __LINE__, #__VA_ARGS__),__VA_ARGS__

#define DEEPHAVEN_LOCATION_STR(MESSAGE) \
::deephaven::dhcore::utility::FormatDebugString( \
Expand Down
87 changes: 44 additions & 43 deletions cpp-client/deephaven/dhcore/src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,45 @@ using deephaven::dhcore::utility::Stringf;


namespace deephaven::dhcore {
const char16_t DeephavenConstants::kNullChar;

const float DeephavenConstants::kNullFloat;
const float DeephavenConstants::kNanFloat;
const float DeephavenConstants::kNegInfinityFloat;
const float DeephavenConstants::kPosInfinityFloat;
const float DeephavenConstants::kMinFloat;
const float DeephavenConstants::kMaxFloat;
const float DeephavenConstants::kMinFiniteFloat =
constexpr const char16_t DeephavenConstants::kNullChar;

constexpr const float DeephavenConstants::kNullFloat;
constexpr const float DeephavenConstants::kNanFloat;
constexpr const float DeephavenConstants::kNegInfinityFloat;
constexpr const float DeephavenConstants::kPosInfinityFloat;
constexpr const float DeephavenConstants::kMinFloat;
constexpr const float DeephavenConstants::kMaxFloat;
/* constexpr clang dislikes */ const float DeephavenConstants::kMinFiniteFloat =
std::nextafter(-std::numeric_limits<float>::max(), 0.0F);
const float DeephavenConstants::kMaxFiniteFloat;
const float DeephavenConstants::kMinPosFloat;

const double DeephavenConstants::kNullDouble;
const double DeephavenConstants::kNanDouble;
const double DeephavenConstants::kNegInfinityDouble;
const double DeephavenConstants::kPosInfinityDouble;
const double DeephavenConstants::kMinDouble;
const double DeephavenConstants::kMaxDouble;
const double DeephavenConstants::kMinFiniteDouble =
constexpr const float DeephavenConstants::kMaxFiniteFloat;
constexpr const float DeephavenConstants::kMinPosFloat;

constexpr const double DeephavenConstants::kNullDouble;
constexpr const double DeephavenConstants::kNanDouble;
constexpr const double DeephavenConstants::kNegInfinityDouble;
constexpr const double DeephavenConstants::kPosInfinityDouble;
constexpr const double DeephavenConstants::kMinDouble;
constexpr const double DeephavenConstants::kMaxDouble;
/* constexpr clang dislikes */ const double DeephavenConstants::kMinFiniteDouble =
std::nextafter(-std::numeric_limits<double>::max(), 0.0);
const double DeephavenConstants::kMaxFiniteDouble;
const double DeephavenConstants::kMinPosDouble;
constexpr const double DeephavenConstants::kMaxFiniteDouble;
constexpr const double DeephavenConstants::kMinPosDouble;

const int8_t DeephavenConstants::kNullByte;
const int8_t DeephavenConstants::kMinByte;
const int8_t DeephavenConstants::kMaxByte;
constexpr const int8_t DeephavenConstants::kNullByte;
constexpr const int8_t DeephavenConstants::kMinByte;
constexpr const int8_t DeephavenConstants::kMaxByte;

const int16_t DeephavenConstants::kNullShort;
const int16_t DeephavenConstants::kMinShort;
const int16_t DeephavenConstants::kMaxShort;
constexpr const int16_t DeephavenConstants::kNullShort;
constexpr const int16_t DeephavenConstants::kMinShort;
constexpr const int16_t DeephavenConstants::kMaxShort;

const int32_t DeephavenConstants::kNullInt;
const int32_t DeephavenConstants::kMinInt;
const int32_t DeephavenConstants::kMaxInt;
constexpr const int32_t DeephavenConstants::kNullInt;
constexpr const int32_t DeephavenConstants::kMinInt;
constexpr const int32_t DeephavenConstants::kMaxInt;

const int64_t DeephavenConstants::kNullLong;
const int64_t DeephavenConstants::kMinLong;
const int64_t DeephavenConstants::kMaxLong;
constexpr const int64_t DeephavenConstants::kNullLong;
constexpr const int64_t DeephavenConstants::kMinLong;
constexpr const int64_t DeephavenConstants::kMaxLong;

DateTime DateTime::Parse(std::string_view iso_8601_timestamp) {
constexpr const char *kFormatToUse = "%Y-%m-%dT%H:%M:%S%z";
Expand Down Expand Up @@ -93,16 +93,17 @@ DateTime::DateTime(int year, int month, int day, int hour, int minute, int secon
nanos_ = static_cast<int64_t>(time) + nanos;
}

void DateTime::StreamIrisRepresentation(std::ostream &s) const {
size_t oneBillion = 1000000000;
time_t timeSecs = nanos_ / oneBillion;
auto nanos = nanos_ % oneBillion;
std::ostream &operator<<(std::ostream &s, const DateTime &o) {
size_t one_billions = 1'000'000'000;
time_t time_secs = o.nanos_ / one_billions;
auto nanos = o.nanos_ % one_billions;
struct tm tm = {};
gmtime_r(&timeSecs, &tm);
char dateBuffer[32]; // ample
char nanosBuffer[32]; // ample
strftime(dateBuffer, sizeof(dateBuffer), "%FT%T", &tm);
snprintf(nanosBuffer, sizeof(nanosBuffer), "%09zd", nanos);
s << dateBuffer << '.' << nanosBuffer << " UTC";
gmtime_r(&time_secs, &tm);
char date_buffer[32]; // ample
char nanos_buffer[32]; // ample
strftime(date_buffer, sizeof(date_buffer), "%FT%T", &tm);
snprintf(nanos_buffer, sizeof(nanos_buffer), "%09zd", nanos);
s << date_buffer << '.' << nanos_buffer << " UTC";
return s;
}
} // namespace deephaven::client
Loading