Search in sources :

Example 31 with DataFlowException

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);
    }
}
Also used : DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException) TextDBException(edu.uci.ics.textdb.api.exception.TextDBException) DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException) StorageException(edu.uci.ics.textdb.api.exception.StorageException)

Example 32 with DataFlowException

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);
    }
}
Also used : DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) TextDBException(edu.uci.ics.textdb.api.exception.TextDBException) DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException)

Example 33 with DataFlowException

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");
    }
}
Also used : DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException) DoubleField(edu.uci.ics.textdb.api.field.DoubleField)

Example 34 with DataFlowException

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");
    }
}
Also used : DataFlowException(edu.uci.ics.textdb.api.exception.DataFlowException) DateField(edu.uci.ics.textdb.api.field.DateField) Date(java.util.Date)

Aggregations

DataFlowException (edu.uci.ics.textdb.api.exception.DataFlowException)34 TextDBException (edu.uci.ics.textdb.api.exception.TextDBException)13 AttributeType (edu.uci.ics.textdb.api.schema.AttributeType)12 Schema (edu.uci.ics.textdb.api.schema.Schema)11 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)10 Attribute (edu.uci.ics.textdb.api.schema.Attribute)8 Span (edu.uci.ics.textdb.api.span.Span)7 ArrayList (java.util.ArrayList)7 SchemaConstants (edu.uci.ics.textdb.api.constants.SchemaConstants)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 StorageException (edu.uci.ics.textdb.api.exception.StorageException)5 ListField (edu.uci.ics.textdb.api.field.ListField)5 IOException (java.io.IOException)5 IField (edu.uci.ics.textdb.api.field.IField)4 Utils (edu.uci.ics.textdb.api.utils.Utils)4 AbstractSingleInputOperator (edu.uci.ics.textdb.exp.common.AbstractSingleInputOperator)4 Iterator (java.util.Iterator)4 ErrorMessages (edu.uci.ics.textdb.api.constants.ErrorMessages)3 IOperator (edu.uci.ics.textdb.api.dataflow.IOperator)3