// ConversionHelper can be called without method parameter length
// checkings
// for terminatePartial() and merge() calls.
if (parameterOIs.length < methodParameterTypes.length - 1) {
throw new UDFArgumentLengthException(m.toString()
+ " requires at least " + (methodParameterTypes.length - 1)
+ " arguments but only " + parameterOIs.length
+ " are passed in.");
}
// Copy the first methodParameterTypes.length - 1 entries
for (int i = 0; i < methodParameterTypes.length - 1; i++) {
// This method takes Object, so it accepts whatever types that are
// passed in.
if (methodParameterTypes[i] == Object.class) {
methodParameterOIs[i] = ObjectInspectorUtils
.getStandardObjectInspector(parameterOIs[i],
ObjectInspectorCopyOption.JAVA);
} else {
methodParameterOIs[i] = ObjectInspectorFactory
.getReflectionObjectInspector(methodParameterTypes[i],
ObjectInspectorOptions.JAVA);
}
}
// Deal with the last entry
if (lastParaElementType == Object.class) {
// This method takes Object[], so it accepts whatever types that are
// passed in.
for (int i = methodParameterTypes.length - 1; i < parameterOIs.length; i++) {
methodParameterOIs[i] = ObjectInspectorUtils
.getStandardObjectInspector(parameterOIs[i],
ObjectInspectorCopyOption.JAVA);
}
} else {
// This method takes something like String[], so it only accepts
// something like String
ObjectInspector oi = ObjectInspectorFactory
.getReflectionObjectInspector(lastParaElementType,
ObjectInspectorOptions.JAVA);
for (int i = methodParameterTypes.length - 1; i < parameterOIs.length; i++) {
methodParameterOIs[i] = oi;
}
}
} else {
// Normal case, the last parameter is a normal parameter.
// ConversionHelper can be called without method parameter length
// checkings
// for terminatePartial() and merge() calls.
if (methodParameterTypes.length != parameterOIs.length) {
throw new UDFArgumentLengthException(m.toString() + " requires "
+ methodParameterTypes.length + " arguments but "
+ parameterOIs.length + " are passed in.");
}
for (int i = 0; i < methodParameterTypes.length; i++) {
// This method takes Object, so it accepts whatever types that are