@Override public void copyToNewInstance(Object newInstance) throws UDFArgumentException { super.copyToNewInstance(newInstance); if (_stdUdf == null) { return; } StdUdfWrapper newWrapper = (StdUdfWrapper) newInstance; newWrapper._inputObjectInspectors = _inputObjectInspectors; newWrapper._stdFactory = _stdFactory; newWrapper._stdUdf = _stdUdf; newWrapper._nullableArguments = _stdUdf.getAndCheckNullableArguments(); newWrapper._stdUdf.init(_stdFactory); newWrapper._requiredFilesProcessed = false; newWrapper.createStdData(); }
@Override public void copyToNewInstance(Object newInstance) throws UDFArgumentException { super.copyToNewInstance(newInstance); if (_stdUdf == null) { return; } StdUdfWrapper newWrapper = (StdUdfWrapper) newInstance; newWrapper._inputObjectInspectors = _inputObjectInspectors; newWrapper._stdFactory = _stdFactory; newWrapper._stdUdf = _stdUdf; newWrapper._nullableArguments = _stdUdf.getAndCheckNullableArguments(); newWrapper._stdUdf.init(_stdFactory); newWrapper._requiredFilesProcessed = false; newWrapper.createStdData(); }
@Override public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { StdFactory stdFactory = new PrestoFactory(boundVariables, typeManager, functionRegistry); StdUDF stdUDF = getStdUDF(); stdUDF.init(stdFactory); // Subtract a small jitter value so that refresh is triggered on first call // Do not add extra delay, if refresh time was set to lower value by an earlier specialize long initialJitter = getRefreshIntervalMillis() / JITTER_FACTOR; int initialJitterInt = initialJitter > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) initialJitter; _requiredFilesNextRefreshTime = Math.min(_requiredFilesNextRefreshTime, System.currentTimeMillis() - (new Random()).nextInt(initialJitterInt)); boolean[] nullableArguments = stdUDF.getAndCheckNullableArguments(); return new ScalarFunctionImplementation(true, getNullConventionForArguments(nullableArguments), getMethodHandle(stdUDF, typeManager, boundVariables, nullableArguments), isDeterministic()); }
@Override public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { StdFactory stdFactory = new PrestoFactory(boundVariables, typeManager, functionRegistry); StdUDF stdUDF = getStdUDF(); stdUDF.init(stdFactory); // Subtract a small jitter value so that refresh is triggered on first call // Do not add extra delay, if refresh time was set to lower value by an earlier specialize long initialJitter = getRefreshIntervalMillis() / JITTER_FACTOR; int initialJitterInt = initialJitter > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) initialJitter; _requiredFilesNextRefreshTime = Math.min(_requiredFilesNextRefreshTime, System.currentTimeMillis() - (new Random()).nextInt(initialJitterInt)); boolean[] nullableArguments = stdUDF.getAndCheckNullableArguments(); return new ScalarFunctionImplementation(true, getNullConventionForArguments(nullableArguments), getMethodHandle(stdUDF, typeManager, boundVariables, nullableArguments), isDeterministic()); }
/** * Given input {@link TestType}s, this method matches them to the expected {@link TestType}, and finds bindings to the * generic parameters. Once the generic parameter bindings are known, the method infers the output type (in the form * of a {@link TestType}) by substituting the binding values in the output {@link TestType}. * * @param arguments Input {@link TestType} of UDF parameters. * @return Inferred output {@link TestType}. */ public TestType initialize(TestType[] arguments) { GenericTypeInference genericTypeInference = new GenericTypeInference(); genericTypeInference.compile(arguments, getStdUdfImplementations(), getTopLevelUdfClass()); _inputTypes = genericTypeInference.getInputDataTypes(); _stdFactory = genericTypeInference.getStdFactory(); _stdUdf = genericTypeInference.getStdUdf(); _nullableArguments = _stdUdf.getAndCheckNullableArguments(); _stdUdf.init(_stdFactory); _requiredFilesProcessed = false; createStdData(); return genericTypeInference.getOutputDataType(); }
/** * Given input schemas, this method matches them to the expected type signatures, and finds bindings to the * generic parameters. Once the generic parameter bindings are known, the method infers the output type (in the form * of an Avro schema) by substituting the binding values in the output type signature. * signature and * @param arguments Input Avro Schemas of UDF parameters. * @return Inferred output Avro Schema. */ public Schema initialize(Schema[] arguments) { AvroTypeInference avroTypeInference = new AvroTypeInference(); avroTypeInference.compile(arguments, getStdUdfImplementations(), getTopLevelUdfClass()); _inputSchemas = avroTypeInference.getInputDataTypes(); _stdFactory = avroTypeInference.getStdFactory(); _stdUdf = avroTypeInference.getStdUdf(); _nullableArguments = _stdUdf.getAndCheckNullableArguments(); _stdUdf.init(_stdFactory); _requiredFilesProcessed = false; createStdData(); return avroTypeInference.getOutputDataType(); }
/** * Given input schemas, this method matches them to the expected type signatures, and finds bindings to the * generic parameters. Once the generic parameter bindings are known, the method infers the output type (in the form * of an Avro schema) by substituting the binding values in the output type signature. * signature and * @param arguments Input Avro Schemas of UDF parameters. * @return Inferred output Avro Schema. */ public Schema initialize(Schema[] arguments) { AvroTypeInference avroTypeInference = new AvroTypeInference(); avroTypeInference.compile(arguments, getStdUdfImplementations(), getTopLevelUdfClass()); _inputSchemas = avroTypeInference.getInputDataTypes(); _stdFactory = avroTypeInference.getStdFactory(); _stdUdf = avroTypeInference.getStdUdf(); _nullableArguments = _stdUdf.getAndCheckNullableArguments(); _stdUdf.init(_stdFactory); _requiredFilesProcessed = false; createStdData(); return avroTypeInference.getOutputDataType(); }
/** * Given input object inspectors, this method matches them to the expected type signatures, and finds bindings to the * generic parameters. Once the generic parameter bindings are known, the method infers the output type (in the form * of object inspectors) by substituting the binding values in the output type signature. * signature and * @param arguments Input object inspectors of UDF parameters. * @return Inferred output object inspector. */ @Override public ObjectInspector initialize(ObjectInspector[] arguments) { HiveTypeInference hiveTypeInference = new HiveTypeInference(); hiveTypeInference.compile( arguments, getStdUdfImplementations(), getTopLevelUdfClass() ); _inputObjectInspectors = hiveTypeInference.getInputDataTypes(); _stdFactory = hiveTypeInference.getStdFactory(); _stdUdf = hiveTypeInference.getStdUdf(); _nullableArguments = _stdUdf.getAndCheckNullableArguments(); _stdUdf.init(_stdFactory); _requiredFilesProcessed = false; createStdData(); return hiveTypeInference.getOutputDataType(); }
/** * Given input object inspectors, this method matches them to the expected type signatures, and finds bindings to the * generic parameters. Once the generic parameter bindings are known, the method infers the output type (in the form * of object inspectors) by substituting the binding values in the output type signature. * signature and * @param arguments Input object inspectors of UDF parameters. * @return Inferred output object inspector. */ @Override public ObjectInspector initialize(ObjectInspector[] arguments) { HiveTypeInference hiveTypeInference = new HiveTypeInference(); hiveTypeInference.compile( arguments, getStdUdfImplementations(), getTopLevelUdfClass() ); _inputObjectInspectors = hiveTypeInference.getInputDataTypes(); _stdFactory = hiveTypeInference.getStdFactory(); _stdUdf = hiveTypeInference.getStdUdf(); _nullableArguments = _stdUdf.getAndCheckNullableArguments(); _stdUdf.init(_stdFactory); _requiredFilesProcessed = false; createStdData(); return hiveTypeInference.getOutputDataType(); }