From 6c082dafbf58f96edc3814a1211ac124811a1951 Mon Sep 17 00:00:00 2001 From: Johnnathan Date: Thu, 5 May 2022 10:25:26 -0300 Subject: [PATCH] Clang executed to fix some errors in Lint c++ --- cpp/src/gandiva/function_registry_string.cc | 8 +++--- cpp/src/gandiva/precompiled/string_ops.cc | 28 +++++++++---------- .../gandiva/precompiled/string_ops_test.cc | 6 ++-- cpp/src/gandiva/precompiled/types.h | 8 +++--- cpp/src/gandiva/tests/projector_test.cc | 28 ++++++------------- 5 files changed, 34 insertions(+), 44 deletions(-) diff --git a/cpp/src/gandiva/function_registry_string.cc b/cpp/src/gandiva/function_registry_string.cc index 2399913428d0c..2245e87f7fb88 100644 --- a/cpp/src/gandiva/function_registry_string.cc +++ b/cpp/src/gandiva/function_registry_string.cc @@ -439,12 +439,12 @@ std::vector GetStringFunctionRegistry() { kResultNullIfNull, "right_utf8_int32", NativeFunction::kNeedsContext), - NativeFunction("binary", {}, DataTypeVector{binary()}, binary(), - kResultNullIfNull, "castBINARY_binary", + NativeFunction("binary", {}, DataTypeVector{binary()}, binary(), kResultNullIfNull, + "castBINARY_binary", NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors), - NativeFunction("binary", {}, DataTypeVector{utf8()}, binary(), - kResultNullIfNull, "castBINARY_utf8", + NativeFunction("binary", {}, DataTypeVector{utf8()}, binary(), kResultNullIfNull, + "castBINARY_utf8", NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors), NativeFunction("castVARBINARY", {}, DataTypeVector{binary(), int64()}, binary(), diff --git a/cpp/src/gandiva/precompiled/string_ops.cc b/cpp/src/gandiva/precompiled/string_ops.cc index 3267ac68613c7..3e4e6fc62003d 100644 --- a/cpp/src/gandiva/precompiled/string_ops.cc +++ b/cpp/src/gandiva/precompiled/string_ops.cc @@ -705,20 +705,20 @@ CAST_VARCHAR_FROM_VARLEN_TYPE(binary) CAST_VARBINARY_FROM_STRING_AND_BINARY(utf8) CAST_VARBINARY_FROM_STRING_AND_BINARY(binary) -#define CAST_BINARY_FROM_STRING_AND_BINARY(TYPE) \ - GANDIVA_EXPORT \ - const char* castBINARY_##TYPE(gdv_int64 context, const char* data, \ - gdv_int32 data_len, int32_t* out_length) { \ - int32_t len = static_cast(data_len); \ - if (len < 0) { \ - gdv_fn_context_set_error_msg(context, "Output buffer length can't be negative"); \ - *out_length = 0; \ - return ""; \ - } \ - \ - *out_length = len; \ - \ - return data; \ +#define CAST_BINARY_FROM_STRING_AND_BINARY(TYPE) \ + GANDIVA_EXPORT \ + const char* castBINARY_##TYPE(gdv_int64 context, const char* data, gdv_int32 data_len, \ + int32_t* out_length) { \ + int32_t len = static_cast(data_len); \ + if (len < 0) { \ + gdv_fn_context_set_error_msg(context, "Output buffer length can't be negative"); \ + *out_length = 0; \ + return ""; \ + } \ + \ + *out_length = len; \ + \ + return data; \ } CAST_BINARY_FROM_STRING_AND_BINARY(utf8) diff --git a/cpp/src/gandiva/precompiled/string_ops_test.cc b/cpp/src/gandiva/precompiled/string_ops_test.cc index 0f4d31c649458..d192fd9ef37c9 100644 --- a/cpp/src/gandiva/precompiled/string_ops_test.cc +++ b/cpp/src/gandiva/precompiled/string_ops_test.cc @@ -908,13 +908,13 @@ TEST(TestGdvFnStubs, TestCastBinaryBinary) { const char* input = "\\x41\\x42\\x43"; const char* out; - out = castBINARY_binary(ctx_ptr, input, 12,&out_len); + out = castBINARY_binary(ctx_ptr, input, 12, &out_len); EXPECT_EQ(std::string(out, out_len), input); - out = castBINARY_binary(ctx_ptr, input, 8,&out_len); + out = castBINARY_binary(ctx_ptr, input, 8, &out_len); EXPECT_EQ(std::string(out, out_len), "\\x41\\x42"); - out = castBINARY_binary(ctx_ptr, input,-10, &out_len); + out = castBINARY_binary(ctx_ptr, input, -10, &out_len); EXPECT_EQ(std::string(out, out_len), ""); EXPECT_THAT(ctx.get_error(), ::testing::HasSubstr("Output buffer length can't be negative")); diff --git a/cpp/src/gandiva/precompiled/types.h b/cpp/src/gandiva/precompiled/types.h index 0f65239841d03..1059cca36357e 100644 --- a/cpp/src/gandiva/precompiled/types.h +++ b/cpp/src/gandiva/precompiled/types.h @@ -573,11 +573,11 @@ const char* castVARBINARY_binary_int64(gdv_int64 context, const char* data, gdv_int32 data_len, int64_t out_len, int32_t* out_length); -const char* castBINARY_utf8(gdv_int64 context, const char* data, - gdv_int32 data_len, int32_t* out_length); +const char* castBINARY_utf8(gdv_int64 context, const char* data, gdv_int32 data_len, + int32_t* out_length); -const char* castBINARY_binary(gdv_int64 context, const char* data, - gdv_int32 data_len, int32_t* out_length); +const char* castBINARY_binary(gdv_int64 context, const char* data, gdv_int32 data_len, + int32_t* out_length); gdv_int32 levenshtein(int64_t context, const char* in1, int32_t in1_len, const char* in2, int32_t in2_len); diff --git a/cpp/src/gandiva/tests/projector_test.cc b/cpp/src/gandiva/tests/projector_test.cc index 2097a72eaf7d3..9ee2d17e6c7c0 100644 --- a/cpp/src/gandiva/tests/projector_test.cc +++ b/cpp/src/gandiva/tests/projector_test.cc @@ -2684,24 +2684,21 @@ TEST_F(TestProjector, TestCastVarbinary) { auto res_out1 = field("res_out1", arrow::binary()); // Build expression - auto cast_expr_1 = TreeExprBuilder::MakeExpression("castVARBINARY", {field0, field1}, res_out1); + auto cast_expr_1 = + TreeExprBuilder::MakeExpression("castVARBINARY", {field0, field1}, res_out1); std::shared_ptr projector; - auto status = Projector::Make( - schema, {cast_expr_1}, - TestConfiguration(), &projector); + auto status = Projector::Make(schema, {cast_expr_1}, TestConfiguration(), &projector); EXPECT_TRUE(status.ok()); // Create a row-batch with some sample data int num_records = 2; - auto array0 = MakeArrowArrayUtf8( - {"a", "abc"}, {true, true}); + auto array0 = MakeArrowArrayUtf8({"a", "abc"}, {true, true}); - auto array1 = MakeArrowArrayInt64( - {1, 3}, {true, true}); + auto array1 = MakeArrowArrayInt64({1, 3}, {true, true}); auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0, array1}); @@ -2714,7 +2711,6 @@ TEST_F(TestProjector, TestCastVarbinary) { EXPECT_TRUE(status.ok()); EXPECT_ARROW_ARRAY_EQUALS(out_1, outputs.at(0)); - } TEST_F(TestProjector, TestCastBinaryUTF) { @@ -2729,17 +2725,14 @@ TEST_F(TestProjector, TestCastBinaryUTF) { std::shared_ptr projector; - auto status = Projector::Make( - schema, {cast_expr_1}, - TestConfiguration(), &projector); + auto status = Projector::Make(schema, {cast_expr_1}, TestConfiguration(), &projector); EXPECT_TRUE(status.ok()); // Create a row-batch with some sample data int num_records = 2; - auto array0 = MakeArrowArrayUtf8( - {"a", "abc"}, {true, true}); + auto array0 = MakeArrowArrayUtf8({"a", "abc"}, {true, true}); auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0}); @@ -2766,17 +2759,14 @@ TEST_F(TestProjector, TestCastBinaryBinary) { std::shared_ptr projector; - auto status = Projector::Make( - schema, {cast_expr_1}, - TestConfiguration(), &projector); + auto status = Projector::Make(schema, {cast_expr_1}, TestConfiguration(), &projector); EXPECT_TRUE(status.ok()); // Create a row-batch with some sample data int num_records = 2; - auto array0 = MakeArrowArrayUtf8( - {"\\x41\\x42\\x43", "\\x41\\x42"}, {true, true}); + auto array0 = MakeArrowArrayUtf8({"\\x41\\x42\\x43", "\\x41\\x42"}, {true, true}); auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0});