Search in sources :

Example 6 with PlanTerm

use of com.cubrid.common.core.queryplan.model.PlanTerm in project cubrid-manager by CUBRID.

the class PlanParser method parseIndex.

/**
	 * Parse the index
	 * 
	 * @param indexRaw the raw index string
	 * @return the PlanTerm Object
	 */
private PlanTerm parseIndex(String indexRaw) {
    if (StringUtil.isEmpty(indexRaw)) {
        return null;
    }
    String indexName = indexRaw.trim();
    String indexCond = indexName;
    int sp = indexRaw.indexOf(' ');
    if (sp != -1) {
        indexName = indexRaw.substring(0, sp++).trim();
        indexCond = indexRaw.substring(sp, indexRaw.length()).trim();
    }
    PlanTerm planIndex = parseTerm(indexCond);
    if (planIndex == null) {
        planIndex = new PlanTerm();
    }
    planIndex.setName(indexName);
    return planIndex;
}
Also used : PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Example 7 with PlanTerm

use of com.cubrid.common.core.queryplan.model.PlanTerm in project cubrid-manager by CUBRID.

the class QueryPlanTest method testModelPlanNode.

public void testModelPlanNode() {
    PlanNode bean = new PlanNode();
    bean.setDepth(5);
    assertEquals(bean.getDepth(), 5);
    bean.setMethod("method");
    assertEquals(bean.getMethod(), "method");
    bean.setPosition("position");
    assertEquals(bean.getPosition(), "position");
    bean.setCost(new PlanCost());
    assertEquals(bean.getCost().getClass(), PlanCost.class);
    bean.setTable(new PlanTable());
    assertEquals(bean.getTable().getClass(), PlanTable.class);
    bean.setIndex(new PlanTerm());
    assertEquals(bean.getIndex().getClass(), PlanTerm.class);
    bean.setEdge(new PlanTerm());
    assertEquals(bean.getEdge().getClass(), PlanTerm.class);
    bean.setSargs(new PlanTerm());
    assertEquals(bean.getSargs().getClass(), PlanTerm.class);
    bean.setFilter(new PlanTerm());
    assertEquals(bean.getFilter().getClass(), PlanTerm.class);
    bean.setSort("sort");
    assertEquals(bean.getSort(), "sort");
    bean.setOrder("order");
    assertEquals(bean.getOrder(), "order");
    assertEquals(bean.toString() == null, false);
    bean.getChildren();
    bean.newChild();
}
Also used : PlanNode(com.cubrid.common.core.queryplan.model.PlanNode) PlanCost(com.cubrid.common.core.queryplan.model.PlanCost) PlanTable(com.cubrid.common.core.queryplan.model.PlanTable) PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Example 8 with PlanTerm

use of com.cubrid.common.core.queryplan.model.PlanTerm in project cubrid-manager by CUBRID.

the class QueryPlanTest method testModelPlanTerm.

public void testModelPlanTerm() {
    PlanTerm bean = new PlanTerm();
    bean.setType(PlanTermType.EDGE);
    assertEquals(bean.getType(), PlanTermType.EDGE);
    bean.setName("name");
    assertEquals(bean.getName(), "name");
    bean.addTermItem(new PlanTermItem());
    // assertEquals(bean.getTermItem() instanceof List, true);
    bean.getTypeString();
    bean.getTermString();
    bean.getTermItems();
    assertEquals(bean.toString() == null, false);
}
Also used : PlanTermItem(com.cubrid.common.core.queryplan.model.PlanTermItem) PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Example 9 with PlanTerm

use of com.cubrid.common.core.queryplan.model.PlanTerm in project cubrid-manager by CUBRID.

the class PlanParserTest method testExam01.

/**
	 * simple plan
	 * 
	 * @throws Exception
	 */
public void testExam01() throws Exception {
    String planString = loadPlanExmaple("plan01.txt");
    PlanParser parser = new PlanParser();
    boolean bool = parser.doParse(planString);
    assertTrue(bool);
    parser.getPlanTree(1);
    PlanResult planRoot = parser.getPlanTree(0);
    assertNotNull(planRoot);
    PlanNode planNode = planRoot.getPlanNode();
    assertEquals(planNode.getMethod(), "idx-join (inner join)");
    assertEquals(planNode.getDepth(), 1);
    PlanCost planCost = planNode.getCost();
    assertNotNull(planCost);
    assertEquals(planCost.getCard(), 40);
    assertEquals(String.valueOf(planCost.getFixedCpu()), "0.0");
    assertEquals(String.valueOf(planCost.getFixedDisk()), "2.0");
    assertEquals(String.valueOf(planCost.getFixedTotal()), "2.0");
    assertEquals(String.valueOf(planCost.getVarCpu()), "100.3");
    assertEquals(String.valueOf(planCost.getVarDisk()), "275.0");
    assertEquals(String.valueOf(planCost.getVarTotal()), "375.0");
    assertNull(planNode.getTable());
    assertNull(planNode.getIndex());
    assertNull(planNode.getEdge());
    assertNull(planNode.getFilter());
    assertNull(planNode.getSort());
    assertNull(planNode.getOrder());
    PlanTerm sargs = planNode.getSargs();
    assertNotNull(sargs);
    assertNotNull(planNode.getChildren());
    assertEquals(planNode.getChildren().size(), 2);
    PlanParser parser2 = new PlanParser();
    parser2.getPlanTree(0);
    parser2.countPlanTree();
    parser2.doParse(null);
    parser2.doParse("aaa");
}
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) PlanParser(com.cubrid.common.core.queryplan.PlanParser) PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Aggregations

PlanTerm (com.cubrid.common.core.queryplan.model.PlanTerm)9 PlanNode (com.cubrid.common.core.queryplan.model.PlanNode)5 PlanCost (com.cubrid.common.core.queryplan.model.PlanCost)4 PlanTermItem (com.cubrid.common.core.queryplan.model.PlanTermItem)3 PlanTable (com.cubrid.common.core.queryplan.model.PlanTable)2 PlanParser (com.cubrid.common.core.queryplan.PlanParser)1 PlanResult (com.cubrid.common.core.queryplan.model.PlanResult)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1