/** * @param rootNode Root tree node. * @return String representation of the tree. */ public String print(T rootNode) { StringBuilder b = new StringBuilder(); try { print(rootNode, b); } catch (IOException e) { throw new IllegalStateException(e); } return b.toString(); }
/** * @param treeNode Tree node. * @param prefix Prefix. * @param tail Tail child. * @param a Output. * @throws IOException If failed. */ private void printTree(T treeNode, String prefix, boolean tail, Appendable a) throws IOException { List<T> children = getChildren(treeNode); int cnt = children == null ? 0 : children.size(); a.append(prefix).append(tail ? "└── " : "├── ").append(formatTreeNode(treeNode)).append('\n'); String childPrefix = prefix + (tail ? " " : "│ "); if (children == null) a.append(childPrefix).append("└── <list of children is not accessible>\n"); else { for (int i = 0; i < cnt; i++) printTree(children.get(i), childPrefix, i == cnt - 1, a); } }
/** * @param rootNode Root tree node. * @param a Output. */ public void print(T rootNode, Appendable a) throws IOException { printTree(rootNode, "", true, a); }
/** * @param rootNode Root tree node. * @param a Output. */ public void print(T rootNode, Appendable a) throws IOException { printTree(rootNode, "", true, a); }
/** * For debug. * * @return Tree as {@link String}. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unused") public final String printTree() throws IgniteCheckedException { long rootPageId; long metaPage = acquirePage(metaPageId); try { rootPageId = getFirstPageId(metaPageId, metaPage, -1); } finally { releasePage(metaPageId, metaPage); } return treePrinter.print(rootPageId); }
/** * @param treeNode Tree node. * @param prefix Prefix. * @param tail Tail child. * @param a Output. * @throws IOException If failed. */ private void printTree(T treeNode, String prefix, boolean tail, Appendable a) throws IOException { List<T> children = getChildren(treeNode); int cnt = children == null ? 0 : children.size(); a.append(prefix).append(tail ? "└── " : "├── ").append(formatTreeNode(treeNode)).append('\n'); String childPrefix = prefix + (tail ? " " : "│ "); if (children == null) a.append(childPrefix).append("└── <list of children is not accessible>\n"); else { for (int i = 0; i < cnt; i++) printTree(children.get(i), childPrefix, i == cnt - 1, a); } }
/** * @param root Root model. * @return Tree as a string. */ @SuppressWarnings("unused") private String printQueryModel(QueryModel root) { GridTreePrinter<QueryModel> mp = new GridTreePrinter<QueryModel>() { /** {@inheritDoc} */ @Override protected List<QueryModel> getChildren(QueryModel m) { return m; } /** {@inheritDoc} */ @Override protected String formatTreeNode(QueryModel m) { return "[ " +(m.uniqueAlias == null ? "+" : m.uniqueAlias.alias()) + " -> " + m.type + " ns:" + m.needSplit + " nsch:" + m.needSplitChild + " ast: " + ast(m) +" ]"; } private String ast(QueryModel m) { if (m.prnt == null) return "-+-+-"; String ast = m.ast().getSQL().replace('\n', ' '); int maxLen = 2000; return ast.length() <= maxLen ? ast : ast.substring(0, maxLen); } }; return mp.print(root); }
/** * @param rootNode Root tree node. * @return String representation of the tree. */ public String print(T rootNode) { StringBuilder b = new StringBuilder(); try { print(rootNode, b); } catch (IOException e) { throw new IllegalStateException(e); } return b.toString(); }
/** * For debug. * * @return Tree as {@link String}. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unused") public final String printTree() throws IgniteCheckedException { long rootPageId; long metaPage = acquirePage(metaPageId); try { rootPageId = getFirstPageId(metaPageId, metaPage, -1); } finally { releasePage(metaPageId, metaPage); } return treePrinter.print(rootPageId); }