本文整理汇总了Java中org.apache.pig.PigException类的典型用法代码示例。如果您正苦于以下问题:Java PigException类的具体用法?Java PigException怎么用?Java PigException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PigException类属于org.apache.pig包,在下文中一共展示了PigException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchema
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public ResourceSchema getSchema(String location, Job job) throws IOException {
HCatContext.INSTANCE.setConf(job.getConfiguration()).getConf().get()
.setBoolean(HCatConstants.HCAT_DATA_TINY_SMALL_INT_PROMOTION, true);
Table table = phutil.getTable(location,
hcatServerUri != null ? hcatServerUri : PigHCatUtil.getHCatServerUri(job),
PigHCatUtil.getHCatServerPrincipal(job),
// Pass job to initialize metastore conf overrides for embedded metastore case
// (hive.metastore.uris = "").
job);
HCatSchema hcatTableSchema = HCatUtil.getTableSchemaWithPtnCols(table);
try {
PigHCatUtil.validateHCatTableSchemaFollowsPigRules(hcatTableSchema);
} catch (IOException e) {
throw new PigException(
"Table schema incompatible for reading through HCatLoader :" + e.getMessage()
+ ";[Table schema was " + hcatTableSchema.toString() + "]"
, PigHCatUtil.PIG_EXCEPTION_CODE, e);
}
storeInUDFContext(signature, HCatConstants.HCAT_TABLE_SCHEMA, hcatTableSchema);
outputSchema = hcatTableSchema;
return PigHCatUtil.getResourceSchema(hcatTableSchema);
}
示例2: getByteArrayPositions
import org.apache.pig.PigException; //导入依赖的package包/类
/**
* Gets the positions in the schema which are byte arrays
* @param func
*
* @param s -
* input schema
* @throws VisitorException
*/
private List<Integer> getByteArrayPositions(UserFuncExpression func, Schema s)
throws VisitorException {
List<Integer> result = new ArrayList<Integer>();
for (int i = 0; i < s.size(); i++) {
try {
FieldSchema fs = s.getField(i);
if (fs.type == DataType.BYTEARRAY) {
result.add(i);
}
} catch (FrontendException fee) {
int errCode = 1043;
String msg = "Unable to retrieve field schema.";
throw new TypeCheckerException(func, msg, errCode, PigException.INPUT, fee); }
}
return result;
}
示例3: checkSchemaEx
import org.apache.pig.PigException; //导入依赖的package包/类
private void checkSchemaEx(String query, String expectedErr) throws IOException {
PigServer pig = new PigServer(ExecType.LOCAL);
boolean foundEx = false;
try{
Util.registerMultiLineQuery(pig, query);
pig.dumpSchema("u");
}catch(FrontendException e){
PigException pigEx = LogUtils.getPigException(e);
foundEx = true;
if(!pigEx.getMessage().contains(expectedErr)){
String msg = "Expected exception message matching '"
+ expectedErr + "' but got '" + pigEx.getMessage() + "'" ;
fail(msg);
}
}
if(!foundEx)
fail("No exception thrown. Exception is expected.");
}
示例4: asCollection
import org.apache.pig.PigException; //导入依赖的package包/类
public HPath[] asCollection(String pattern) throws DataStorageException {
try {
FileStatus[] paths = this.fs.globStatus(new Path(pattern));
if (paths == null)
return new HPath[0];
List<HPath> hpaths = new ArrayList<HPath>();
for (int i = 0; i < paths.length; ++i) {
HPath hpath = (HPath)this.asElement(paths[i].getPath().toString());
if (!hpath.systemElement()) {
hpaths.add(hpath);
}
}
return hpaths.toArray(new HPath[hpaths.size()]);
} catch (IOException e) {
int errCode = 6008;
String msg = "Failed to obtain glob for " + pattern;
throw new DataStorageException(msg, errCode, PigException.REMOTE_ENVIRONMENT, e);
}
}
示例5: exec
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public Tuple exec(Tuple input) throws IOException {
try {
// input is a bag with one tuple containing
// the column we are trying to min on
DataBag bg = (DataBag) input.get(0);
String s = null;
if(bg.iterator().hasNext()) {
Tuple tp = bg.iterator().next();
s = (String)(tp.get(0));
}
return tfact.newTuple(s);
} catch (ExecException ee) {
throw ee;
} catch (Exception e) {
int errCode = 2106;
String msg = "Error while computing min in " + this.getClass().getSimpleName();
throw new ExecException(msg, errCode, PigException.BUG, e);
}
}
示例6: Lead
import org.apache.pig.PigException; //导入依赖的package包/类
Lead(Object[] args) throws IOException {
rowsAhead = 1;
deflt = null;
if (args != null) {
if (args.length >= 1) {
try {
rowsAhead = (Integer)args[0];
} catch (ClassCastException cce) {
int errCode = 2107; // TODO not sure this is the right one
String msg = "Lead expected an integer for arg 2 " +
" but received " + DataType.findTypeName(args[0]);
throw new ExecException(msg, errCode, PigException.INPUT);
}
}
if (args.length >= 2) {
deflt = args[1];
}
}
reset();
}
示例7: visit
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public void visit(LODistinct loDistinct) throws FrontendException {
String scope = DEFAULT_SCOPE;
PODistinct physOp = new PODistinct(new OperatorKey(scope,nodeGen.getNextNodeId(scope)), loDistinct.getRequestedParallelism());
physOp.addOriginalLocation(loDistinct.getAlias(), loDistinct.getLocation());
currentPlan.add(physOp);
physOp.setResultType(DataType.BAG);
logToPhyMap.put(loDistinct, physOp);
Operator op = loDistinct.getPlan().getPredecessors(loDistinct).get(0);
PhysicalOperator from = logToPhyMap.get(op);
try {
currentPlan.connect(from, physOp);
} catch (PlanException e) {
int errCode = 2015;
String msg = "Invalid physical operators in the physical plan" ;
throw new LogicalToPhysicalTranslatorException(msg, errCode, PigException.BUG, e);
}
}
示例8: visit
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public void visit(NegativeExpression negExp) throws FrontendException {
byte type = negExp.getExpression().getType() ;
if (DataType.isNumberType(type)) {
//do nothing
}
else if (type == DataType.BYTEARRAY) {
// cast bytearray to double
insertCast(negExp, DataType.DOUBLE, negExp.getExpression());
}
else {
int errCode = 1041;
String msg = "NEG can be used with numbers or Bytearray only" ;
msgCollector.collect(msg, MessageType.Error);
throw new TypeCheckerException(negExp, msg, errCode, PigException.INPUT) ;
}
}
示例9: accumulate
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public void accumulate(Tuple b) throws IOException {
try {
String curMax = max(b);
if (curMax == null) {
return;
}
// check if it lexicographically follows curMax
if (intermediateMax == null || intermediateMax.compareTo(curMax) > 0) {
intermediateMax = curMax;
}
} catch (ExecException ee) {
throw ee;
} catch (Exception e) {
int errCode = 2106;
String msg = "Error while computing max in " + this.getClass().getSimpleName();
throw new ExecException(msg, errCode, PigException.BUG, e);
}
}
示例10: addUidLoadFuncToMap
import org.apache.pig.PigException; //导入依赖的package包/类
/**
* Add given uid, loadFuncSpec to mapping
* @param uid
* @param loadFuncSpec
* @throws VisitorException
*/
private void addUidLoadFuncToMap(long uid, FuncSpec loadFuncSpec)
throws VisitorException{
if(loadFuncSpec == null){
return;
}
//ensure that uid always matches to same load func
FuncSpec curFuncSpec = uid2LoadFuncMap.get(uid);
if(curFuncSpec == null){
uid2LoadFuncMap.put(uid, loadFuncSpec);
}else if(! haveIdenticalCasters(curFuncSpec,loadFuncSpec)){
String msg = "Bug: uid mapped to two different load functions : " +
curFuncSpec + " and " + loadFuncSpec;
throw new VisitorException(msg,2262, PigException.BUG) ;
}
}
示例11: getResult
import org.apache.pig.PigException; //导入依赖的package包/类
private Result getResult(ExpressionOperator op) throws ExecException {
Result res;
switch (op.getResultType()) {
case DataType.BAG:
case DataType.BOOLEAN:
case DataType.BYTEARRAY:
case DataType.CHARARRAY:
case DataType.DOUBLE:
case DataType.FLOAT:
case DataType.INTEGER:
case DataType.LONG:
case DataType.BIGINTEGER:
case DataType.BIGDECIMAL:
case DataType.DATETIME:
case DataType.MAP:
case DataType.TUPLE:
res = op.getNext(op.getResultType());
break;
default:
String msg = "Invalid result type: "
+ DataType.findType(op.getResultType());
throw new ExecException(msg, 2270, PigException.BUG);
}
return res;
}
示例12: visitSort
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public void visitSort(POSort op) throws VisitorException {
try{
FileSpec fSpec = getTempFileSpec();
MapReduceOper mro = endSingleInputPlanWithStr(fSpec);
FileSpec quantFile = getTempFileSpec();
int rp = op.getRequestedParallelism();
Pair<POProject, Byte>[] fields = getSortCols(op.getSortPlans());
Pair<MapReduceOper, Integer> quantJobParallelismPair =
getQuantileJob(op, mro, fSpec, quantFile, rp);
curMROp = getSortJob(op, quantJobParallelismPair.first, fSpec, quantFile,
quantJobParallelismPair.second, fields);
if(op.isUDFComparatorUsed){
curMROp.UDFs.add(op.getMSortFunc().getFuncSpec().toString());
curMROp.isUDFComparatorUsed = true;
}
phyToMROpMap.put(op, curMROp);
}catch(Exception e){
int errCode = 2034;
String msg = "Error compiling operator " + op.getClass().getSimpleName();
throw new MRCompilerException(msg, errCode, PigException.BUG, e);
}
}
示例13: addUidLoadFuncToMap
import org.apache.pig.PigException; //导入依赖的package包/类
/**
* Add given uid, loadFuncSpec to mapping
* @param uid
* @param loadFuncSpec
* @throws VisitorException
*/
private void addUidLoadFuncToMap(long uid, FuncSpec loadFuncSpec)
throws VisitorException{
if(loadFuncSpec == null){
return;
}
//ensure that uid always matches to same load func
FuncSpec curFuncSpec = uid2LoadFuncMap.get(uid);
if(curFuncSpec == null){
uid2LoadFuncMap.put(uid, loadFuncSpec);
}else if(! curFuncSpec.equals(loadFuncSpec)){
String msg = "Bug: uid mapped to two different load functions : " +
curFuncSpec + " and " + loadFuncSpec;
throw new VisitorException(msg,2262, PigException.BUG) ;
}
}
示例14: doTupleWork
import org.apache.pig.PigException; //导入依赖的package包/类
protected static Integer doTupleWork(Tuple input, KnownOpProvider opProvider) throws ExecException {
DataBag values = (DataBag)input.get(0);
// if we were handed an empty bag, return NULL
// this is in compliance with SQL standard
if(values.size() == 0) {
return null;
}
int sofar = AlgebraicIntMathBase.getSeed(opProvider.getOp());
boolean sawNonNull = false;
for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
Tuple t = it.next();
try {
Integer d = (Integer)(t.get(0));
if (d == null) continue;
sawNonNull = true;
sofar = doWork(sofar, d, opProvider.getOp());
}catch(RuntimeException exp) {
int errCode = 2103;
throw new ExecException("Problem doing work on Doubles", errCode, PigException.BUG, exp);
}
}
return sawNonNull ? sofar : null;
}
示例15: visit
import org.apache.pig.PigException; //导入依赖的package包/类
@Override
public void visit(LOGenerate gen) throws FrontendException {
for(int i=0; i < gen.getOutputPlans().size(); i++) {
LogicalExpressionPlan expPlan = gen.getOutputPlans().get(i);
// Check that the inner plan has only 1 output port
if (expPlan.getSources().size() > 1) {
int errCode = 1057;
String msg = "LOGenerate expression plan can only have one output" ;
msgCollector.collect(msg, MessageType.Error) ;
throwTypeCheckerException( gen, msg, errCode, PigException.BUG, null) ;
}
// visit the filter expression
visitExpressionPlan( expPlan, gen );
}
gen.resetSchema();
gen.getSchema();
}