Search in sources :

Example 11 with TextDBException

use of edu.uci.ics.textdb.api.exception.TextDBException 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 12 with TextDBException

use of edu.uci.ics.textdb.api.exception.TextDBException 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 13 with TextDBException

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

the class PlanStoreResource method updateQueryPlan.

@PUT
@Path("/{plan_name}")
public TextdbWebResponse updateQueryPlan(@PathParam("plan_name") String planName, String queryPlanBeanJson) {
    try {
        QueryPlanBean queryPlanBean = new ObjectMapper().readValue(queryPlanBeanJson, QueryPlanBean.class);
        // Updating the plan in the plan store
        planStore.updatePlan(planName, queryPlanBean.getDescription(), mapper.writeValueAsString(queryPlanBean.getQueryPlan()));
    } catch (IOException | TextDBException e) {
        throw new TextdbWebException(e.getMessage());
    }
    return new TextdbWebResponse(0, "Success");
}
Also used : TextdbWebResponse(edu.uci.ics.textdb.web.response.TextdbWebResponse) TextdbWebException(edu.uci.ics.textdb.web.TextdbWebException) IOException(java.io.IOException) TextDBException(edu.uci.ics.textdb.api.exception.TextDBException) QueryPlanBean(edu.uci.ics.textdb.web.response.planstore.QueryPlanBean) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with TextDBException

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

the class PlanStoreResource method getQueryPlan.

@GET
@Path("/{plan_name}")
public QueryPlanBean getQueryPlan(@PathParam("plan_name") String planName) {
    try {
        Tuple tuple = planStore.getPlan(planName);
        if (tuple == null) {
            throw new TextdbWebException("Plan with the given name does not exist");
        }
        QueryPlanBean queryPlanBean = new QueryPlanBean(tuple.getField(PlanStoreConstants.NAME).getValue().toString(), tuple.getField(PlanStoreConstants.DESCRIPTION).getValue().toString(), mapper.readValue(tuple.getField(PlanStoreConstants.LOGICAL_PLAN_JSON).getValue().toString(), LogicalPlan.class));
        return queryPlanBean;
    } catch (TextDBException e) {
        throw new TextdbWebException(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : TextdbWebException(edu.uci.ics.textdb.web.TextdbWebException) LogicalPlan(edu.uci.ics.textdb.exp.plangen.LogicalPlan) IOException(java.io.IOException) TextDBException(edu.uci.ics.textdb.api.exception.TextDBException) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) QueryPlanBean(edu.uci.ics.textdb.web.response.planstore.QueryPlanBean)

Example 15 with TextDBException

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

the class PlanStoreResource method addQueryPlan.

@POST
public TextdbWebResponse addQueryPlan(String queryPlanBeanJson) {
    try {
        QueryPlanBean queryPlanBean = new ObjectMapper().readValue(queryPlanBeanJson, QueryPlanBean.class);
        // Adding the query plan to the PlanStore
        planStore.addPlan(queryPlanBean.getName(), queryPlanBean.getDescription(), mapper.writeValueAsString(queryPlanBean.getQueryPlan()));
    } catch (TextDBException e) {
        throw new TextdbWebException(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new TextdbWebResponse(0, "Success");
}
Also used : TextdbWebResponse(edu.uci.ics.textdb.web.response.TextdbWebResponse) TextdbWebException(edu.uci.ics.textdb.web.TextdbWebException) IOException(java.io.IOException) TextDBException(edu.uci.ics.textdb.api.exception.TextDBException) QueryPlanBean(edu.uci.ics.textdb.web.response.planstore.QueryPlanBean) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TextDBException (edu.uci.ics.textdb.api.exception.TextDBException)15 DataFlowException (edu.uci.ics.textdb.api.exception.DataFlowException)9 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)8 IOException (java.io.IOException)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 TextdbWebException (edu.uci.ics.textdb.web.TextdbWebException)4 QueryPlanBean (edu.uci.ics.textdb.web.response.planstore.QueryPlanBean)4 StorageException (edu.uci.ics.textdb.api.exception.StorageException)3 Attribute (edu.uci.ics.textdb.api.schema.Attribute)3 Schema (edu.uci.ics.textdb.api.schema.Schema)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 SchemaConstants (edu.uci.ics.textdb.api.constants.SchemaConstants)2 IField (edu.uci.ics.textdb.api.field.IField)2 AttributeType (edu.uci.ics.textdb.api.schema.AttributeType)2 Utils (edu.uci.ics.textdb.api.utils.Utils)2 AbstractSingleInputOperator (edu.uci.ics.textdb.exp.common.AbstractSingleInputOperator)2 TextdbWebResponse (edu.uci.ics.textdb.web.response.TextdbWebResponse)2 Collectors (java.util.stream.Collectors)2