Skip to content

Commit

Permalink
fix warning unreachable code in datetime.cuh (#6281)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikeyann authored Sep 23, 2020
1 parent b418eb4 commit 2a75339
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
- PR #6259 Fix compilation error with GCC 8
- PR #6258 Pin libcudf conda recipe to boost 1.72.0
- PR #6264 Remove include statement for missing rmm/mr/device/default_memory_resource.hpp file
- PR #6281 Fix unreachable code warning in datetime.cuh
- PR #6286 Fix `read_csv` `int32` overflow
- PR #6289 Revert #6206
- PR #6304 Fix span_tests.cu includes
Expand Down
52 changes: 26 additions & 26 deletions cpp/src/io/csv/datetime.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -417,34 +417,34 @@ __inline__ __device__ int64_t parseTimeDeltaFormat(const char* data, long start,
// single pass to parse days, hour, minute, seconds, nanosecond
long moving_pos = start;
int32_t value = parse_integer<int>(data, moving_pos, end);
if (std::is_same<T, cudf::duration_D>::value) return value;
while (data[moving_pos] == ' ') moving_pos++;
if (moving_pos >= end) return value; // %value
// " days [+]"
const bool days_seperator = is_present(data, moving_pos, end, "days", 4);
while (data[moving_pos] == ' ') moving_pos++;
moving_pos += (data[moving_pos] == '+');
if (days_seperator) {
days = value;
hour = parse_integer<int>(data, moving_pos, end);
while (data[moving_pos] == ' ' && moving_pos <= end) moving_pos++;
if (std::is_same<T, cudf::duration_D>::value || moving_pos >= end) { // %value
return value;
} else {
hour = value;
}
// " days [+]"
const bool days_seperator = is_present(data, moving_pos, end, "days", 4);
while (data[moving_pos] == ' ' && moving_pos <= end) moving_pos++;
moving_pos += (data[moving_pos] == '+');
if (days_seperator) {
days = value;
hour = parse_integer<int>(data, moving_pos, end);
} else {
hour = value;
}

//:%M:%S
if (data[moving_pos] == sep) { minute = parse_integer<int>(data, ++moving_pos, end); }
if (data[moving_pos] == sep) { second = parse_integer<int>(data, ++moving_pos, end); }
if (std::is_same<T, cudf::duration_s>::value) {
return ((days * 24L + hour) * 60L + minute) * 60L + second;
}
//.n
if (data[moving_pos] == '.') {
auto start_subsecond = moving_pos + 1;
nanosecond = parse_integer<int>(data, ++moving_pos, end);
int8_t num_digits = min(9L, moving_pos - start_subsecond);
constexpr int64_t powers_of_ten[] = {
1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L};
nanosecond *= powers_of_ten[9 - num_digits];
//:%M:%S
if (data[moving_pos] == sep) { minute = parse_integer<int>(data, ++moving_pos, end); }
if (data[moving_pos] == sep) { second = parse_integer<int>(data, ++moving_pos, end); }
if (std::is_same<T, cudf::duration_s>::value) {
return ((days * 24L + hour) * 60L + minute) * 60L + second;
} else if (data[moving_pos] == '.') { //.n
auto start_subsecond = moving_pos + 1;
nanosecond = parse_integer<int>(data, ++moving_pos, end);
int8_t num_digits = min(9L, moving_pos - start_subsecond);
constexpr int64_t powers_of_ten[] = {
1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L};
nanosecond *= powers_of_ten[9 - num_digits];
}
}

return simt::std::chrono::duration_cast<T>(
Expand Down

0 comments on commit 2a75339

Please sign in to comment.