Skip to content

Commit

Permalink
Remove useless JsonExtractScalarFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 6, 2024
1 parent 4a89d3b commit e7a345e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
27 changes: 0 additions & 27 deletions velox/functions/prestosql/JsonFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,6 @@ struct IsJsonScalarFunction {
}
};

// jsonExtractScalar(json, json_path) -> varchar
// Current implementation support UTF-8 in json, but not in json_path.
// Like jsonExtract(), but returns the result value as a string (as opposed
// to being encoded as JSON). The value referenced by json_path must be a scalar
// (boolean, number or string)
template <typename T>
struct JsonExtractScalarFunction {
VELOX_DEFINE_FUNCTION_TYPES(T);

FOLLY_ALWAYS_INLINE bool call(
out_type<Varchar>& result,
const arg_type<Json>& json,
const arg_type<Varchar>& jsonPath) {
const folly::StringPiece& jsonStringPiece = json;
const folly::StringPiece& jsonPathStringPiece = jsonPath;
auto extractResult =
jsonExtractScalar(jsonStringPiece, jsonPathStringPiece);
if (extractResult.hasValue()) {
UDFOutputString::assign(result, *extractResult);
return true;

} else {
return false;
}
}
};

template <typename T>
struct JsonExtractFunction {
VELOX_DEFINE_FUNCTION_TYPES(T);
Expand Down
11 changes: 0 additions & 11 deletions velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class JsonBenchmark : public velox::functions::test::FunctionBenchmarkBase {
{"folly_json_array_length"});
registerFunction<SIMDJsonArrayLengthFunction, int64_t, Json>(
{"simd_json_array_length"});
registerFunction<JsonExtractScalarFunction, Varchar, Json, Varchar>(
{"folly_json_extract_scalar"});
registerFunction<SIMDJsonExtractScalarFunction, Varchar, Json, Varchar>(
{"simd_json_extract_scalar"});
registerFunction<JsonExtractFunction, Varchar, Json, Varchar>(
Expand Down Expand Up @@ -193,15 +191,6 @@ void SIMDJsonArrayLength(int iter, int vectorSize, int jsonSize) {
benchmark.runWithJson(iter, vectorSize, "simd_json_array_length", json);
}

void FollyJsonExtractScalar(int iter, int vectorSize, int jsonSize) {
folly::BenchmarkSuspender suspender;
JsonBenchmark benchmark;
auto json = benchmark.prepareData(jsonSize);
suspender.dismiss();
benchmark.runWithJsonExtract(
iter, vectorSize, "folly_json_extract_scalar", json, "$.key[7].k1");
}

void SIMDJsonExtractScalar(int iter, int vectorSize, int jsonSize) {
folly::BenchmarkSuspender suspender;
JsonBenchmark benchmark;
Expand Down

0 comments on commit e7a345e

Please sign in to comment.