use of com.cubrid.common.core.queryplan.model.PlanTable in project cubrid-manager by CUBRID.
the class PlanParser method parseClass.
/**
*
* Parse classes
*
* @param raw the raw string
* @return the PlanTable object
*/
private PlanTable parseClass(String raw) {
// C nation C(215/6)
int sp = raw.indexOf(' ');
if (sp == -1) {
return null;
}
String newRaw = raw.substring(sp + 1);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<raw>" + newRaw + "</raw>");
}
// for partitioned table : (game, game__p__medal1) as game(2833/196) (sargs 0)
// eg. general table : athlete A(6677/264)
sp = 0;
boolean partitioned = false;
if (newRaw.charAt(0) == '(') {
sp = 1;
partitioned = true;
}
int ep = newRaw.indexOf('(', sp);
if (ep == -1) {
return null;
}
String className = newRaw.substring(0, ep);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<className>" + className + "</className>");
}
// for partitioned table
String[] partitions = null;
if (partitioned) {
String[] tmpArr = splitPartitionedTable(className);
if (tmpArr != null && tmpArr.length > 1) {
className = tmpArr[0];
partitions = new String[tmpArr.length - 1];
for (int i = 1, len = tmpArr.length; i < len; i++) {
partitions[i - 1] = tmpArr[i].trim();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<partition>" + partitions[i - 1] + "</partition>");
}
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<className-new>" + className + "</className-new>");
}
}
sp = ep;
ep = newRaw.indexOf(')', sp);
if (ep == -1) {
return null;
}
newRaw = newRaw.substring(sp, ep + 1);
String pattenString = "\\(([0-9]+)/([0-9]+)\\)";
Matcher matcher = Pattern.compile(pattenString).matcher(newRaw);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<PlanClass:matches>" + matcher.matches() + "</PlanClass:matches>");
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("<PlanClass:groupCount>" + matcher.groupCount() + "</PlanClass:groupCount>");
}
if (!matcher.matches() || matcher.groupCount() != 2) {
return null;
}
if (className.indexOf(' ') != -1) {
String[] splitClassName = className.split(" ");
if (splitClassName != null && splitClassName.length == 2) {
String className1 = StringUtil.trim(splitClassName[0]);
String className2 = StringUtil.trim(splitClassName[1]);
if (StringUtil.isEqual(className1, className2)) {
className = className1;
}
}
}
PlanTable planClass = new PlanTable();
planClass.setName(className);
planClass.setCard(StringUtil.intValue(matcher.group(1)));
planClass.setPage(StringUtil.intValue(matcher.group(2)));
planClass.setPartitions(partitions);
return planClass;
}
use of com.cubrid.common.core.queryplan.model.PlanTable 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();
}
use of com.cubrid.common.core.queryplan.model.PlanTable in project cubrid-manager by CUBRID.
the class QueryPlanTest method testModelPlanTable.
public void testModelPlanTable() {
PlanTable bean = new PlanTable();
bean.setName("name");
assertEquals(bean.getName(), "name");
bean.setCard(4);
assertEquals(bean.getCard(), 4);
bean.setPage(4);
assertEquals(bean.getPage(), 4);
assertEquals(bean.toString() == null, false);
assertEquals(bean.toString() == null, false);
}
use of com.cubrid.common.core.queryplan.model.PlanTable 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();
bean.addChild(new PlanNode());
assertNotNull(bean.toString());
assertNotNull(bean.getDebugString());
}
use of com.cubrid.common.core.queryplan.model.PlanTable in project cubrid-manager by CUBRID.
the class QueryPlanTest method testModelPlanTable.
public void testModelPlanTable() {
PlanTable bean = new PlanTable();
bean.setName("name");
assertEquals(bean.getName(), "name");
bean.setCard(4);
assertEquals(bean.getCard(), 4);
bean.setPage(4);
assertEquals(bean.getPage(), 4);
assertEquals(bean.toString() == null, false);
assertEquals(bean.toString() == null, false);
bean.getPartitions();
bean.getTextPartitions();
String[] testStrings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
bean.setPartitions(testStrings);
bean.getPartitions();
bean.getTextPartitions();
}