Skip to content

Commit

Permalink
Address PR feedback from @davidwendt.
Browse files Browse the repository at this point in the history
Tweak the switch statement in avro_decode_row().
  • Loading branch information
tpn committed Mar 16, 2023
1 parent 5173135 commit 75dbbc9
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions cpp/src/io/avro/avro_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -109,40 +109,36 @@ avro_decode_row(schemadesc_s const* schema,
}
break;

case type_int: [[fallthrough]];
case type_long: [[fallthrough]];
case type_int: {
int64_t v = avro_decode_zigzag_varint(cur, end);
static_cast<int32_t*>(dataptr)[row] = static_cast<int32_t>(v);
} break;

case type_long: {
int64_t v = avro_decode_zigzag_varint(cur, end);
static_cast<int64_t*>(dataptr)[row] = v;
} break;

case type_bytes: [[fallthrough]];
case type_fixed: [[fallthrough]];
case type_string: [[fallthrough]];
case type_uuid: [[fallthrough]];
case type_enum: {
int64_t v = avro_decode_zigzag_varint(cur, end);
if (kind == type_int) {
if (dataptr != nullptr && row < max_rows) {
static_cast<int32_t*>(dataptr)[row] = static_cast<int32_t>(v);
}
} else if (kind == type_long) {
if (dataptr != nullptr && row < max_rows) { static_cast<int64_t*>(dataptr)[row] = v; }
} else if (kind == type_fixed) {
CUDF_UNREACHABLE("avro type 'fixed' type not yet implemented");
} else { // string, uuid, or enum
size_t count = 0;
const char* ptr = nullptr;
if (kind == type_enum) { // dictionary
size_t idx = schema[i].count + v;
if (idx < global_dictionary.size()) {
ptr = global_dictionary[idx].first;
count = global_dictionary[idx].second;
}
} else if (v >= 0 && cur + v <= end) { // string or uuid
ptr = reinterpret_cast<const char*>(cur);
count = (size_t)v;
cur += count;
}
if (dataptr != nullptr && row < max_rows) {
static_cast<string_index_pair*>(dataptr)[row].first = ptr;
static_cast<string_index_pair*>(dataptr)[row].second = count;
int64_t v = avro_decode_zigzag_varint(cur, end);
size_t count = 0;
const char* ptr = nullptr;
if (kind == type_enum) { // dictionary
size_t idx = schema[i].count + v;
if (idx < global_dictionary.size()) {
ptr = global_dictionary[idx].first;
count = global_dictionary[idx].second;
}
} else if (v >= 0 && cur + v <= end) { // string or bytes
ptr = reinterpret_cast<const char*>(cur);
count = (size_t)v;
cur += count;
}
if (dataptr != nullptr && row < max_rows) {
static_cast<string_index_pair*>(dataptr)[row].first = ptr;
static_cast<string_index_pair*>(dataptr)[row].second = count;
}
} break;

Expand Down

0 comments on commit 75dbbc9

Please sign in to comment.