diff --git a/velox/functions/prestosql/SIMDJsonFunctions.h b/velox/functions/prestosql/JsonFunctions.h similarity index 97% rename from velox/functions/prestosql/SIMDJsonFunctions.h rename to velox/functions/prestosql/JsonFunctions.h index 8dd24442b464..c31ad5968eb8 100644 --- a/velox/functions/prestosql/SIMDJsonFunctions.h +++ b/velox/functions/prestosql/JsonFunctions.h @@ -26,7 +26,7 @@ namespace facebook::velox::functions { template -struct SIMDIsJsonScalarFunction { +struct IsJsonScalarFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE Status call(bool& result, const arg_type& json) { @@ -52,7 +52,7 @@ struct SIMDIsJsonScalarFunction { }; template -struct SIMDJsonArrayContainsFunction { +struct JsonArrayContainsFunction { VELOX_DEFINE_FUNCTION_TYPES(TExec); template @@ -122,7 +122,7 @@ struct SIMDJsonArrayContainsFunction { }; template -struct SIMDJsonArrayLengthFunction { +struct JsonArrayLengthFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call(int64_t& len, const arg_type& json) { @@ -148,7 +148,7 @@ struct SIMDJsonArrayLengthFunction { }; template -struct SIMDJsonArrayGetFunction { +struct JsonArrayGetFunction { VELOX_DEFINE_FUNCTION_TYPES(TExec); FOLLY_ALWAYS_INLINE bool @@ -194,7 +194,7 @@ struct SIMDJsonArrayGetFunction { // to being encoded as JSON). The value referenced by json_path must be a scalar // (boolean, number or string) template -struct SIMDJsonExtractScalarFunction { +struct JsonExtractScalarFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call( @@ -257,7 +257,7 @@ struct SIMDJsonExtractScalarFunction { }; template -struct SIMDJsonExtractFunction { +struct JsonExtractFunction { VELOX_DEFINE_FUNCTION_TYPES(T); bool call( @@ -337,7 +337,7 @@ struct SIMDJsonExtractFunction { }; template -struct SIMDJsonSizeFunction { +struct JsonSizeFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call( diff --git a/velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp b/velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp index 3f6ac3790219..b0843f2a786c 100644 --- a/velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp +++ b/velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp @@ -21,7 +21,7 @@ #include #include "velox/functions/Registerer.h" #include "velox/functions/lib/benchmarks/FunctionBenchmarkBase.h" -#include "velox/functions/prestosql/SIMDJsonFunctions.h" +#include "velox/functions/prestosql/JsonFunctions.h" #include "velox/functions/prestosql/json/JsonExtractor.h" #include "velox/functions/prestosql/types/JsonType.h" @@ -29,7 +29,7 @@ namespace facebook::velox::functions::prestosql { namespace { template -struct IsJsonScalarFunction { +struct FollyIsJsonScalarFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE void call(bool& result, const arg_type& json) { @@ -45,7 +45,7 @@ struct IsJsonScalarFunction { // to being encoded as JSON). The value referenced by json_path must be a scalar // (boolean, number or string) template -struct JsonExtractScalarFunction { +struct FollyJsonExtractScalarFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call( @@ -59,7 +59,6 @@ struct JsonExtractScalarFunction { if (extractResult.hasValue()) { UDFOutputString::assign(result, *extractResult); return true; - } else { return false; } @@ -67,7 +66,7 @@ struct JsonExtractScalarFunction { }; template -struct JsonExtractFunction { +struct FollyJsonExtractFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call( @@ -91,7 +90,7 @@ struct JsonExtractFunction { }; template -struct JsonArrayLengthFunction { +struct FollyJsonArrayLengthFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call(int64_t& result, const arg_type& json) { @@ -106,7 +105,7 @@ struct JsonArrayLengthFunction { }; template -struct JsonArrayContainsFunction { +struct FollyJsonArrayContainsFunction { VELOX_DEFINE_FUNCTION_TYPES(T); template @@ -146,7 +145,7 @@ struct JsonArrayContainsFunction { }; template -struct JsonSizeFunction { +struct FollyJsonSizeFunction { VELOX_DEFINE_FUNCTION_TYPES(T); FOLLY_ALWAYS_INLINE bool call( @@ -177,30 +176,28 @@ class JsonBenchmark : public velox::functions::test::FunctionBenchmarkBase { public: JsonBenchmark() : FunctionBenchmarkBase() { registerJsonType(); - registerFunction( + registerFunction({"is_json_scalar"}); + registerFunction( {"folly_is_json_scalar"}); - registerFunction( - {"simd_is_json_scalar"}); registerFunction( + {"json_array_contains"}); + registerFunction( {"folly_json_array_contains"}); - registerFunction( - {"simd_json_array_contains"}); registerFunction( + {"json_array_length"}); + registerFunction( {"folly_json_array_length"}); - registerFunction( - {"simd_json_array_length"}); registerFunction( + {"json_extract_scalar"}); + registerFunction( {"folly_json_extract_scalar"}); - registerFunction( - {"simd_json_extract_scalar"}); registerFunction( + {"json_extract"}); + registerFunction( {"folly_json_extract"}); - registerFunction( - {"simd_json_extract"}); - registerFunction( + registerFunction({"json_size"}); + registerFunction( {"folly_json_size"}); - registerFunction( - {"simd_json_size"}); } std::string prepareData(int jsonSize) { @@ -298,7 +295,7 @@ void SIMDIsJsonScalar(int iter, int vectorSize, int jsonSize) { JsonBenchmark benchmark; auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); - benchmark.runWithJson(iter, vectorSize, "simd_is_json_scalar", json); + benchmark.runWithJson(iter, vectorSize, "is_json_scalar", json); } void FollyJsonArrayContains(int iter, int vectorSize, int jsonSize) { @@ -315,8 +312,7 @@ void SIMDJsonArrayContains(int iter, int vectorSize, int jsonSize) { JsonBenchmark benchmark; auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); - benchmark.runWithJsonContains( - iter, vectorSize, "simd_json_array_contains", json); + benchmark.runWithJsonContains(iter, vectorSize, "json_array_contains", json); } void FollyJsonArrayLength(int iter, int vectorSize, int jsonSize) { @@ -332,7 +328,7 @@ void SIMDJsonArrayLength(int iter, int vectorSize, int jsonSize) { JsonBenchmark benchmark; auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); - benchmark.runWithJson(iter, vectorSize, "simd_json_array_length", json); + benchmark.runWithJson(iter, vectorSize, "json_array_length", json); } void FollyJsonExtractScalar(int iter, int vectorSize, int jsonSize) { @@ -350,7 +346,7 @@ void SIMDJsonExtractScalar(int iter, int vectorSize, int jsonSize) { auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); benchmark.runWithJsonExtract( - iter, vectorSize, "simd_json_extract_scalar", json, "$.key[7].k1"); + iter, vectorSize, "json_extract_scalar", json, "$.key[7].k1"); } void FollyJsonExtract(int iter, int vectorSize, int jsonSize) { @@ -368,7 +364,7 @@ void SIMDJsonExtract(int iter, int vectorSize, int jsonSize) { auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); benchmark.runWithJsonExtract( - iter, vectorSize, "simd_json_extract", json, "$.key[*].k1"); + iter, vectorSize, "json_extract", json, "$.key[*].k1"); } void FollyJsonSize(int iter, int vectorSize, int jsonSize) { @@ -385,8 +381,7 @@ void SIMDJsonSize(int iter, int vectorSize, int jsonSize) { JsonBenchmark benchmark; auto json = benchmark.prepareData(jsonSize); suspender.dismiss(); - benchmark.runWithJsonExtract( - iter, vectorSize, "simd_json_size", json, "$.key"); + benchmark.runWithJsonExtract(iter, vectorSize, "json_size", json, "$.key"); } BENCHMARK_DRAW_LINE(); diff --git a/velox/functions/prestosql/registration/JsonFunctionsRegistration.cpp b/velox/functions/prestosql/registration/JsonFunctionsRegistration.cpp index 36f448325bff..e9f2073224fe 100644 --- a/velox/functions/prestosql/registration/JsonFunctionsRegistration.cpp +++ b/velox/functions/prestosql/registration/JsonFunctionsRegistration.cpp @@ -15,57 +15,57 @@ */ #include "velox/functions/Registerer.h" -#include "velox/functions/prestosql/SIMDJsonFunctions.h" +#include "velox/functions/prestosql/JsonFunctions.h" namespace facebook::velox::functions { void registerJsonFunctions(const std::string& prefix) { registerJsonType(); - registerFunction( + registerFunction( {prefix + "is_json_scalar"}); - registerFunction( + registerFunction( {prefix + "is_json_scalar"}); - registerFunction( + registerFunction( {prefix + "json_extract_scalar"}); - registerFunction( + registerFunction( {prefix + "json_extract_scalar"}); - registerFunction( + registerFunction( {prefix + "json_extract"}); - registerFunction( + registerFunction( {prefix + "json_extract"}); - registerFunction( + registerFunction( {prefix + "json_array_length"}); - registerFunction( + registerFunction( {prefix + "json_array_length"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_contains"}); - registerFunction( + registerFunction( {prefix + "json_array_get"}); - registerFunction( + registerFunction( {prefix + "json_array_get"}); - registerFunction( + registerFunction( {prefix + "json_size"}); - registerFunction( + registerFunction( {prefix + "json_size"}); VELOX_REGISTER_VECTOR_FUNCTION(udf_json_format, prefix + "json_format");