use of org.apache.hyracks.api.dataset.ResultSetMetaData in project asterixdb by apache.
the class Waiter method updatedRecords.
/**
* Compares the records already known by the client for the given job's result set id with the records that the
* dataset directory service knows and if there are any newly discovered records returns a whole array with the
* new records filled in.
*
* @param jobId
* - Id of the job for which the directory records should be retrieved.
* @param rsId
* - Id of the result set for which the directory records should be retrieved.
* @param knownRecords
* - An array of directory records that the client is already aware of.
* @return
* Returns the updated records if new record were discovered, null otherwise
* @throws HyracksDataException
* TODO(madhusudancs): Think about caching (and still be stateless) instead of this ugly O(n) iterations for
* every check. This already looks very expensive.
*/
private DatasetDirectoryRecord[] updatedRecords(JobId jobId, ResultSetId rsId, DatasetDirectoryRecord[] knownRecords) throws HyracksDataException {
DatasetJobRecord djr = getNonNullDatasetJobRecord(jobId);
if (djr.getStatus().getState() == State.FAILED) {
List<Exception> caughtExceptions = djr.getStatus().getExceptions();
if (caughtExceptions != null && !caughtExceptions.isEmpty()) {
final Exception cause = caughtExceptions.get(caughtExceptions.size() - 1);
if (cause instanceof HyracksDataException) {
throw (HyracksDataException) cause;
}
throw HyracksDataException.create(ErrorCode.RESULT_FAILURE_EXCEPTION, cause, rsId, jobId);
} else {
throw HyracksDataException.create(ErrorCode.RESULT_FAILURE_NO_EXCEPTION, rsId, jobId);
}
}
final ResultSetMetaData resultSetMetaData = djr.getResultSetMetaData(rsId);
if (resultSetMetaData == null) {
return null;
}
DatasetDirectoryRecord[] records = resultSetMetaData.getRecords();
return Arrays.equals(records, knownRecords) ? null : records;
}
Aggregations