use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class HDFSLookupReaderFactory method configure.
@Override
public void configure(IServiceContext serviceCtx, Map<String, String> configuration) throws AsterixException {
this.serviceCtx = serviceCtx;
this.configuration = configuration;
JobConf conf = HDFSUtils.configureHDFSJobConf(configuration);
try {
confFactory = new ConfFactory(conf);
} catch (HyracksDataException e) {
throw new AsterixException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class StreamDataFlowController method start.
@Override
public void start(IFrameWriter writer) throws HyracksDataException {
try {
ArrayTupleBuilder tb = new ArrayTupleBuilder(1);
tupleForwarder.initialize(ctx, writer);
while (true) {
tb.reset();
if (!dataParser.parse(tb.getDataOutput())) {
break;
}
tb.addFieldEndOffset();
tupleForwarder.addTuple(tb);
}
tupleForwarder.close();
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class StreamRecordReaderFactory method createRecordReader.
@Override
public IRecordReader<? extends char[]> createRecordReader(IHyracksTaskContext ctx, int partition) throws HyracksDataException {
try {
StreamRecordReader streamRecordReader = (StreamRecordReader) recordReaderClazz.getConstructor().newInstance();
streamRecordReader.configure(streamFactory.createInputStream(ctx, partition), configuration);
return streamRecordReader;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class TwitterPullRecordReader method next.
@Override
public IRawRecord<String> next() throws IOException, InterruptedException {
if (result == null || nextTweetIndex >= result.getTweets().size()) {
Thread.sleep(1000 * requestInterval);
query.setSinceId(lastTweetIdReceived);
try {
result = twitter.search(query);
} catch (TwitterException e) {
throw new HyracksDataException(e);
}
nextTweetIndex = 0;
}
if (result != null && !result.getTweets().isEmpty()) {
List<Status> tw = result.getTweets();
Status tweet = tw.get(nextTweetIndex++);
if (lastTweetIdReceived < tweet.getId()) {
lastTweetIdReceived = tweet.getId();
}
// transform tweet obj to json
String jsonTweet = TwitterObjectFactory.getRawJSON(tweet);
record.set(jsonTweet);
return record;
} else {
return null;
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class FrameSpiller method open.
public void open() throws HyracksDataException {
try {
this.currentWriteFile = StoragePathUtil.createFile(fileNamePrefix, fileCount++);
this.currentReadFile = currentWriteFile;
this.bos = new BufferedOutputStream(new FileOutputStream(currentWriteFile));
this.bis = new BufferedInputStream(new FileInputStream(currentReadFile));
} catch (Exception e) {
LOGGER.fatal("Unable to create spill file", e);
throw new HyracksDataException(e);
}
}
Aggregations