Search in sources :

Example 1 with PlanTermItem

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

the class QueryPlanTest method testModelPlanTermItem.

public void testModelPlanTermItem() {
    PlanTermItem bean = new PlanTermItem();
    bean.setCondition("condition");
    assertEquals(bean.getCondition(), "condition");
    bean.setAttribute("attribute");
    assertEquals(bean.getAttribute(), "attribute");
    assertEquals(bean.toString() == null, false);
}
Also used : PlanTermItem(com.cubrid.common.core.queryplan.model.PlanTermItem)

Example 2 with PlanTermItem

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

the class QueryPlanComposite method printSubPlanTerm.

/**
	 * print the sub plan term.
	 *
	 * @param treeItem TreeItem
	 * @param term PlanTerm
	 * @param typeName String
	 * @param isOddRow boolean
	 */
private void printSubPlanTerm(TreeItem treeItem, PlanTerm term, String typeName, boolean isOddRow) {
    PlanTermItem[] termItems = term.getTermItems();
    if (termItems == null) {
        return;
    }
    String icon = "icons/queryeditor/qe_explain_table.png";
    int len = termItems.length;
    if (len == 1) {
        TreeItem termTreeItem = new TreeItem(treeItem, SWT.NONE);
        termTreeItem.setText(0, typeName);
        termTreeItem.setImage(0, CommonUIPlugin.getImage(icon));
        termTreeItem.setText(3, term.getTermString());
        if (termItems[0] != null) {
            termTreeItem.setText(7, termItems[0].getAttribute());
        }
    } else {
        PlanTermItem planTermItem = termItems[0];
        if (planTermItem == null || planTermItem.getCondition() == null) {
            return;
        }
        for (int j = 0; j < len; j++) {
            planTermItem = termItems[j];
            if (planTermItem == null || planTermItem.getCondition() == null) {
                continue;
            }
            TreeItem item = new TreeItem(treeItem, SWT.NONE);
            // Type
            item.setText(0, typeName + " " + (j + 1));
            item.setImage(0, CommonUIPlugin.getImage(icon));
            int i = 1;
            // Table
            item.setText(i++, "");
            // Index
            item.setText(i++, "");
            // Terms
            item.setText(i++, planTermItem.getCondition());
            // Cost
            item.setText(i++, "");
            // Card
            item.setText(i++, "");
            // Row/Page
            item.setText(i++, "");
            // Extra informations
            item.setText(i++, planTermItem.getAttribute());
            item.setExpanded(true);
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) PlanTermItem(com.cubrid.common.core.queryplan.model.PlanTermItem)

Example 3 with PlanTermItem

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

the class PlanParser method parseTerm.

/**
	 * Parse term
	 * 
	 * @param raw the raw string
	 * @return the PlanTerm Object
	 */
private PlanTerm parseTerm(String raw) {
    // sargs: rownum range (min inf_lt 10) (sel 0.1) (rank 3) (instnum term) (not-join eligible) (loc 0)
    // sargs: (rownum range (1 ge_le 100)) (sel 0.1) (rank 3) (instnum term) (not-join eligible) (loc 0)
    // sargs: A.gender=B.s_name (sel 0.001) (join term) (mergeable) (inner-join) (loc 0)
    // sargs: y.j range (min inf_lt10) (sel 1) (rank 2) (sargterm) (not-join eligible) (loc 0)
    // sargs: x.i range ((select max(z.i) from z zwhere z.c=x.c) gt_inf max) (sel 0.1) (rank 10) (sarg term) (not-join eligible) (loc 0)
    // sargs: x.vc range ('b' gt_inf max) (sel 0.1) (rank 2) (sarg term) (not-join eligible) (loc 0)
    // edge:  A.gender=B.s_name (sel 0.001) (join term) (mergeable) (inner-join) (loc 0)
    // sargs: table(0) -> t t(5/1)
    PlanTerm term = new PlanTerm();
    term.setName("");
    Pattern patternTable = Pattern.compile("table\\([0-9]+\\) \\-\\> ");
    int sp = 0;
    String[] arr = raw.split(" AND ");
    for (int i = 0, len = arr.length; i < len; i++) {
        String eachTerm = arr[i].trim();
        String condition = "";
        String attribute = "";
        boolean passed = false;
        // (sel #.#)
        if (!passed) {
            sp = eachTerm.indexOf("(sel ");
            if (sp != -1) {
                condition = eachTerm.substring(0, sp).trim();
                attribute = eachTerm.substring(sp).trim();
                passed = true;
            }
        }
        // sargs: table(0) -> t node[1]
        if (!passed) {
            Matcher m = patternTable.matcher(eachTerm);
            if (m.find()) {
                condition = eachTerm;
                passed = true;
            }
        }
        if (!passed) {
            attribute = eachTerm;
        }
        PlanTermItem item = new PlanTermItem();
        item.setCondition(condition);
        item.setAttribute(attribute);
        term.addTermItem(item);
    }
    return term;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) PlanTermItem(com.cubrid.common.core.queryplan.model.PlanTermItem) PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Example 4 with PlanTermItem

use of com.cubrid.common.core.queryplan.model.PlanTermItem 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 5 with PlanTermItem

use of com.cubrid.common.core.queryplan.model.PlanTermItem 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.getTermString();
    bean.getTermItems();
    bean.addTermItem(new PlanTermItem());
    // assertEquals(bean.getTermItem() instanceof List, true);
    bean.getTypeString();
    bean.getTermString();
    bean.getTermItems();
    assertEquals(bean.toString() == null, false);
    bean.setType(PlanTermType.FILTER);
    bean.getTypeString();
    bean.setType(PlanTermType.INDEX);
    bean.getTypeString();
    bean.setType(PlanTermType.SARGS);
    bean.getTypeString();
    bean.setType(null);
    bean.getTypeString();
    assertNotNull(bean.toString());
    assertNotNull(PlanTerm.toString(bean, 3));
}
Also used : PlanTermItem(com.cubrid.common.core.queryplan.model.PlanTermItem) PlanTerm(com.cubrid.common.core.queryplan.model.PlanTerm)

Aggregations

PlanTermItem (com.cubrid.common.core.queryplan.model.PlanTermItem)6 PlanTerm (com.cubrid.common.core.queryplan.model.PlanTerm)3 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1