use of edu.uci.ics.textdb.api.exception.DataFlowException in project textdb by TextDB.
the class ScanBasedSourceOperator method open.
@Override
public void open() throws TextDBException {
if (isOpen) {
return;
}
try {
dataReader.open();
isOpen = true;
} catch (Exception e) {
throw new DataFlowException(e.getMessage(), e);
}
}
use of edu.uci.ics.textdb.api.exception.DataFlowException in project textdb by TextDB.
the class AbstractSingleInputOperator method getNextTuple.
@Override
public Tuple getNextTuple() throws TextDBException {
if (cursor == CLOSED) {
throw new DataFlowException(ErrorMessages.OPERATOR_NOT_OPENED);
}
if (resultCursor >= limit + offset - 1) {
return null;
}
try {
Tuple resultTuple = null;
while (true) {
resultTuple = computeNextMatchingTuple();
if (resultTuple == null) {
break;
}
resultCursor++;
if (resultCursor >= offset) {
break;
}
}
return resultTuple;
} catch (Exception e) {
throw new DataFlowException(e.getMessage(), e);
}
}
use of edu.uci.ics.textdb.api.exception.DataFlowException in project textdb by TextDB.
the class ComparableMatcher method compareDouble.
private boolean compareDouble(Tuple inputTuple) {
Object compareToObject = predicate.getCompareToValue();
Class<?> compareToType = compareToObject.getClass();
Double value = inputTuple.getField(predicate.getAttributeName(), DoubleField.class).getValue();
if (compareToType.equals(Integer.class)) {
return compareValues(value, (double) (int) compareToObject, predicate.getComparisonType());
} else if (compareToType.equals(Double.class)) {
return compareValues(value, (double) compareToObject, predicate.getComparisonType());
} else if (compareToType.equals(String.class)) {
try {
Double compareToValue = Double.parseDouble((String) predicate.getCompareToValue());
return compareValues(value, compareToValue, predicate.getComparisonType());
} catch (NumberFormatException e) {
throw new DataFlowException("Unable to parse to number " + e.getMessage());
}
} else {
throw new DataFlowException("Value " + predicate.getCompareToValue() + " is not a valid number type");
}
}
use of edu.uci.ics.textdb.api.exception.DataFlowException in project textdb by TextDB.
the class ComparableMatcher method compareDate.
private boolean compareDate(Tuple inputTuple) throws DataFlowException {
if (predicate.getCompareToValue().getClass().equals(String.class)) {
try {
String compareTo = (String) predicate.getCompareToValue();
Date compareToDate = DateFormat.getDateInstance(DateFormat.MEDIUM).parse(compareTo);
Date date = inputTuple.getField(predicate.getAttributeName(), DateField.class).getValue();
return compareValues(date, compareToDate, predicate.getComparisonType());
} catch (java.text.ParseException e) {
throw new DataFlowException("Unable to parse date: " + e.getMessage());
}
} else {
throw new DataFlowException("Value " + predicate.getCompareToValue() + " is not a string");
}
}
Aggregations