MCPcopy Create free account
hub / github.com/apache/impala / addFunctionToDbParams

Method addFunctionToDbParams

fe/src/main/java/org/apache/impala/catalog/Db.java:341–361  ·  view source on GitHub ↗

Adds the user defined function fn to metastore DB params. fn is serialized to thrift using TBinaryProtocol and then base64-encoded to be compatible with the HMS' representation of params.

(Function fn)

Source from the content-addressed store, hash-verified

339 * to be compatible with the HMS' representation of params.
340 */
341 private boolean addFunctionToDbParams(Function fn) {
342 Preconditions.checkState(
343 fn.getBinaryType() != TFunctionBinaryType.BUILTIN &&
344 fn.getBinaryType() != TFunctionBinaryType.JAVA);
345 try {
346 TSerializer serializer =
347 new TSerializer(new TCompactProtocol.Factory());
348 byte[] serializedFn = serializer.serialize(fn.toThrift());
349 String base64Fn = Base64.getEncoder().encodeToString(serializedFn);
350 String fnKey = FUNCTION_INDEX_PREFIX + fn.signatureString();
351 if (base64Fn.length() > HIVE_METASTORE_DB_PARAM_LIMIT_BYTES) {
352 throw new ImpalaRuntimeException(
353 "Serialized function size exceeded HMS 4K byte limit");
354 }
355 putToHmsParameters(fnKey, base64Fn);
356 } catch (ImpalaException | TException e) {
357 LOG.error("Error adding function " + fn.getName() + " to DB params", e);
358 return false;
359 }
360 return true;
361 }
362
363 public boolean addFunction(Function fn) {
364 // We use the db parameters map to persist native and IR functions.

Callers 1

addFunctionMethod · 0.95

Calls 8

putToHmsParametersMethod · 0.95
signatureStringMethod · 0.80
toThriftMethod · 0.65
getNameMethod · 0.65
getBinaryTypeMethod · 0.45
serializeMethod · 0.45
lengthMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected