use of edu.uci.ics.texera.storage.DataReader in project textdb by TextDB.
the class PlanStoreResource method getAllQueryPlans.
@GET
public QueryPlanListBean getAllQueryPlans() {
ArrayList<QueryPlanBean> queryPlans = new ArrayList<>();
try {
// Getting an iterator for the plan store
DataReader reader = planStore.getPlanIterator();
reader.open();
// Iterating through the stored plans, and mapping them to a QueryPlanRequest object
Tuple tuple;
while ((tuple = reader.getNextTuple()) != null) {
String name = tuple.getField(PlanStoreConstants.NAME).getValue().toString();
String description = tuple.getField(PlanStoreConstants.DESCRIPTION).getValue().toString();
String logicalPlanJson = tuple.getField(PlanStoreConstants.LOGICAL_PLAN_JSON).getValue().toString();
queryPlans.add(new QueryPlanBean(name, description, mapper.readValue(logicalPlanJson, LogicalPlan.class)));
}
} catch (TexeraException e) {
throw new TexeraWebException(e.getMessage());
} catch (IOException e) {
throw new TexeraWebException("fail to parse json:\n" + e.getMessage());
}
return new QueryPlanListBean(queryPlans);
}
Aggregations