protected PrefetchTreeNode getChild(String segment) { if (children != null) { for (PrefetchTreeNode child : children) { if (segment.equals(child.getName())) { return child; } } } return null; }
protected PrefetchTreeNode getChild(String segment) { if (children != null) { Iterator it = children.iterator(); while (it.hasNext()) { PrefetchTreeNode next = (PrefetchTreeNode) it.next(); if (segment.equals(next.getName())) { return next; } } } return null; }
public String getPath(PrefetchTreeNode upTillParent) { if (parent == null || upTillParent == this) { return ""; } StringBuilder path = new StringBuilder(getName()); PrefetchTreeNode node = this.getParent(); // root node has no path while (node.getParent() != null && node != upTillParent) { path.insert(0, node.getName() + "."); node = node.getParent(); } return path.toString(); }
public String getPath(PrefetchTreeNode upTillParent) { if (parent == null || upTillParent == this) { return ""; } StringBuffer path = new StringBuffer(getName()); PrefetchTreeNode node = this.getParent(); // root node has no path while (node.getParent() != null && node != upTillParent) { path.insert(0, node.getName() + "."); node = node.getParent(); } return path.toString(); }
/** * Merges {@link PrefetchTreeNode} into the current prefetch tree, cloning * the nodes added to this tree. Merged nodes semantics (if defined) and * non-phantom status are applied to the nodes of this tree. * * @param node * a root node of a tree to merge into this tree. The path of the * merged node within the resulting tree is determined from its * name. * * @since 4.0 */ public void merge(PrefetchTreeNode node) { if (node == null) { throw new NullPointerException("Null node"); } PrefetchTreeNode start = node.getName() != null ? addPath(node.getName()) : this; merge(start, node); }
public void addChild(PrefetchTreeNode child) { if (Util.isEmptyString(child.getName())) { throw new IllegalArgumentException("Child has no segmentPath: " + child); } if (child.getParent() != this) { child.getParent().removeChild(child.getName()); child.parent = this; } if (children == null) { children = new ArrayList(4); } children.add(child); }
public void addChild(PrefetchTreeNode child) { if (Util.isEmptyString(child.getName())) { throw new IllegalArgumentException("Child has no segmentPath: " + child); } if (child.getParent() != this) { child.getParent().removeChild(child.getName()); child.parent = this; } if (children == null) { children = new ArrayList<>(4); } children.add(child); }
private PrefetchProcessorNode createDisjointNode(PrefetchTreeNode node) { // TODO, Andrus, 11/16/2005 - minor inefficiency: 'adjacentJointNodes' // would // grab ALL nodes, we just need to find first and stop... PrefetchProcessorNode decorated = !node.adjacentJointNodes().isEmpty() ? new PrefetchProcessorJointNode( getParent(), node.getName()) : new PrefetchProcessorNode(getParent(), node.getName()); decorated.setPhantom(false); return decorated; }
public boolean startDisjointPrefetch(PrefetchTreeNode node) { // look ahead for joint children as joint children will require a different // node type. // TODO, Andrus, 11/16/2005 - minor inefficiency: 'adjacentJointNodes' would // grab ALL nodes, we just need to find first and stop... PrefetchProcessorNode decorated = !node.adjacentJointNodes().isEmpty() ? decorated = new PrefetchProcessorJointNode(getParent(), node .getName()) : new PrefetchProcessorNode(getParent(), node.getName()); decorated.setPhantom(false); // semantics has to be "DISJOINT" even if the node is joint, as semantics // defines relationship with parent.. decorated.setSemantics(PrefetchTreeNode.DISJOINT_PREFETCH_SEMANTICS); return addNode(decorated); }
void merge(PrefetchTreeNode original, PrefetchTreeNode toMerge) { if (toMerge.getSemantics() != UNDEFINED_SEMANTICS) { original.setSemantics(toMerge.getSemantics()); } if (!toMerge.isPhantom()) { original.setPhantom(false); } for (PrefetchTreeNode childToMerge : toMerge.getChildren()) { PrefetchTreeNode childOrigin = original.getChild(childToMerge.getName()); if (childOrigin == null) { childOrigin = original.addPath(childToMerge.getName()); } merge(childOrigin, childToMerge); } }
/** * Removes or makes phantom a node defined by this path. If the node for this path * doesn't have any children, it is removed, otherwise it is made phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }
/** * Removes or makes phantom a node defined by this path. If the node for * this path doesn't have any children, it is removed, otherwise it is made * phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }
public boolean startPhantomPrefetch(PrefetchTreeNode node) { // root should be treated as disjoint if (getParent() == null) { return startDisjointPrefetch(node); } else { PrefetchProcessorNode decorated = new PrefetchProcessorNode(getParent(), node.getName()); decorated.setPhantom(true); return addNode(decorated); } }
public boolean startPhantomPrefetch(PrefetchTreeNode node) { // root should be treated as disjoint if (getParent() == null) { return startDisjointPrefetch(node); } else { PrefetchProcessorNode decorated = new PrefetchProcessorNode( getParent(), node.getName()); decorated.setPhantom(true); return addNode(decorated); } }
private PrefetchTreeNode cloneJointSubtree(PrefetchTreeNode parent) { PrefetchTreeNode cloned = new PrefetchTreeNode(parent, getName()); if (parent != null) { cloned.setSemantics(getSemantics()); cloned.setPhantom(isPhantom()); } if (children != null) { for (PrefetchTreeNode child : children) { if (child.isJointPrefetch()) { cloned.addChild(child.cloneJointSubtree(cloned)); } } } return cloned; }
@Override public void writeTo(Output output, PrefetchTreeNode message) throws IOException { if (message.getName() != null) { output.writeString(1, message.getName(), false); } output.writeBool(2, message.isPhantom(), false); output.writeInt32(3, message.getSemantics(), false); if (message.getEjbqlPathEntityId() != null) { output.writeString(4, message.getEjbqlPathEntityId(), false); } if (message.getEntityName() != null) { output.writeString(5, message.getEntityName(), false); } if (message.hasChildren()) { for (PrefetchTreeNode node : message.getChildren()) { output.writeObject(6, node, this, true); } } }
public boolean startJointPrefetch(PrefetchTreeNode node) { PrefetchProcessorJointNode decorated = new PrefetchProcessorJointNode( getParent(), node.getName()); decorated.setPhantom(false); decorated.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); boolean result = addNode(decorated); // set "jointChildren" flag on all nodes in the same "join group" PrefetchProcessorNode groupNode = decorated; while (groupNode.getParent() != null && !groupNode.isDisjointPrefetch()) { groupNode = (PrefetchProcessorNode) groupNode.getParent(); groupNode.setJointChildren(true); } return result; }
public boolean startJointPrefetch(PrefetchTreeNode node) { PrefetchProcessorJointNode decorated = new PrefetchProcessorJointNode(getParent(), node.getName()); decorated.setPhantom(false); decorated.setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); boolean result = addNode(decorated); // set "jointChildren" flag on all nodes in the same "join group" PrefetchProcessorNode groupNode = decorated; while (groupNode.getParent() != null && !groupNode.isDisjointPrefetch() && !groupNode.isDisjointByIdPrefetch()) { groupNode = (PrefetchProcessorNode) groupNode.getParent(); groupNode.setJointChildren(true); } return result; }
private PrefetchTreeNode deepClone(PrefetchTreeNode source, PrefetchTreeNode targetParent) { PrefetchTreeNode target = new PrefetchTreeNode(targetParent, source.getName()); target.setEjbqlPathEntityId(source.getEjbqlPathEntityId()); target.setEntityName(source.getEntityName()); target.setPhantom(source.isPhantom()); target.setSemantics(source.getSemantics()); for (PrefetchTreeNode child : source.getChildren()) { target.addChild(deepClone(child, target)); } return target; }