methodHandle = constantJsonExtract;
jsonExtractor = generateExtractor(pattern, new ScalarValueJsonExtractor());
break;
case JSON_EXTRACT_FUNCTION_NAME:
methodHandle = constantJsonExtract;
jsonExtractor = generateExtractor(pattern, new JsonValueJsonExtractor());
break;
case JSON_SIZE_FUNCTION_NAME:
methodHandle = constantJsonSize;
jsonExtractor = generateExtractor(pattern, new JsonSizeExtractor());
break;
default:
throw new IllegalArgumentException("Unsupported method " + name);
}
methodHandle = MethodHandles.insertArguments(methodHandle, 1, jsonExtractor);
// remove the pattern argument
arguments = new ArrayList<>(arguments);
arguments.remove(1);
arguments = ImmutableList.copyOf(arguments);
}
else {
JsonExtractCache<?> cache;
switch (name) {
case JSON_EXTRACT_SCALAR_FUNCTION_NAME:
methodHandle = dynamicJsonExtract;
cache = new JsonExtractCache<>(20, new Supplier<JsonExtractor<Slice>>()
{
@Override
public JsonExtractor<Slice> get()
{
return new ScalarValueJsonExtractor();
}
});
break;
case JSON_EXTRACT_FUNCTION_NAME:
methodHandle = dynamicJsonExtract;
cache = new JsonExtractCache<>(20, new Supplier<JsonExtractor<Slice>>()
{
@Override
public JsonExtractor<Slice> get()
{
return new JsonValueJsonExtractor();
}
});
break;
case JSON_SIZE_FUNCTION_NAME:
methodHandle = dynamicJsonSize;