Search in sources :

Example 31 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class RelationManager method getTableAnalyzer.

/**
 * Gets the Lucene analyzer of a table.
 *
 * @param tableName, the name of the table, case insensitive
 * @return
 * @throws StorageException
 */
public Analyzer getTableAnalyzer(String tableName) throws StorageException {
    String analyzerString = getTableAnalyzerString(tableName);
    // convert a lucene analyzer string to an analyzer object
    Analyzer luceneAnalyzer = null;
    try {
        luceneAnalyzer = LuceneAnalyzerConstants.getLuceneAnalyzer(analyzerString);
    } catch (DataflowException e) {
        throw new StorageException(e);
    }
    return luceneAnalyzer;
}
Also used : DataflowException(edu.uci.ics.texera.api.exception.DataflowException) Analyzer(org.apache.lucene.analysis.Analyzer) StorageException(edu.uci.ics.texera.api.exception.StorageException)

Example 32 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class ScanBasedSourceOperator method open.

@Override
public void open() throws TexeraException {
    if (isOpen) {
        return;
    }
    try {
        dataReader.open();
        isOpen = true;
    } catch (Exception e) {
        throw new DataflowException(e.getMessage(), e);
    }
}
Also used : DataflowException(edu.uci.ics.texera.api.exception.DataflowException) DataflowException(edu.uci.ics.texera.api.exception.DataflowException) TexeraException(edu.uci.ics.texera.api.exception.TexeraException) StorageException(edu.uci.ics.texera.api.exception.StorageException)

Example 33 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class TwitterFeedOperator method open.

@Override
public void open() throws TexeraException {
    if (cursor != CLOSED) {
        return;
    }
    try {
        twitterConnector.getClient().connect();
        cursor = OPENED;
    } catch (Exception e) {
        throw new DataflowException(e.getMessage(), e);
    }
}
Also used : DataflowException(edu.uci.ics.texera.api.exception.DataflowException) TexeraException(edu.uci.ics.texera.api.exception.TexeraException) IOException(java.io.IOException) DataflowException(edu.uci.ics.texera.api.exception.DataflowException)

Example 34 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class TwitterUtils method getPlaceLocation.

/**
 * To track tweets inside a geoBox defined by a List</Location>.
 * The string defines the coordinates in the order of "latitude_SW, longitude_SW, latitude_NE, longitude_NE".
 *
 * @param inputLocation
 * @return
 * @throws TexeraException
 */
public static List<Location> getPlaceLocation(String inputLocation) throws TexeraException {
    List<Location> locationList = new ArrayList<>();
    if (inputLocation == null || inputLocation.isEmpty()) {
        return locationList;
    }
    List<String> boudingCoordinate = Arrays.asList(inputLocation.trim().split(","));
    if (boudingCoordinate.size() != 4 || boudingCoordinate.stream().anyMatch(s -> s.trim().isEmpty())) {
        throw new DataflowException("Please provide valid location coordinates");
    }
    List<Double> boundingBox = new ArrayList<>();
    boudingCoordinate.stream().forEach(s -> boundingBox.add(Double.parseDouble(s.trim())));
    locationList.add(new Location(new Coordinate(boundingBox.get(1), boundingBox.get(0)), new Coordinate(boundingBox.get(3), boundingBox.get(2))));
    return locationList;
}
Also used : Arrays(java.util.Arrays) Coordinate(com.twitter.hbc.core.endpoint.Location.Coordinate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TexeraException(edu.uci.ics.texera.api.exception.TexeraException) IOException(java.io.IOException) Location(com.twitter.hbc.core.endpoint.Location) ArrayList(java.util.ArrayList) List(java.util.List) DataflowException(edu.uci.ics.texera.api.exception.DataflowException) AttributeType(edu.uci.ics.texera.api.schema.AttributeType) Schema(edu.uci.ics.texera.api.schema.Schema) JsonNode(com.fasterxml.jackson.databind.JsonNode) Attribute(edu.uci.ics.texera.api.schema.Attribute) Coordinate(com.twitter.hbc.core.endpoint.Location.Coordinate) ArrayList(java.util.ArrayList) DataflowException(edu.uci.ics.texera.api.exception.DataflowException) Location(com.twitter.hbc.core.endpoint.Location)

Example 35 with DataflowException

use of edu.uci.ics.texera.api.exception.DataflowException in project textdb by TextDB.

the class DataflowUtils method tokenizeQuery.

/**
 * Tokenizes the query string using the given analyser
 *
 * @param luceneAnalyzer
 * @param query
 * @return ArrayList<String> list of results
 */
public static ArrayList<String> tokenizeQuery(Analyzer luceneAnalyzer, String query) {
    ArrayList<String> result = new ArrayList<String>();
    TokenStream tokenStream = luceneAnalyzer.tokenStream(null, new StringReader(query));
    CharTermAttribute term = tokenStream.addAttribute(CharTermAttribute.class);
    try {
        tokenStream.reset();
        while (tokenStream.incrementToken()) {
            result.add(term.toString());
        }
        tokenStream.close();
    } catch (IOException e) {
        throw new DataflowException(e);
    }
    return result;
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) CharTermAttribute(org.apache.lucene.analysis.tokenattributes.CharTermAttribute) StringReader(java.io.StringReader) DataflowException(edu.uci.ics.texera.api.exception.DataflowException) IOException(java.io.IOException)

Aggregations

DataflowException (edu.uci.ics.texera.api.exception.DataflowException)56 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)23 AttributeType (edu.uci.ics.texera.api.schema.AttributeType)20 Schema (edu.uci.ics.texera.api.schema.Schema)20 Tuple (edu.uci.ics.texera.api.tuple.Tuple)18 IOException (java.io.IOException)14 Span (edu.uci.ics.texera.api.span.Span)11 Collectors (java.util.stream.Collectors)10 SchemaConstants (edu.uci.ics.texera.api.constants.SchemaConstants)9 ArrayList (java.util.ArrayList)9 Attribute (edu.uci.ics.texera.api.schema.Attribute)8 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)7 IField (edu.uci.ics.texera.api.field.IField)7 ListField (edu.uci.ics.texera.api.field.ListField)7 List (java.util.List)7 AbstractSingleInputOperator (edu.uci.ics.texera.dataflow.common.AbstractSingleInputOperator)6 ErrorMessages (edu.uci.ics.texera.api.constants.ErrorMessages)5 StorageException (edu.uci.ics.texera.api.exception.StorageException)5 IntegerField (edu.uci.ics.texera.api.field.IntegerField)4 DataflowUtils (edu.uci.ics.texera.dataflow.utils.DataflowUtils)4