case CHAR: case VARCHAR: return utf8Converter.bytesToCharArray(bytes); case UNSIGNED_SMALLINT: case SMALLINT: return utf8Converter.bytesToInteger(bytes).shortValue(); case UNSIGNED_TINYINT: case TINYINT: return utf8Converter.bytesToInteger(bytes).byteValue(); case UNSIGNED_INT: case INTEGER: return utf8Converter.bytesToInteger(bytes); case BOOLEAN: return utf8Converter.bytesToBoolean(bytes); case DECIMAL: return utf8Converter.bytesToBigDecimal(bytes); case FLOAT: case UNSIGNED_FLOAT: return utf8Converter.bytesToFloat(bytes); case DOUBLE: case UNSIGNED_DOUBLE: return utf8Converter.bytesToDouble(bytes); case UNSIGNED_LONG: case LONG: return utf8Converter.bytesToLong(bytes); case TIME: case TIMESTAMP: case UNSIGNED_TIMESTAMP:
private InvokerFunction generateInvokerFunction(String className, Method method, boolean isStatic, Class<?>[] arguments) { byte[] byteCode = generateInvokerFunctionBytecode(className, method, isStatic, arguments); return ByteClassLoader.getInvokerFunction(className, byteCode); }
@Override public Object exec(Tuple input) throws IOException { if (!isInitialized) initialize(); return generatedFunction.eval(input); }
public void storeSchema(ResourceSchema schema, String location, Job job) throws IOException { // Store the schema in a side file in the same directory. MapReduce // does not include files starting with "_" when reading data for a job. JsonMetadata metadataWriter = new JsonMetadata(); byte recordDel = '\n'; byte fieldDel = '\t'; metadataWriter.setFieldDel(fieldDel); metadataWriter.setRecordDel(recordDel); metadataWriter.storeSchema(schema, location, job); }
protected static BigInteger getSeed(KNOWN_OP op) { switch (op) { case SUM: return BigInteger.ZERO; case MAX: return BigIntegerWrapper.NEGATIVE_INFINITY(); case MIN: return BigIntegerWrapper.POSITIVE_INFINITY(); default: return null; } }
/** * This will be called on both the front end and the back * end during execution. * @return the {@link LoadCaster} associated with this loader. Returning null * indicates that casts from byte array are not supported for this loader. * construction * @throws IOException if there is an exception during LoadCaster */ public LoadCaster getLoadCaster() throws IOException { return new Utf8StorageConverter(); }
public Final(String funcName, String params) throws IOException { this.funcName = funcName; constantsInfo = ConstantObjectInspectInfo.parse(params); } @Override
private static Class getFunctionInClass(ExceptionalFunction functionClassName) throws ClassNotFoundException, NoSuchMethodException, IOException { return getFunctionTypeClass(functionClassName, 0); }
/** * For JsonMetadata schema is considered optional * This method suppresses (and logs) errors if they are encountered. * */ @Override public ResourceSchema getSchema(String location, Job job) throws IOException { return getSchema(location, job, false); }
/** * Takes the class name of a Function, initializes it using the default constructor and passes * it to FunctionWrapperEvalFunc(ExceptionalFunction function). Functions must implement either * com.google.common.base.Function or ExceptionalFunction. * @param functionClassName function class to initialize */ public FunctionWrapperEvalFunc(String functionClassName) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, IOException { this(initializeFunction(functionClassName)); }
@Override public String exec(Tuple input) throws IOException { try { return max(input); } catch (ExecException ee) { throw ee; } }
@Override public List<String> getShipFiles() { Class[] classList = new Class[] {OrcFile.class, HiveConf.class, AbstractSerDe.class, org.apache.hadoop.hive.shims.HadoopShims.class, HadoopShimsSecure.class, Hadoop23Shims.class, Input.class}; return FuncUtils.getShipFiles(classList); }
@Override public String exec(Tuple input) throws IOException { try { return min(input); } catch (ExecException ee) { throw ee; } }
/** * Helper function reads the input avro schema from the UDF * Properties. * @return The input avro schema */ public final Schema getInputAvroSchema() { if (schema == null) { updateSchemaFromInputAvroSchema(); } return schema; }
public GenericInvoker(String fullName, String paramSpecsStr, String isStatic) throws ClassNotFoundException, FrontendException, SecurityException, NoSuchMethodException { invoker_ = new Invoker<T>(fullName, paramSpecsStr, isStatic); }
@Override public DataBag exec(Tuple input) throws IOException { return getDistinct(input); }
@Override public DataByteArray exec(Tuple input) throws IOException { return bloomOr(input); } }
public HiveUDTF(String funcName, String params) throws InstantiationException, IllegalAccessException, IOException { this(funcName); constantsInfo = ConstantObjectInspectInfo.parse(params); } @Override
private static Class getFunctionOutClass(ExceptionalFunction functionClassName) throws ClassNotFoundException, NoSuchMethodException, IOException { return getFunctionTypeClass(functionClassName, 1); }
public Intermediate(String funcName, String params) throws IOException { this.funcName = funcName; constantsInfo = ConstantObjectInspectInfo.parse(params); } @Override