本文整理匯總了Java中org.apache.pig.backend.executionengine.ExecException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ExecException.printStackTrace方法的具體用法?Java ExecException.printStackTrace怎麽用?Java ExecException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.pig.backend.executionengine.ExecException
的用法示例。
在下文中一共展示了ExecException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DeduplicationJob
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
public DeduplicationJob(List<String> files, List<String> dimensions) {
this.files = files;
Properties props = new Properties();
props.setProperty("output.compression.enabled", "true");
props.setProperty("output.compression.codec", "org.apache.hadoop.io.compress.GzipCodec");
try {
this.pigServer = new PigServer(ExecType.MAPREDUCE, props);
} catch (ExecException e) {
log.error("Couldn't execute pig server: {}", e.getMessage());
e.printStackTrace();
}
this.usingAsDimensions = Joiner.on(":chararray, ").join(dimensions) + ", data:Map[], count:int";
this.groupByDimensions = Joiner.on(", ").join(dimensions);
this.loaderDimensions = "'" + Joiner.on("','").join(dimensions) + "'";
}
示例2: printFreqWords
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
void printFreqWords() throws IOException, ParseException {
LOG.info("Printing the most frequent words");
BasicTable.Reader reader = new BasicTable.Reader(freqWordTablePath, conf);
TableScanner scanner = reader.getScanner(null, true);
BytesWritable key = new BytesWritable();
Schema schema = Projection.toSchema(scanner.getProjection());
int idxCount = schema.getColumnIndex("count");
Tuple value = TypesUtils.createTuple(schema);
for (; !scanner.atEnd(); scanner.advance()) {
scanner.getKey(key);
scanner.getValue(value);
try {
String word = new String(key.getBytes(), 0, key.getLength());
int count = (Integer) value.get(idxCount);
LOG.info(String.format("%s\t%d", word, count));
} catch (ExecException e) {
e.printStackTrace();
}
}
scanner.close();
}
示例3: reduce
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@Override
public void reduce(BytesWritable key, Iterator<InvIndex> values,
OutputCollector<BytesWritable, Tuple> output, Reporter reporter)
throws IOException {
InvIndex sum = new InvIndex();
for (; values.hasNext();) {
sum.reduce(values.next());
}
try {
outRow.set(idxCount, sum.count);
outRow.set(idxIndex, convertInvIndex(sum.index));
output.collect(key, outRow);
} catch (ExecException e) {
e.printStackTrace();
}
}
示例4: reduce
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
public void reduce(BytesWritable key, Iterator<Tuple> values, Context context)
throws IOException, InterruptedException {
try {
for (; values.hasNext();) {
context.write(key, values.next());
}
} catch (ExecException e) {
e.printStackTrace();
}
}
示例5: reduce
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
public void reduce(BytesWritable key, Iterator<Tuple> values,
OutputCollector<BytesWritable, Tuple> output, Reporter reporter)
throws IOException {
try {
for (; values.hasNext();) {
output.collect(key, values.next());
}
} catch (ExecException e) {
e.printStackTrace();
}
}
示例6: getPartition
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@Override
public int getPartition(Tuple key, V value, int numPartitions)
{
try
{
for (int i = 0; i < partitionKeyIndex.size(); i++)
{
Object o = null;
if (partitionKeyIndex.get(i).getFirst())
o = key.get(partitionKeyIndex.get(i).getSecond());
else
o = ((Tuple) value).get(partitionKeyIndex.get(i).getSecond());
keyTuple.set(i, o);
}
}
catch (ExecException e)
{
e.printStackTrace();
}
// This has to be cast to long;
// If it is int, and the hashcode is -2147483648, negative or math.abs(), or *-1
// of this all return negative numbers
long hashcode = BlockUtils.getBlockId(keyTuple);
return (int) (hashcode % numPartitions);
}
示例7: setUp
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
init();
pathTable = getTableFullPath("TestBasicTableUnionLoader1");
removeDir(pathTable);
BasicTable.Writer writer = new BasicTable.Writer(pathTable,
"SF_a:string,SF_b:string,SF_c:string,SF_d:string,SF_e:string,SF_f:string,SF_g:string",
"[SF_a, SF_b, SF_c]; [SF_e, SF_f, SF_g]", conf);
Schema schema = writer.getSchema();
Tuple tuple = TypesUtils.createTuple(schema);
final int numsBatch = 10;
final int numsInserters = 1;
TableInserter[] inserters = new TableInserter[numsInserters];
for (int i = 0; i < numsInserters; i++) {
inserters[i] = writer.getInserter("ins" + i, false);
}
for (int b = 0; b < numsBatch; b++) {
for (int i = 0; i < numsInserters; i++) {
TypesUtils.resetTuple(tuple);
for (int k = 0; k < tuple.size(); ++k) {
try {
tuple.set(k, (9-b) + "_" + i + "" + k);
} catch (ExecException e) {
e.printStackTrace();
}
}
inserters[i].insert(new BytesWritable(("key" + i).getBytes()), tuple);
}
}
for (int i = 0; i < numsInserters; i++) {
inserters[i].close();
}
writer.close();
}
示例8: format
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
/**
* Default implementation of format of tuple (each filed is delimited by
* tab)
*
* @param tuple
* @return Default format of Tuple
*/
@SuppressWarnings("unchecked")
public static String format(Tuple tuple) {
StringBuilder sb = new StringBuilder();
sb.append('(');
for (int i = 0; i < tuple.size(); ++i) {
try {
Object d = tuple.get(i);
if (d != null) {
if (d instanceof Map) {
sb.append(DataType.mapToString((Map<String, Object>) d));
} else if (d instanceof Tuple) {
Tuple t = (Tuple) d;
sb.append(TupleFormat.format(t));
} else if (d instanceof DataBag){
DataBag bag=(DataBag)d;
sb.append(BagFormat.format(bag));
}
else {
sb.append(d.toString());
}
} else {
sb.append("");
}
if (i != tuple.size() - 1)
sb.append(",");
} catch (ExecException e) {
e.printStackTrace();
mLog.warn("Exception when format tuple", e);
}
}
sb.append(')');
return sb.toString();
}
示例9: close
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@Override
public void close() throws IOException {
Item[] items = freqWords.toArray();
for (Item i : items) {
try {
outRow.set(idxCount, new Integer(i.count));
out.collect(i.word, outRow);
} catch (ExecException e) {
e.printStackTrace();
}
}
}
示例10: testTupleFormat
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@Test
public void testTupleFormat() {
try {
Tuple tuple = mTupleFactory.newTuple(7);
tuple.set(0, 12);
Map<String, String> map = new HashMap<String, String>();
map.put("pig", "scalability");
tuple.set(1, map);
tuple.set(2, null);
tuple.set(3, 12L);
tuple.set(4, 1.2F);
Tuple innerTuple = mTupleFactory.newTuple(1);
innerTuple.set(0, "innerTuple");
tuple.set(5, innerTuple);
DataBag bag = BagFactory.getInstance().newDefaultBag();
bag.add(innerTuple);
tuple.set(6, bag);
assertEquals(
"(12,[pig#scalability],,12,1.2,(innerTuple),{(innerTuple)})",
TupleFormat.format(tuple));
} catch (ExecException e) {
e.printStackTrace();
fail();
}
}
示例11: setUp
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
init();
pathTable = getTableFullPath("TestTableLoader");
removeDir(pathTable);
BasicTable.Writer writer = new BasicTable.Writer(pathTable,
"a:string,b:string,c:string,d:string,e:string,f:string,g:string", "[a,b,c];[d,e,f,g]", conf);
Schema schema = writer.getSchema();
Tuple tuple = TypesUtils.createTuple(schema);
final int numsBatch = 10;
final int numsInserters = 2;
TableInserter[] inserters = new TableInserter[numsInserters];
for (int i = 0; i < numsInserters; i++) {
inserters[i] = writer.getInserter("ins" + i, false);
}
for (int b = 0; b < numsBatch; b++) {
for (int i = 0; i < numsInserters; i++) {
TypesUtils.resetTuple(tuple);
for (int k = 0; k < tuple.size(); ++k) {
try {
tuple.set(k, b + "_" + i + "" + k);
} catch (ExecException e) {
e.printStackTrace();
}
}
inserters[i].insert(new BytesWritable(("key" + i).getBytes()), tuple);
}
}
for (int i = 0; i < numsInserters; i++) {
inserters[i].close();
}
writer.close();
}
示例12: setUp
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
init();
pathTable = getTableFullPath("TestTableStorer");
removeDir(pathTable);
BasicTable.Writer writer = new BasicTable.Writer(pathTable,
"SF_a:string,SF_b:string,SF_c:string,SF_d:string,SF_e:string,SF_f:string,SF_g:string",
"[SF_a, SF_b, SF_c]; [SF_e, SF_f, SF_g]", conf);
Schema schema = writer.getSchema();
Tuple tuple = TypesUtils.createTuple(schema);
final int numsBatch = 10;
final int numsInserters = 2;
TableInserter[] inserters = new TableInserter[numsInserters];
for (int i = 0; i < numsInserters; i++) {
inserters[i] = writer.getInserter("ins" + i, false);
}
for (int b = 0; b < numsBatch; b++) {
for (int i = 0; i < numsInserters; i++) {
TypesUtils.resetTuple(tuple);
for (int k = 0; k < tuple.size(); ++k) {
try {
tuple.set(k, b + "_" + i + "" + k);
} catch (ExecException e) {
e.printStackTrace();
}
}
inserters[i].insert(new BytesWritable(("key" + i).getBytes()), tuple);
}
}
for (int i = 0; i < numsInserters; i++) {
inserters[i].close();
}
writer.close();
}
示例13: examineTuple
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
public static void examineTuple(ArrayList<DataByteArray[]> expectedData, Tuple tuple, int tupleCount) {
for (int i = 0; i < tuple.size(); i++) {
DataByteArray dataAtom= null;
try {
dataAtom = (DataByteArray) tuple.get(i);
} catch (ExecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DataByteArray expected = expectedData.get(tupleCount)[i];
System.err.println("compare "+expected+" to "+dataAtom);
assertEquals(expected, dataAtom);
}
}
示例14: setUpOnce
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
@BeforeClass
public static void setUpOnce() throws IOException {
conf = new Configuration();
conf.setInt("table.output.tfile.minBlock.size", 64 * 1024);
conf.setInt("table.input.split.minSize", 64 * 1024);
conf.set("table.output.tfile.compression", "none");
RawLocalFileSystem rawLFS = new RawLocalFileSystem();
fs = new LocalFileSystem(rawLFS);
path = new Path(fs.getWorkingDirectory(), "TestBasicTableProjections");
fs = path.getFileSystem(conf);
// drop any previous tables
BasicTable.drop(path, conf);
BasicTable.Writer writer = new BasicTable.Writer(path, "a,b,c,d,e,f,g",
"[a,b,c];[d,e,f,g]", conf);
writer.finish();
Schema schema = writer.getSchema();
// String[] colNames = schema.getColumns();
Tuple tuple = TypesUtils.createTuple(schema);
// BytesWritable key;
int parts = 2;
for (int part = 0; part < parts; part++) {
writer = new BasicTable.Writer(path, conf);
TableInserter inserter = writer.getInserter("part" + part, true);
TypesUtils.resetTuple(tuple);
for (int row = 0; row < 2; row++) {
try {
for (int nx = 0; nx < tuple.size(); nx++)
tuple.set(nx, new DataByteArray(String.format("%c%d%d", 'a' + nx, part + 1, row + 1).getBytes()));
} catch (ExecException e) {
e.printStackTrace();
}
inserter.insert(new BytesWritable(String.format("k%d%d", part + 1,
row + 1).getBytes()), tuple);
}
inserter.close();
writer.finish();
}
writer.close();
}
示例15: instanceOf
import org.apache.pig.backend.executionengine.ExecException; //導入方法依賴的package包/類
/**
* Recursively check whether "datum" is an instance of "schema" and called
* by {@link #resolveUnionSchema(Schema,Object)},
* {@link #unwrappedInstanceOf(Schema,Object)}.
*
*/
protected boolean instanceOf(Schema schema, Object datum)
throws IOException {
try {
switch (schema.getType()) {
case RECORD:
if (datum instanceof Tuple) {
Tuple tuple = (Tuple) datum;
List<Field> fields = schema.getFields();
if (fields.size() != tuple.size()) {
return false;
}
for (int i = 0; i < fields.size(); i++) {
if (!instanceOf(fields.get(i).schema(), tuple.get(i)))
return false;
}
return true;
}
return false;
case UNION:
@SuppressWarnings("unused")
int index = resolveUnionSchema(schema, datum);
return true;
case ENUM:
return datum instanceof String && schema.hasEnumSymbol(((String) datum))
|| unwrappedInstanceOf(schema, datum);
case ARRAY:
return datum instanceof DataBag
|| unwrappedInstanceOf(schema, datum);
case MAP:
return datum instanceof Map
|| unwrappedInstanceOf(schema, datum);
case FIXED:
return datum instanceof DataByteArray && ((DataByteArray) datum).size() == schema.getFixedSize()
|| unwrappedInstanceOf(schema, datum);
case STRING:
return datum instanceof String
|| unwrappedInstanceOf(schema, datum);
case BYTES:
return datum instanceof DataByteArray
|| unwrappedInstanceOf(schema, datum);
case INT:
return datum instanceof Integer
|| unwrappedInstanceOf(schema, datum);
case LONG:
return datum instanceof Long
|| datum instanceof Integer
|| unwrappedInstanceOf(schema, datum);
case FLOAT:
return datum instanceof Float
|| datum instanceof Integer
|| datum instanceof Long
|| unwrappedInstanceOf(schema, datum);
case DOUBLE:
return datum instanceof Double
|| datum instanceof Float
|| datum instanceof Integer
|| datum instanceof Long
|| unwrappedInstanceOf(schema, datum);
case BOOLEAN:
return datum instanceof Boolean
|| datum instanceof Integer
|| unwrappedInstanceOf(schema, datum);
case NULL:
return datum == null;
default:
throw new RuntimeException("Unexpected type: " + schema);
}
} catch (ExecException e) {
e.printStackTrace(System.err);
throw new RuntimeException(e);
}
}