Skip to content

Commit

Permalink
a bunch of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Aug 5, 2024
1 parent cd9a895 commit 24496b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/include/common/arrow/arrow_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ struct ArrowBuffer {
private:
void reserveInternal(uint64_t bytes) {
if (dataptr) {
dataptr = (uint8_t*)realloc(dataptr, bytes);
dataptr = static_cast<uint8_t*>(realloc(dataptr, bytes));
} else {
dataptr = (uint8_t*)malloc(bytes);
dataptr = static_cast<uint8_t*>(malloc(bytes));
}
capacity = bytes;
}
Expand Down
10 changes: 5 additions & 5 deletions src/include/common/types/cast_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct DateToStringCast {
ptr[0] = '-';
if (date[i] < 10) {
ptr[1] = '0';
ptr[2] = '0' + date[i];
ptr[2] = static_cast<char>('0' + date[i]);
} else {
auto index = static_cast<unsigned>(date[i] * 2);
ptr[1] = digits[index];
Expand All @@ -138,8 +138,8 @@ struct TimeToStringCast {
while (endptr > micro_buffer) {
*--endptr = '0';
}
uint64_t trailing_zeros = 0;
for (uint64_t i = 5; i > 0; i--) {
int32_t trailing_zeros = 0;
for (int32_t i = 5; i > 0; i--) {
if (micro_buffer[i] != '0') {
break;
}
Expand Down Expand Up @@ -168,10 +168,10 @@ struct TimeToStringCast {
return length;
}

static void FormatTwoDigits(char* ptr, int32_t value) {
static void FormatTwoDigits(char* ptr, int64_t value) {
if (value < 10) {
ptr[0] = '0';
ptr[1] = '0' + value;
ptr[1] = static_cast<char>('0' + value);
} else {
auto index = static_cast<unsigned>(value * 2);
ptr[0] = digits[index];
Expand Down
4 changes: 2 additions & 2 deletions src/include/function/schema/label_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ namespace kuzu {
namespace function {

struct Label {
static inline void operation(common::internalID_t& left, common::list_entry_t& right,
static void operation(common::internalID_t& left, common::list_entry_t& right,
common::ku_string_t& result, common::ValueVector& leftVector,
common::ValueVector& rightVector, common::ValueVector& resultVector, uint64_t resPos) {
KU_ASSERT(left.tableID < right.size);
ListExtract::operation(right, left.tableID + 1 /* listExtract requires 1-based index */,
ListExtract::operation(right, left.tableID + 1u /* listExtract requires 1-based index */,
result, rightVector, leftVector, resultVector, resPos);
}
};
Expand Down
9 changes: 4 additions & 5 deletions src/include/function/string/functions/rpad_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace kuzu {
namespace function {

struct Rpad : BasePadOperation {
public:
static inline void operation(common::ku_string_t& src, int64_t count,
static void operation(common::ku_string_t& src, int64_t count,
common::ku_string_t& characterToPad, common::ku_string_t& result,
common::ValueVector& resultValueVector) {
BasePadOperation::operation(src, count, characterToPad, result, resultValueVector,
Expand All @@ -18,10 +17,10 @@ struct Rpad : BasePadOperation {
static void rpadOperation(common::ku_string_t& src, int64_t count,
common::ku_string_t& characterToPad, std::string& paddedResult) {
auto srcPadInfo =
BasePadOperation::padCountChars(count, (const char*)src.getData(), src.len);
auto srcData = (const char*)src.getData();
padCountChars(count, reinterpret_cast<const char*>(src.getData()), src.len);
auto srcData = reinterpret_cast<const char*>(src.getData());
paddedResult.insert(paddedResult.end(), srcData, srcData + srcPadInfo.first);
BasePadOperation::insertPadding(count - srcPadInfo.second, characterToPad, paddedResult);
insertPadding(count - srcPadInfo.second, characterToPad, paddedResult);
}
};

Expand Down
23 changes: 12 additions & 11 deletions src/include/function/ternary_function_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ namespace function {

struct TernaryFunctionWrapper {
template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename OP>
static inline void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
static void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
void* /*aValueVector*/, void* /*resultValueVector*/, void* /*dataPtr*/) {
OP::operation(a, b, c, result);
}
};

struct TernaryStringFunctionWrapper {
template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename OP>
static inline void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
static void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
void* /*aValueVector*/, void* resultValueVector, void* /*dataPtr*/) {
OP::operation(a, b, c, result, *(common::ValueVector*)resultValueVector);
OP::operation(a, b, c, result, *static_cast<common::ValueVector*>(resultValueVector));
}
};

struct TernaryListFunctionWrapper {
template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename OP>
static inline void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
void* aValueVector, void* resultValueVector, void* /*dataPtr*/) {
OP::operation(a, b, c, result, *(common::ValueVector*)aValueVector,
*(common::ValueVector*)resultValueVector);
static void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result, void* aValueVector,
void* resultValueVector, void* /*dataPtr*/) {
OP::operation(a, b, c, result, *static_cast<common::ValueVector*>(aValueVector),
*static_cast<common::ValueVector*>(resultValueVector));
}
};

struct TernaryUDFFunctionWrapper {
template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename OP>
static inline void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
static void operation(A_TYPE& a, B_TYPE& b, C_TYPE& c, RESULT_TYPE& result,
void* /*aValueVector*/, void* /*resultValueVector*/, void* dataPtr) {
OP::operation(a, b, c, result, dataPtr);
}
Expand All @@ -44,10 +44,11 @@ struct TernaryFunctionExecutor {
static void executeOnValue(common::ValueVector& a, common::ValueVector& b,
common::ValueVector& c, common::ValueVector& result, uint64_t aPos, uint64_t bPos,
uint64_t cPos, uint64_t resPos, void* dataPtr) {
auto resValues = (RESULT_TYPE*)result.getData();
auto resValues = static_cast<RESULT_TYPE*>(result.getData());
OP_WRAPPER::template operation<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, FUNC>(
((A_TYPE*)a.getData())[aPos], ((B_TYPE*)b.getData())[bPos],
((C_TYPE*)c.getData())[cPos], resValues[resPos], (void*)&a, (void*)&result, dataPtr);
static_cast<A_TYPE*>(a.getData())[aPos], static_cast<B_TYPE*>(b.getData())[bPos],
static_cast<C_TYPE*>(c.getData())[cPos], resValues[resPos], static_cast<void*>(&a),
static_cast<void*>(&result), dataPtr);
}

template<typename A_TYPE, typename B_TYPE, typename C_TYPE, typename RESULT_TYPE, typename FUNC,
Expand Down

0 comments on commit 24496b2

Please sign in to comment.