本文整理汇总了Java中org.apache.pig.impl.logicalLayer.FrontendException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java FrontendException.printStackTrace方法的具体用法?Java FrontendException.printStackTrace怎么用?Java FrontendException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.impl.logicalLayer.FrontendException
的用法示例。
在下文中一共展示了FrontendException.printStackTrace方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: coltypeFromFieldSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
public static ColumnType coltypeFromFieldSchema(String colName, FieldSchema colSchema)
{
ColumnType t = new ColumnType();
t.setName(colName);
t.setType(convertoRCFTypeName(DataType.findTypeName(colSchema.type)));
if (colSchema.schema != null)
{
try
{
t.setColumnSchema(convertToBlockSchema(colSchema.schema));
}
catch (FrontendException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return t;
}
示例2: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema input)
{
try {
if (!(input.size() == 2 || input.size() == 3))
{
throw new RuntimeException("Expected input to have two or three fields");
}
if (input.getField(1).type != DataType.INTEGER ) {
throw new RuntimeException("Expected an INT as second input, got: "+input.getField(1).type);
}
return new Schema(input.getField(0).schema);
}
catch (FrontendException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例3: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
try {
Schema.FieldSchema inputFieldSchema = input.getField(0);
if (inputFieldSchema.type != DataType.BAG) {
throw new RuntimeException("Expected a BAG as input");
}
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input),
inputFieldSchema.schema, DataType.BAG));
} catch (FrontendException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例4: testBlockErrMessage
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Test
public void testBlockErrMessage() throws Throwable {
PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
PigContext context = server.getPigContext();
String script = "A = load 'inputdata' using PigStorage() as ( curr_searchQuery );\n" +
"B = foreach A { domain = CONCAT(curr_searchQuery,\"^www\\.\");\n" +
" generate domain; };\n";
ByteArrayInputStream cmd = new ByteArrayInputStream(script.getBytes());
InputStreamReader reader = new InputStreamReader(cmd);
Grunt grunt = new Grunt(new BufferedReader(reader), context);
try {
grunt.exec();
} catch(FrontendException e) {
e.printStackTrace();
assertTrue(e.getMessage().contains("Error during parsing. <line 2, column 49> Unexpected character '\"'"));
}
}
示例5: testValidationFailure
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Test
public void testValidationFailure() throws Exception{
String input[] = new String[] { "some data" };
String outputFileName = "test-output.txt";
boolean sawException = false;
try {
Util.createInputFile(pig.getPigContext(),outputFileName, input);
String query = "a = load '" + inputFileName + "' as (c:chararray, " +
"i:int,d:double);" +
"store a into '" + outputFileName + "' using PigStorage();";
Util.buildLp( pig, query );
} catch (InvocationTargetException e){
FrontendException pve = (FrontendException)e.getCause();
pve.printStackTrace();
// Since output file is present, validation should fail
// and throw this exception
assertEquals(6000,pve.getErrorCode());
assertEquals(PigException.REMOTE_ENVIRONMENT, pve.getErrorSource());
assertTrue(pve.getCause() instanceof IOException);
sawException = true;
} finally {
assertTrue(sawException);
Util.deleteFile(pig.getPigContext(), outputFileName);
}
}
示例6: testBlockErrMessage
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Test
public void testBlockErrMessage() throws Throwable {
PigServer server = new PigServer(cluster.getExecType(), cluster.getProperties());
PigContext context = server.getPigContext();
String script = "A = load 'inputdata' using PigStorage() as ( curr_searchQuery );\n" +
"B = foreach A { domain = CONCAT(curr_searchQuery,\"^www\\.\");\n" +
" generate domain; };\n";
ByteArrayInputStream cmd = new ByteArrayInputStream(script.getBytes());
InputStreamReader reader = new InputStreamReader(cmd);
Grunt grunt = new Grunt(new BufferedReader(reader), context);
try {
grunt.exec();
} catch(FrontendException e) {
e.printStackTrace();
assertTrue(e.getMessage().contains("Error during parsing. <line 2, column 49> Unexpected character '\"'"));
}
}
示例7: local
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Test
public void local() {
PigServer pigServer = pigConfiguration.local();
try {
pigServer.printAliases();
} catch (FrontendException e) {
e.printStackTrace();
}
System.out.println(pigServer);
}
示例8: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
try {
if (!(input.size() == 2 || input.size() == 3))
{
throw new RuntimeException("Expected input to have two or three fields");
}
Schema.FieldSchema inputFieldSchema = input.getField(0);
if (inputFieldSchema.type != DataType.BAG) {
throw new RuntimeException("Expected a BAG as first input, got: "+inputFieldSchema.type);
}
if (input.getField(1).type != DataType.INTEGER) {
throw new RuntimeException("Expected an INT as second input, got: "+input.getField(1).type);
}
if (input.size() == 3 && !(input.getField(2).type == DataType.INTEGER || input.getField(2).type == DataType.LONG)) {
throw new RuntimeException("Expected an INT or LONG as second input, got: "+input.getField(2).type);
}
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input),
inputFieldSchema.schema, DataType.BAG));
} catch (FrontendException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
示例9: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema inputSchema) {
try {
if ((inputSchema == null) || ((inputSchema.size() != 1) && (inputSchema.size() != 2))) {
throw new RuntimeException("Expecting 2 inputs, found: " +
((inputSchema == null) ? 0 : inputSchema.size()));
}
FieldSchema inputFieldSchema = inputSchema.getField(0);
if (inputFieldSchema.type != DataType.BAG) {
throw new RuntimeException("Expecting a bag of tuples: {()}, found data type: " +
DataType.findTypeName(inputFieldSchema.type));
}
// first field in the bag schema
FieldSchema firstFieldSchema = inputFieldSchema.schema.getField(0);
if ((firstFieldSchema == null) || (firstFieldSchema.schema == null)
|| firstFieldSchema.schema.size() < 1) {
throw new RuntimeException("Expecting a bag and a delimeter, found: " + inputSchema);
}
if (firstFieldSchema.type != DataType.TUPLE) {
throw new RuntimeException("Expecting a bag and a delimeter, found: " + inputSchema);
}
if (inputSchema.size() == 2) {
FieldSchema secondInputFieldSchema = inputSchema.getField(1);
if (secondInputFieldSchema.type != DataType.CHARARRAY) {
throw new RuntimeException("Expecting a bag and a delimeter, found: " + inputSchema);
}
}
return new Schema(new Schema.FieldSchema(null, DataType.CHARARRAY));
} catch (FrontendException e) {
e.printStackTrace();
return null;
}
}
示例10: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema inputSchema) {
try {
if ((inputSchema == null) || inputSchema.size() != 1) {
throw new RuntimeException("Expecting 1 input, found " +
((inputSchema == null) ? 0 : inputSchema.size()));
}
Schema.FieldSchema inputFieldSchema = inputSchema.getField(0);
if (inputFieldSchema.type != DataType.BAG) {
throw new RuntimeException("Expecting a bag of tuples: {()}");
}
// first field in the bag schema
Schema.FieldSchema firstFieldSchema = inputFieldSchema.schema.getField(0);
if ((firstFieldSchema == null) || (firstFieldSchema.schema == null)
|| firstFieldSchema.schema.size() < 1) {
throw new RuntimeException("Expecting a bag of tuples: {()}, found: " + inputSchema);
}
if (firstFieldSchema.type != DataType.TUPLE) {
throw new RuntimeException("Expecting a bag of tuples: {()}, found: " + inputSchema);
}
// now for output schema
Schema tupleOutputSchema = new Schema();
for (int i = 0; i < firstFieldSchema.schema.size(); ++i) {
tupleOutputSchema.add(firstFieldSchema.schema.getField(i));
}
return new Schema(new Schema.FieldSchema(getSchemaName(this
.getClass().getName().toLowerCase(), inputSchema), tupleOutputSchema,
DataType.TUPLE));
} catch (FrontendException e) {
e.printStackTrace();
return null;
}
}
示例11: getOutputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema getOutputSchema(Schema input)
{
ArrayList<String> bagNames = new ArrayList<String>(input.size() / 2);
Map<String, String> bagNameToJoinPrefix = new HashMap<String, String>(input.size() / 2);
Map<String, Integer> bagNameToSize = new HashMap<String, Integer>(input.size() / 2);
Schema outputSchema = null;
Schema bagSchema = new Schema();
try {
int i = 0;
// all even fields should be bags, odd fields are key names
String bagName = null;
String tupleName = null;
for (FieldSchema outerField : input.getFields()) {
if (i++ % 2 == 1)
continue;
bagName = outerField.alias;
bagNames.add(bagName);
if (bagName == null)
bagName = "null";
if (outerField.schema == null)
throw new RuntimeException("Expected input format of (bag, 'field') pairs. "
+"Did not receive a bag at index: "+i+", alias: "+bagName+". "
+"Instead received type: "+DataType.findTypeName(outerField.type)+" in schema:"+input.toString());
FieldSchema tupleField = outerField.schema.getField(0);
tupleName = tupleField.alias;
bagNameToJoinPrefix.put(bagName, getPrefixedAliasName(outerField.alias, tupleName));
if (tupleField.schema == null) {
log.error(String.format("could not get schema for inner tuple %s in bag %s", tupleName, bagName));
} else {
bagNameToSize.put(bagName, tupleField.schema.size());
for (FieldSchema innerField : tupleField.schema.getFields()) {
String innerFieldName = innerField.alias;
if (innerFieldName == null)
innerFieldName = "null";
String outputFieldName = bagName + "::" + innerFieldName;
if (innerField.schema != null) {
bagSchema.add(new FieldSchema(outputFieldName, innerField.schema, innerField.type));
} else {
bagSchema.add(new FieldSchema(outputFieldName, innerField.type));
}
}
}
}
outputSchema = new Schema(new Schema.FieldSchema(
getSchemaName(this.getClass().getName().toLowerCase(), input),
bagSchema,
DataType.BAG));
log.debug("output schema: "+outputSchema.toString());
} catch (FrontendException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
Properties properties = getInstanceProperties();
properties.put(BAG_NAMES_PROPERTY, bagNames);
properties.put(BAG_NAME_TO_JOIN_PREFIX_PROPERTY, bagNameToJoinPrefix);
properties.put(BAG_NAME_TO_SIZE_PROPERTY, bagNameToSize);
return outputSchema;
}
示例12: outputSchema
import org.apache.pig.impl.logicalLayer.FrontendException; //导入方法依赖的package包/类
@Override
public Schema outputSchema(Schema input) {
try {
Schema.FieldSchema inputFieldSchema = input.getField(0);
if (inputFieldSchema.type != DataType.BAG) {
throw new RuntimeException("Expected a BAG as input");
}
Schema inputBagSchema = inputFieldSchema.schema;
if (inputBagSchema.getField(0).type != DataType.TUPLE)
{
throw new RuntimeException(String.format("Expected input bag to contain a TUPLE, but instead found %s",
DataType.findTypeName(inputBagSchema.getField(0).type)));
}
Schema tupleSchema = inputBagSchema.getField(0).schema;
if(tupleSchema == null) {
throw new RuntimeException("The tuple of input bag has no schema");
}
List<Schema.FieldSchema> fieldSchemaList = tupleSchema.getFields();
if(fieldSchemaList == null || fieldSchemaList.size() <= Math.max(0, this.weightIdx)) {
throw new RuntimeException("The field schema of the input tuple is null " +
"or the tuple size is no more than the weight field index: "
+ this.weightIdx);
}
if(fieldSchemaList.get(this.weightIdx).type != DataType.INTEGER &&
fieldSchemaList.get(this.weightIdx).type != DataType.LONG &&
fieldSchemaList.get(this.weightIdx).type != DataType.FLOAT &&
fieldSchemaList.get(this.weightIdx).type != DataType.DOUBLE)
{
String[] expectedTypes = new String[] {DataType.findTypeName(DataType.INTEGER),
DataType.findTypeName(DataType.LONG),
DataType.findTypeName(DataType.FLOAT),
DataType.findTypeName(DataType.DOUBLE)};
throw new RuntimeException("Expect the type of the weight field of the input tuple to be of (" +
java.util.Arrays.toString(expectedTypes) + "), but instead found (" +
DataType.findTypeName(fieldSchemaList.get(this.weightIdx).type) + "), weight field: " +
this.weightIdx);
}
return new Schema(new Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(), input),
inputFieldSchema.schema, DataType.BAG));
} catch (FrontendException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}