本文整理匯總了Java中org.apache.pig.backend.executionengine.ExecException類的典型用法代碼示例。如果您正苦於以下問題:Java ExecException類的具體用法?Java ExecException怎麽用?Java ExecException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ExecException類屬於org.apache.pig.backend.executionengine包,在下文中一共展示了ExecException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNext
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public Tuple getNext() throws IOException {
try {
boolean flag = recordReader.nextKeyValue();
if (!flag) {
return null;
}
Text value = (Text) recordReader.getCurrentValue();
Map<String, Object> stringObjectMap = NginxAccessLogParser.parseLine(value.toString());
List propertiyList = new ArrayList<String>();
propertiyList.add(0, stringObjectMap.get("remoteAddr"));
propertiyList.add(1, DateFormatUtils.format((Date) stringObjectMap.get("accessTime"), "yyyy-MM-dd HH:mm:ss"));
propertiyList.add(2, stringObjectMap.get("method"));
propertiyList.add(3, stringObjectMap.get("url"));
propertiyList.add(4, stringObjectMap.get("protocol"));
propertiyList.add(5, stringObjectMap.get("agent"));
propertiyList.add(6, stringObjectMap.get("refer"));
propertiyList.add(7, stringObjectMap.get("status"));
propertiyList.add(8, stringObjectMap.get("length"));
return TupleFactory.getInstance().newTuple(propertiyList);
} catch (InterruptedException e) {
throw new ExecException("Read data error", PigException.REMOTE_ENVIRONMENT, e);
}
}
示例2: exec
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public Boolean exec(final Tuple tuple) throws IOException {
if (tuple == null || tuple.size() == 0) {
return false;
}
try {
Object object = tuple.get(0);
if (object == null) {
return false;
}
int i = (Integer) object;
return i == 0 || i == 1 || i == 4 || i == 5 || i == 9;
} catch (ExecException e) {
throw new IOException(e);
}
}
示例3: createPig
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
protected PigServer createPig() throws ExecException {
HdpBootstrap.hackHadoopStagingOnWin();
Properties properties = HdpBootstrap.asProperties(QueryTestParams.provisionQueries(HdpBootstrap.hadoopConfig()));
String pigHost = properties.getProperty("pig");
// remote Pig instance
if (StringUtils.hasText(pigHost) && !"local".equals(pig)) {
LogFactory.getLog(PigWrapper.class).info("Executing Pig in Map/Reduce mode");
return new PigServer(ExecType.MAPREDUCE, properties);
}
// use local instance
LogFactory.getLog(PigWrapper.class).info("Executing Pig in local mode");
properties.put("mapred.job.tracker", "local");
return new PigServer(ExecType.LOCAL, properties);
}
示例4: setCollectionTupleValues
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
/** set the values of set/list at and after the position of the tuple */
private void setCollectionTupleValues(Tuple tuple, int position, Object value, AbstractType<?> validator) throws ExecException
{
if (validator instanceof MapType)
{
setMapTupleValues(tuple, position, value, validator);
return;
}
AbstractType elementValidator;
if (validator instanceof SetType)
elementValidator = ((SetType<?>) validator).getElementsType();
else if (validator instanceof ListType)
elementValidator = ((ListType<?>) validator).getElementsType();
else
return;
int i = 0;
Tuple innerTuple = TupleFactory.getInstance().newTuple(((Collection<?>) value).size());
for (Object entry : (Collection<?>) value)
{
setTupleValue(innerTuple, i, cassandraToPigData(entry, elementValidator), elementValidator);
i++;
}
tuple.set(position, innerTuple);
}
示例5: setMapTupleValues
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
/** set the values of set/list at and after the position of the tuple */
private void setMapTupleValues(Tuple tuple, int position, Object value, AbstractType<?> validator) throws ExecException
{
AbstractType<?> keyValidator = ((MapType<?, ?>) validator).getKeysType();
AbstractType<?> valueValidator = ((MapType<?, ?>) validator).getValuesType();
int i = 0;
Tuple innerTuple = TupleFactory.getInstance().newTuple(((Map<?,?>) value).size());
for(Map.Entry<?,?> entry : ((Map<Object, Object>)value).entrySet())
{
Tuple mapEntryTuple = TupleFactory.getInstance().newTuple(2);
setTupleValue(mapEntryTuple, 0, cassandraToPigData(entry.getKey(), keyValidator), keyValidator);
setTupleValue(mapEntryTuple, 1, cassandraToPigData(entry.getValue(), valueValidator), valueValidator);
innerTuple.set(i, mapEntryTuple);
i++;
}
tuple.set(position, innerTuple);
}
示例6: setCollectionTupleValues
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
/** set the values of set/list at and after the position of the tuple */
private void setCollectionTupleValues(Tuple tuple, int position, Object value, AbstractType<?> validator) throws ExecException
{
if (validator instanceof MapType)
{
setMapTupleValues(tuple, position, value, validator);
return;
}
AbstractType<?> elementValidator;
if (validator instanceof SetType)
elementValidator = ((SetType<?>) validator).elements;
else if (validator instanceof ListType)
elementValidator = ((ListType<?>) validator).elements;
else
return;
int i = 0;
Tuple innerTuple = TupleFactory.getInstance().newTuple(((Collection<?>) value).size());
for (Object entry : (Collection<?>) value)
{
setTupleValue(innerTuple, i, entry, elementValidator);
i++;
}
tuple.set(position, innerTuple);
}
示例7: setMapTupleValues
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
/** set the values of set/list at and after the position of the tuple */
private void setMapTupleValues(Tuple tuple, int position, Object value, AbstractType<?> validator) throws ExecException
{
AbstractType<?> keyValidator = ((MapType<?, ?>) validator).keys;
AbstractType<?> valueValidator = ((MapType<?, ?>) validator).values;
int i = 0;
Tuple innerTuple = TupleFactory.getInstance().newTuple(((Map<?,?>) value).size());
for(Map.Entry<?,?> entry : ((Map<Object, Object>)value).entrySet())
{
Tuple mapEntryTuple = TupleFactory.getInstance().newTuple(2);
setTupleValue(mapEntryTuple, 0, entry.getKey(), keyValidator);
setTupleValue(mapEntryTuple, 1, entry.getValue(), valueValidator);
innerTuple.set(i, mapEntryTuple);
i++;
}
tuple.set(position, innerTuple);
}
示例8: 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) + "'";
}
示例9: binData
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
protected static Tuple binData(DataBag values, int nbins, int width, double min) throws ExecException {
try {
System.err.println(values + " " + nbins + " " + width + " " + min);
long[] bins = new long[nbins];
Iterator<Tuple> it = values.iterator();
double val = 0;
int bin = 0;
while (it.hasNext()) {
Tuple next = it.next();
val = ((Number) next.get(0)).doubleValue() - min; // Shift by the min
bin = (int) Math.floor(val / width);
bins[bin]++;
}
Tuple tuple = tupleFactory.newTuple(bins.length);
for (int i = 0; i < bins.length; i++) {
tuple.set(i, bins[i]);
}
return tuple;
} catch (Exception e) {
log.warn("Exception while processing bins={}, width={}, values={}", new Object[] { nbins, width, values });
throw new ExecException(e.getCause());
}
}
示例10: approximateCompareBags
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
private Boolean approximateCompareBags(DataBag inputBag1, DataBag inputBag2) throws ExecException {
// Hardcode Acceptable Error
double errorLimit = 0.0000001;
Iterator<Tuple> iter1 = inputBag1.iterator();
Iterator<Tuple> iter2 = inputBag2.iterator();
while (iter1.hasNext()) {
Tuple tuple1 = iter1.next();
Tuple tuple2 = iter2.next();
// Check error
if (Math.abs((Double) tuple1.get(0) - (Double) tuple2.get(0)) > errorLimit) return false;
// TODO: Add unit test for differenced case
//if (Math.abs((Double) tuple1.get(1) - (Double) tuple2.get(1)) > errorLimit) return false;
if (Math.abs((Double) tuple1.get(2) - (Double) tuple2.get(2)) > errorLimit) return false;
if (Math.abs((Double) tuple1.get(3) - (Double) tuple2.get(3)) > errorLimit) return false;
if (Math.abs((Double) tuple1.get(4) - (Double) tuple2.get(4)) > errorLimit) return false;
}
return true;
}
示例11: exec
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public Map<String, String> exec(Tuple input) throws IOException {
try {
if (input == null || input.size() < 1) {
throw new IOException("Not enough arguments to " +
this.getClass().getName() + ": got " + input.size() +
", expected at least 1");
}
if (input.get(0) == null) {
return null;
}
String jsonLiteral = (String) input.get(0);
return parseStringToMap(jsonLiteral);
} catch (ExecException e) {
LOG.warn("Error in " + getClass() + " with input " + input, e);
throw new IOException(e);
}
}
示例12: updateStoredTupleWhenConfidenceLevelHigher
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
/**
* Stores <code>newTuple</code> in <code>deduplicatedTuplesMap</code> when its confidence level is
* higher than already stored tuple or when tuple for given identifier (stored as first tuple element) was not stored yet.
*/
private void updateStoredTupleWhenConfidenceLevelHigher(Tuple newTuple, Map<String, Tuple> deduplicatedTuplesMap) throws ExecException {
String tupleId = (String) newTuple.get(0);
Tuple storedTuple = deduplicatedTuplesMap.get(tupleId);
if (storedTuple != null) {
Float newTupleConfidenceLevel = (Float) newTuple.get(this.confidenceLevelPosition);
Float storedTupleConfidenceLevel = (Float) storedTuple.get(this.confidenceLevelPosition);
if (newTupleConfidenceLevel != null &&
(storedTupleConfidenceLevel == null || newTupleConfidenceLevel > storedTupleConfidenceLevel)) {
// replacing stored tuple with new tuple when confidence level is higher or when stored tuple didn't have it defined
deduplicatedTuplesMap.put(tupleId, newTuple);
}
} else {
deduplicatedTuplesMap.put(tupleId, newTuple);
}
}
示例13: makeLongColumnSelector
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public LongColumnSelector makeLongColumnSelector(String paramString)
{
return new LongColumnSelector()
{
@Override
public long get()
{
try {
Object obj = ((Tuple) inputs.next()).get(0);
if (obj instanceof Number) {
return ((Number)obj).longValue();
} else {
return Long.parseLong(obj.toString());
}
} catch(ExecException ex) {
throw new RuntimeException(ex);
}
}
};
}
示例14: makeFloatColumnSelector
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public FloatColumnSelector makeFloatColumnSelector(String paramString)
{
return new FloatColumnSelector()
{
@Override
public float get()
{
try {
Object obj = ((Tuple) inputs.next()).get(0);
if (obj instanceof Number) {
return ((Number)obj).floatValue();
} else {
return Float.parseFloat(obj.toString());
}
} catch(ExecException ex) {
throw new RuntimeException(ex);
}
}
};
}
示例15: makeObjectColumnSelector
import org.apache.pig.backend.executionengine.ExecException; //導入依賴的package包/類
@Override
public ObjectColumnSelector makeObjectColumnSelector(String paramString)
{
return new ObjectColumnSelector()
{
@Override
public Class classOfObject()
{
return Object.class;
}
@Override
public Object get()
{
if(inputs.hasNext()) {
try {
DataByteArray d = (DataByteArray)((Tuple)inputs.next()).get(0);
return strategy.fromByteBuffer(ByteBuffer.wrap(d.get()), d.get().length);
} catch (ExecException ex) {
throw new RuntimeException("failed to get to sketch object", ex);
}
}
return null;
}
};
}