本文整理汇总了Java中org.apache.pig.PigException.INPUT属性的典型用法代码示例。如果您正苦于以下问题:Java PigException.INPUT属性的具体用法?Java PigException.INPUT怎么用?Java PigException.INPUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.pig.PigException
的用法示例。
在下文中一共展示了PigException.INPUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Ntile
protected Ntile(Object[] args) throws IOException {
if (args == null || args.length != 1) {
throw new ExecException(
"Ntile args must contain arg describing how to split data, "
+ "e.g. ntile(4)", 2107, PigException.INPUT);
}
try {
numBuckets = (Integer)args[0];
} catch (ClassCastException cce) {
throw new ExecException(
"Ntile expected integer argument but received " +
DataType.findTypeName(args[0]), 2107, PigException.INPUT);
}
reset();
}
示例2: byteArrayFound
/**
* Checks to see if any field of the input schema is a byte array
* @param func
* @param s - input schema
* @return true if found else false
* @throws VisitorException
*/
private boolean byteArrayFound(UserFuncExpression func, Schema s) throws VisitorException {
for(int i=0;i<s.size();i++){
try {
FieldSchema fs=s.getField(i);
if(fs == null)
return false;
if(fs.type==DataType.BYTEARRAY){
return true;
}
} catch (FrontendException fee) {
int errCode = 1043;
String msg = "Unable to retrieve field schema.";
throw new TypeCheckerException(func, msg, errCode, PigException.INPUT, fee);
}
}
return false;
}
示例3: getByteArrayPositions
/**
* 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;
}
示例4: Lag
Lag(Object[] args) throws IOException {
rowsBehind = 1;
deflt = null;
if (args != null) {
if (args.length >= 1) {
try {
rowsBehind = (Integer)args[0];
} catch (ClassCastException cce) {
int errCode = 2107; // TODO not sure this is the right one
String msg = "Lag 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();
}
示例5: visitBooleanBinary
private void visitBooleanBinary(BinaryExpression boolExp)
throws FrontendException {
// if lhs or rhs is null constant then cast it to boolean
insertCastsForNullToBoolean(boolExp);
LogicalExpression lhs = boolExp.getLhs();
LogicalExpression rhs = boolExp.getRhs();
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
int errCode = 1038;
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new TypeCheckerException(boolExp, msg, errCode, PigException.INPUT) ;
}
}
示例6: visit
@Override
public void visit(LOFilter filter) throws FrontendException {
LogicalExpressionPlan expression = filter.getFilterPlan();
if (expression != null) {
// if it is a Sample, the expression must be scalar
if (filter.isSample()) {
ProjectFinder pf = new ProjectFinder(expression,
new ReverseDependencyOrderWalker(expression));
pf.visit();
if (pf.found()) {
int errCode = 1131;
throw new VisitorException(filter, ERR_MSG_SCALAR, errCode,
PigException.INPUT);
}
}
}
}
示例7: visit
@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) ;
}
}
示例8: doInsertBetween
public void doInsertBetween(
E after,
E newNode,
E before,
boolean rewire) throws PlanException {
checkInPlan(newNode);
List<E> newNodePreds = getPredecessors(newNode);
//assuming that the newNode has zero or one predecessor
E newNodePred = (newNodePreds == null? null: newNodePreds.get(0));
if (!replaceNode(after, newNode, before, mFromEdges) || !replaceNode(before, newNode, after, mToEdges)) {
int errCode = 1094;
String msg = "Attempt to insert between two nodes " +
"that were not connected.";
PlanException pe = new PlanException(msg, errCode, PigException.INPUT);
throw pe;
}
mFromEdges.put(newNode, before);
mToEdges.put(newNode, after);
if(rewire) {
if((newNodePred != null) && !(newNodePred.equals(after))) {
newNodePred.regenerateProjectionMap();
newNode.rewire(newNodePred, 0, after, true);
}
newNode.regenerateProjectionMap();
IndexHelper<E> indexHelper = new IndexHelper<E>(getPredecessors(newNode));
before.rewire(after, indexHelper.getIndex(after), newNode, false);
}
}
示例9: FieldSchema
/**
* Constructor for tuple fields.
*
* @param a
* Alias, if known. If unknown leave null.
* @param s
* Schema of this tuple.
* @param t
* Type, using codes from
* {@link org.apache.pig.data.DataType}.
*
*/
public FieldSchema(String a, Schema s, byte t) throws FrontendException {
alias = a;
schema = s;
log.debug("t: " + t + " Bag: " + DataType.BAG + " tuple: " + DataType.TUPLE);
if ((null != s) && !(DataType.isSchemaType(t))) {
int errCode = 1020;
throw new FrontendException("Only a BAG, TUPLE or MAP can have schemas. Got "
+ DataType.findTypeName(t), errCode, PigException.INPUT);
}
type = t;
canonicalName = CanonicalNamer.getNewName();
}
示例10: exactMatchHelper
/**
* Finds if there is an exact match between the schema supported by
* one of the funcSpecs and the input schema s
* @param funcSpecs - mappings provided by udf
* @param s - input schema
* @param func user defined function
* @param ignoreByteArrays - flag for whether the exact match is to computed
* after ignoring bytearray (if true) or without ignoring bytearray (if false)
* @return the matching spec if found else null
* @throws FrontendException
*/
private FuncSpec exactMatchHelper(List<FuncSpec> funcSpecs, Schema s,
UserFuncExpression func, boolean ignoreByteArrays)
throws FrontendException {
List<FuncSpec> matchingSpecs = new ArrayList<FuncSpec>();
for (Iterator<FuncSpec> iterator = funcSpecs.iterator(); iterator.hasNext();) {
FuncSpec fs = iterator.next();
if (schemaEqualsForMatching(s, fs.getInputArgsSchema(), ignoreByteArrays)) {
matchingSpecs.add(fs);
}
}
if(matchingSpecs.size() == 0)
return null;
if(matchingSpecs.size() > 1) {
int errCode = 1046;
String msg = "Multiple matching functions for "
+ func.getFuncSpec() + " with input schema: "
+ "(" + matchingSpecs.get(0).getInputArgsSchema()
+ ", " + matchingSpecs.get(1).getInputArgsSchema()
+ "). Please use an explicit cast.";
msgCollector.collect(msg, MessageType.Error);
throw new TypeCheckerException(func, msg, errCode, PigException.INPUT);
}
// exactly one matching spec - return it
return matchingSpecs.get(0);
}
示例11: throwTypeCheckerException
private void throwTypeCheckerException(Operator op, String msg,
int errCode, byte input, FrontendException fe) throws TypeCheckerException {
if( fe == null ) {
throw new TypeCheckerException(op, msg, errCode, PigException.INPUT);
}
throw new TypeCheckerException(op, msg, errCode, PigException.INPUT, fe);
}
示例12: fetchFilesInternal
/**
* Copies the files from remote to local filesystem.
* When 'multipleFiles' is set the path could point to multiple files
* through globs or a directory. In this case, return array contains multiple
* files, otherwise a single file is returned.
*
* If pig.jars.relative.to.dfs is true then a relative path is assumed to be
* relative to the default filesystem's active directory.
* Else they are assumed to be relative to the local working directory.
*
* @param properties
* @param filePath
* @param multipleFiles
* @return
*/
private static FetchFileRet[] fetchFilesInternal(Properties properties,
String filePath,
boolean multipleFiles) throws IOException {
Path path = new Path(filePath);
if (path.getName().isEmpty()) {
return new FetchFileRet[0];
}
URI uri = path.toUri();
Configuration conf = new Configuration();
ConfigurationUtil.mergeConf(conf, ConfigurationUtil.toConfiguration(properties));
// if there is no schema or if the schema is "local", then it is
// expected to be a local path.
FileSystem localFs = FileSystem.getLocal(conf);
FileSystem srcFs;
if ( (!"true".equals(properties.getProperty("pig.jars.relative.to.dfs"))
&& uri.getScheme() == null )||
// For Windows local files
(uri.getScheme() == null && uri.getPath().matches("^/[A-Za-z]:.*")) ||
(uri.getScheme() != null && uri.getScheme().equals("local"))
) {
srcFs = localFs;
} else {
srcFs = path.getFileSystem(conf);
}
FileStatus[] files;
if (multipleFiles) {
files = srcFs.globStatus(path);
} else {
files = new FileStatus[]{ srcFs.getFileStatus(path) };
}
if (files == null || files.length == 0) {
throw new ExecException("file '" + filePath + "' does not exist.", 101, PigException.INPUT);
}
FetchFileRet[] fetchFiles = new FetchFileRet[files.length];
int idx = 0;
for(FileStatus file : files) {
// should throw an exception if this is not a file?
String pathname = file.getPath().toUri().getPath();
String filename = file.getPath().getName();
if (srcFs == localFs) {
fetchFiles[idx++] = new FetchFileRet(new File(pathname), false);
} else {
// fetch from remote:
File dest = new File(localTempDir, filename);
dest.deleteOnExit();
try {
srcFs.copyToLocalFile(file.getPath(), new Path(dest.getAbsolutePath()));
} catch (IOException e) {
throw new ExecException("Could not copy " + filePath + " to local destination " + dest, 101, PigException.INPUT, e);
}
fetchFiles[idx++] = new FetchFileRet(dest, true);
}
}
return fetchFiles;
}
示例13: exec
@Override
public Tuple exec(Tuple inputTuple) throws IOException {
if (inputTuple.size() != 1) {
throw new ExecException("Expecting 1 input, found " + inputTuple.size(), PigException.INPUT);
}
if (inputTuple.get(0) == null) {
return null;
}
if (!(inputTuple.get(0) instanceof DataBag)) {
throw new ExecException("Usage BagToTuple(DataBag)", PigException.INPUT);
}
DataBag inputBag = (DataBag) (inputTuple.get(0));
try {
Tuple outputTuple = null;
long outputTupleSize = getOuputTupleSize(inputBag);
// TupleFactory.newTuple(int size) can only support up to Integer.MAX_VALUE
if (outputTupleSize > Integer.MAX_VALUE) {
throw new ExecException("Input bag is too large", 105, PigException.INPUT);
}
TupleFactory tupleFactory = TupleFactory.getInstance();
outputTuple = tupleFactory.newTuple((int) outputTupleSize);
int fieldNum = 0;
for (Tuple t : inputBag) {
if (t != null) {
for (int i = 0; i < t.size(); i++) {
outputTuple.set(fieldNum++, t.get(i));
}
}
}
return outputTuple;
} catch (Exception e) {
String msg = "Encourntered error while flattening a bag to tuple"
+ this.getClass().getSimpleName();
throw new ExecException(msg, PigException.BUG, e);
}
}
示例14: visit
@Override
public void visit(LORank rank) throws FrontendException {
List<LogicalExpressionPlan> expPlans = rank.getRankColPlans();
List<Boolean> ascOrder = rank.getAscendingCol();
List<LogicalExpressionPlan> newExpPlans = new ArrayList<LogicalExpressionPlan>();
List<Boolean> newAscOrder = new ArrayList<Boolean>();
if (expPlans.size() != ascOrder.size()) {
throw new AssertionError(
"Size of expPlans and ascorder should be same");
}
for (int i = 0; i < expPlans.size(); i++) {
// expand the plan
LogicalExpressionPlan ithExpPlan = expPlans.get(i);
List<LogicalExpressionPlan> expandedPlans = expandPlan(ithExpPlan,
0);
newExpPlans.addAll(expandedPlans);
// add corresponding isAsc flags
Boolean isAsc = ascOrder.get(i);
for (int j = 0; j < expandedPlans.size(); j++) {
newAscOrder.add(isAsc);
}
}
// check if there is a project-star-to-end followed by another sort plan
// in the expanded plans (can happen if there is no input schema)
for (int i = 0; i < newExpPlans.size(); i++) {
ProjectExpression proj = getProjectStar(newExpPlans.get(i));
if (proj != null && proj.isRangeProject() && proj.getEndCol() == -1
&& i != newExpPlans.size() - 1) {
String msg = "Project-range to end (eg. x..)"
+ " is supported in rank-by only as last rank column";
throw new FrontendException(msg, 1128, PigException.INPUT);
}
}
rank.setRankColPlan(newExpPlans);
rank.setAscendingCol(newAscOrder);
}
示例15: storeScriptSchema
/**
* This method will store the scriptSchema:Schema using ObjectSerializer to
* the current configuration.<br/>
* The schema can be retrieved by load functions or UDFs to know the schema
* the user entered in the as clause.<br/>
* The name format is:<br/>
*
* <pre>
* ${UDFSignature}.scriptSchema = ObjectSerializer.serialize(scriptSchema)
* </pre>
* <p/>
* Note that this is not the schema the load function returns but will
* always be the as clause schema.<br/>
* That is a = LOAD 'input' as (a:chararray, b:chararray)<br/>
* The schema wil lbe (a:chararray, b:chararray)<br/>
* <p/>
*
* TODO Find better solution to make script schema available to LoadFunc see
* https://issues.apache.org/jira/browse/PIG-1717
*/
private void storeScriptSchema(Configuration conf, LogicalSchema scriptSchema, String signature) {
if (conf != null && scriptSchema != null && signature != null) {
try {
conf.set(
Utils.getScriptSchemaKey(signature),
ObjectSerializer.serialize(Util.translateSchema(scriptSchema)));
} catch (IOException ioe) {
int errCode = 1018;
String msg = "Problem serializing script schema";
FrontendException fee = new FrontendException(this, msg, errCode,
PigException.INPUT, false, null, ioe);
throw new RuntimeException(fee);
}
}
}