Search in sources :

Example 1 with PlanResult

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;
}
Also used : PlanResult(com.cubrid.common.core.queryplan.model.PlanResult) PlanNode(com.cubrid.common.core.queryplan.model.PlanNode)

Example 2 with PlanResult

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);
}
Also used : PlanResult(com.cubrid.common.core.queryplan.model.PlanResult) PlanNode(com.cubrid.common.core.queryplan.model.PlanNode)

Example 3 with PlanResult

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();
}
Also used : PlanResult(com.cubrid.common.core.queryplan.model.PlanResult) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan)

Example 4 with PlanResult

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();
        }
    }
}
Also used : PlanResult(com.cubrid.common.core.queryplan.model.PlanResult) PlanNode(com.cubrid.common.core.queryplan.model.PlanNode) PlanCost(com.cubrid.common.core.queryplan.model.PlanCost) TableItem(org.eclipse.swt.widgets.TableItem)

Example 5 with PlanResult

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);
    }
}
Also used : PlanResult(com.cubrid.common.core.queryplan.model.PlanResult) PlanParser(com.cubrid.common.core.queryplan.PlanParser)

Aggregations

PlanResult (com.cubrid.common.core.queryplan.model.PlanResult)13 PlanNode (com.cubrid.common.core.queryplan.model.PlanNode)8 PlanParser (com.cubrid.common.core.queryplan.PlanParser)3 PlanCost (com.cubrid.common.core.queryplan.model.PlanCost)3 StructQueryPlan (com.cubrid.common.core.queryplan.StructQueryPlan)1 PlanTerm (com.cubrid.common.core.queryplan.model.PlanTerm)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1