@Override public Tuple getNext() throws IOException { try { HCatRecord hr = (HCatRecord) (reader.nextKeyValue() ? reader.getCurrentValue() : null); Tuple t = PigHCatUtil.transformToTuple(hr, outputSchema); // TODO : we were discussing an iter interface, and also a LazyTuple // change this when plans for that solidifies. return t; } catch (ExecException e) { int errCode = 6018; String errMsg = "Error while reading input"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, e); } catch (Exception eOther) { int errCode = 6018; String errMsg = "Error converting read value to tuple"; throw new ExecException(errMsg, errCode, PigException.REMOTE_ENVIRONMENT, eOther); } }
@Override public Tuple getNext() throws IOException { try { if(!reader.nextKeyValue()) { return null; } final PhoenixRecordWritable record = reader.getCurrentValue(); if(record == null) { return null; } final Tuple tuple = TypeUtil.transformToTuple(record, schema.getFields()); return tuple; } catch (InterruptedException e) { Thread.currentThread().interrupt(); int errCode = 6018; final String errMsg = "Error while reading input"; throw new ExecException(errMsg, errCode,PigException.REMOTE_ENVIRONMENT, e); } }
/** * TextLoader does not support conversion to Bag * @throws IOException if the value cannot be cast. */ public DataBag bytesToBag(byte[] b, ResourceFieldSchema schema) throws IOException { int errCode = 2109; String msg = "TextLoader does not support conversion to Bag."; throw new ExecException(msg, errCode, PigException.BUG); }
public byte[] toBytes(Double d) throws IOException { int errCode = 2109; String msg = "TextLoader does not support conversion from Double."; throw new ExecException(msg, errCode, PigException.BUG); }
public byte[] toBytes(Float f) throws IOException { int errCode = 2109; String msg = "TextLoader does not support conversion from Float."; throw new ExecException(msg, errCode, PigException.BUG); }
public byte[] toBytes(Long l) throws IOException { int errCode = 2109; String msg = "TextLoader does not support conversion from Long."; throw new ExecException(msg, errCode, PigException.BUG); }
/** * NOT IMPLEMENTED */ @Override public Tuple bytesToTuple(byte[] b, ResourceFieldSchema fieldSchema) throws IOException { throw new ExecException("Can't generate a Tuple from byte[]"); }
private Tuple getAggResultTuple(Object result) throws ExecException { try { return (Tuple) result; } catch (ClassCastException ex) { throw new ExecException("Intermediate Algebraic " + "functions must implement EvalFunc<Tuple>"); } }
/** * Not implemented! */ @Override public BigDecimal bytesToBigDecimal(byte[] b) throws IOException { throw new ExecException("Can't generate a BigInteger from byte[]"); }
private void freeMemory() throws ExecException { if (rawInputMap != null && !rawInputMap.isEmpty()) { throw new ExecException("Illegal state. Trying to free up partial aggregation maps when they are not empty"); } // Free up the maps for garbage collection rawInputMap = null; processedInputMap = null; }
public static byte findTypeFromClassName(String className) throws ExecException { if (classToTypeMap.containsKey(className)) { return classToTypeMap.get(className); } else { throw new ExecException("Unable to map " + className + " to known types." + Arrays.toString(classToTypeMap.keySet().toArray())); } }
@Override public Long exec(Tuple input) throws IOException { try { return sum(input); } catch (Exception ee) { int errCode = 2106; String msg = "Error while computing count in " + this.getClass().getSimpleName(); throw new ExecException(msg, errCode, PigException.BUG, ee); } } }
@Override public BigDecimal exec(Tuple input) throws IOException { try { return doTupleWork(input, this); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on BigDecimal", errCode, PigException.BUG, e); } } }
public byte[] toBytes(DateTime dt) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, dt); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting datetime to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
protected Number mod(Number a, Number b, byte dataType) throws ExecException { switch(dataType) { case DataType.INTEGER: return Integer.valueOf((Integer) a % (Integer) b); case DataType.LONG: return Long.valueOf((Long) a % (Long) b); case DataType.BIGINTEGER: return ((BigInteger)a).mod((BigInteger)b); default: throw new ExecException("called on unsupported Number class " + DataType.findTypeName(dataType)); } }
@Override public Float exec(Tuple input) throws IOException { try { return doTupleWork(input, this); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Floats", errCode, PigException.BUG, e); } } }
public byte[] toBytes(Double d) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, d); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting double to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
public byte[] toBytes(Float f) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { DataReaderWriter.writeDatum(dos, f); } catch (Exception ee) { int errCode = 2105; String msg = "Error while converting float to bytes."; throw new ExecException(msg, errCode, PigException.BUG, ee); } return baos.toByteArray(); }
@Override public Tuple exec(Tuple input) throws IOException { try { return tfact.newTuple(doTupleWork(input, this)); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on Doubles", errCode, PigException.BUG, e); } } }
@Override public Tuple exec(Tuple input) throws IOException { try { return tfact.newTuple(doTupleWork(input, this)); } catch (ExecException ee) { throw ee; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing function on BigDecimal", errCode, PigException.BUG, e); } } }