use of com.cubrid.common.core.queryplan.model.PlanResult in project cubrid-manager by CUBRID.
the class StructQueryPlan method calCost.
/**
* Calculate the cost
*
* @return
*/
public int calCost() {
int costVal = 0;
for (int i = 0, len = countSubPlan(); i < len; i++) {
PlanResult result = getSubPlan(i);
if (result == null) {
continue;
}
PlanNode node = result.getPlanNode();
if (node != null) {
costVal += node.getCost().getTotal();
}
}
return costVal;
}
use of com.cubrid.common.core.queryplan.model.PlanResult in project cubrid-manager by CUBRID.
the class QueryPlanTest method testModelPlanRoot.
public void testModelPlanRoot() {
PlanResult bean = new PlanResult();
bean.setSql("sql");
assertEquals(bean.getSql(), "sql");
bean.setRaw("raw");
assertEquals(bean.getRaw(), "raw");
bean.setPlanNode(new PlanNode());
assertEquals(bean.getPlanNode().getClass(), PlanNode.class);
bean.getPlainSql();
assertEquals(bean.toString() == null, false);
}
use of com.cubrid.common.core.queryplan.model.PlanResult in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method fillPlanHistory.
public void fillPlanHistory() {
clearAll();
planHistoryList = new ArrayList<StructQueryPlan>();
List<StructQueryPlan> StructQueryPlanList = PlanHistoryManager.getStructQueryPlanListFromPreference(editor.getSelectedDatabase());
if (StructQueryPlanList != null) {
planHistoryList.addAll(StructQueryPlanList);
}
if (planHistoryList.size() == 0) {
PlanTabItem tabItem = newPlanTab(1);
plansTabFolder.setSelection(tabItem);
}
int index = 1;
for (int i = 0, len = planHistoryList.size(); i < len; i++) {
StructQueryPlan sq = planHistoryList.get(i);
PlanResult planRoot = sq.getSubPlan(0);
if (planRoot == null) {
continue;
}
printHistory(index, sq);
index++;
}
refreshTableByCurrentSort();
}
use of com.cubrid.common.core.queryplan.model.PlanResult in project cubrid-manager by CUBRID.
the class QueryPlanCompositeWithHistory method printHistory.
/**
* print a plan history
*
* @param uid int
* @param sq StructQueryPlan
*/
private void printHistory(int uid, StructQueryPlan sq) {
String created = sq.getCreatedDateString();
float costValue = 0.0f;
PlanResult planRoot = sq.getSubPlan(0);
if (planRoot == null) {
return;
}
for (int i = 0, len = sq.countSubPlan(); i < len; i++) {
planRoot = sq.getSubPlan(i);
PlanNode node = planRoot.getPlanNode();
if (node != null && node.getCost() != null) {
PlanCost cost = node.getCost();
costValue += cost.getTotal();
}
}
TableItem item = new TableItem(planHistoryTable, SWT.LEFT);
item.setText(0, String.valueOf(uid));
item.setText(1, created);
item.setText(2, String.valueOf(costValue));
String sql = planRoot.getPlainSql();
if (sql.length() > 100) {
sql = sql.substring(0, 96);
sql += "...";
}
item.setText(3, sql);
for (int i = 0, len = planHistoryTblCols.length; i < len; i++) {
if (planHistoryTblCols[i] != null && !planHistoryTblCols[i].isDisposed()) {
planHistoryTblCols[i].pack();
}
}
}
use of com.cubrid.common.core.queryplan.model.PlanResult in project cubrid-manager by CUBRID.
the class PlanParserTest method testExam02.
/**
* complicated plan
*
* @throws Exception
*/
public void testExam02() throws Exception {
String planString = loadPlanExmaple("plan02.txt");
PlanParser parser = new PlanParser();
boolean bool = parser.doParse(planString);
assertTrue(bool);
int subPlanCount = parser.countPlanTree();
assertEquals(10, subPlanCount);
for (int i = 0; i < subPlanCount; i++) {
PlanResult planRoot = parser.getPlanTree(i);
assertNotNull(planRoot);
}
}
Aggregations