public boolean haveJointNode(PrefetchTreeNode prefetchTree) { if(prefetchTree == null) { return false; } haveJointNode = false; prefetchTree.traverse(this); return haveJointNode; }
/** * Returns a collection of PrefetchTreeNodes in this tree with joint semantics. */ public Collection jointNodes() { Collection c = new ArrayList(); traverse(new CollectionBuilderOperation(c, false, true, false, false)); return c; }
/** * Returns a collection of PrefetchTreeNodes with disjoint semantics * * @since 3.1 */ public Collection<PrefetchTreeNode> disjointByIdNodes() { Collection<PrefetchTreeNode> c = new ArrayList<>(); traverse(new CollectionBuilderOperation(c, false, true, false, false, false)); return c; }
/** * Returns a subset of nodes with "joint" semantics that are to be * prefetched in the same query as the current node. Result excludes this * node, regardless of its semantics. */ public Collection<PrefetchTreeNode> adjacentJointNodes() { Collection<PrefetchTreeNode> c = new ArrayList<>(); traverse(new AdjacentJoinsOperation(c)); return c; }
/** * Returns a collection of PrefetchTreeNodes in this tree with joint * semantics. */ public Collection<PrefetchTreeNode> jointNodes() { Collection<PrefetchTreeNode> c = new ArrayList<>(); traverse(new CollectionBuilderOperation(c, false, false, true, false, false)); return c; }
/** * Returns a collection of PrefetchTreeNodes with disjoint semantics. */ public Collection<PrefetchTreeNode> disjointNodes() { Collection<PrefetchTreeNode> c = new ArrayList<>(); traverse(new CollectionBuilderOperation(c, true, false, false, false, false)); return c; }
/** * Returns a collection of PrefetchTreeNodes that are not phantoms. */ public Collection<PrefetchTreeNode> nonPhantomNodes() { Collection<PrefetchTreeNode> c = new ArrayList<>(); traverse(new CollectionBuilderOperation(c, true, true, true, true, false)); return c; }
PrefetchProcessorNode buildTree(PrefetchTreeNode tree) { // reset state this.nodeStack = new LinkedList(); this.root = null; tree.traverse(this); if (root == null) { throw new CayenneRuntimeException( "Failed to create prefetch processing tree."); } return root; }
/** * Returns a subset of nodes with "joint" semantics that are to be prefetched in the * same query as the current node. Result excludes this node, regardless of its * semantics. */ public Collection adjacentJointNodes() { Collection c = new ArrayList(); traverse(new AdjacentJoinsOperation(c)); return c; }
/** * Returns a collection of PrefetchTreeNodes with disjoint semantics. */ public Collection disjointNodes() { Collection c = new ArrayList(); traverse(new CollectionBuilderOperation(c, true, false, false, false)); return c; }
/** * Returns a collection of PrefetchTreeNodes that are not phantoms. */ public Collection nonPhantomNodes() { Collection c = new ArrayList(); traverse(new CollectionBuilderOperation(c, true, true, true, false)); return c; }
public void encodeAsXML(XMLEncoder encoder) { traverse(new XMLEncoderOperation(encoder)); }
PrefetchProcessorNode buildTree(PrefetchTreeNode tree) { // reset state this.nodeStack = new LinkedList<PrefetchProcessorNode>(); // 'seen' is used to avoid re-processing objects already processed in a // given prefetch query (see CAY-1695 for why this is bad). It is // essentially a map of all objects fetched in a given transaction // TODO: there are other places that are attempting to track objects in // a tx... can we reuse 'seen' map from here? this.seen = new HashMap<>(); this.root = null; tree.traverse(this); if (root == null) { throw new CayenneRuntimeException("Failed to create prefetch processing tree."); } return root; }
public void encodeAsXML(XMLEncoder encoder) { traverse(new XMLEncoderOperation(encoder)); }
/** * Routes query prefetches, but not the query itself. */ void route(SelectQuery query, QueryRouter router, EntityResolver resolver) { if (!query.isFetchingDataRows() && query.getPrefetchTree() != null) { this.query = query; this.router = router; this.resolver = resolver; this.classDescriptor = query.getMetaData(resolver).getClassDescriptor(); query.getPrefetchTree().traverse(this); } }
/** * Traverses the tree depth-first, invoking callback methods of the processor when * passing through the nodes. */ public void traverse(PrefetchProcessor processor) { boolean result = false; if (isPhantom()) { result = processor.startPhantomPrefetch(this); } else if (isDisjointPrefetch()) { result = processor.startDisjointPrefetch(this); } else if (isJointPrefetch()) { result = processor.startJointPrefetch(this); } else { result = processor.startUnknownPrefetch(this); } // process children unless processing is blocked... if (result && children != null) { Iterator it = children.iterator(); while (it.hasNext()) { ((PrefetchTreeNode) it.next()).traverse(processor); } } // call finish regardless of whether children were processed processor.finishPrefetch(this); }
/** * Routes query prefetches, but not the query itself. */ void route(SelectQuery query, QueryRouter router, EntityResolver resolver) { if (!query.isFetchingDataRows() && query.getPrefetchTree() != null) { this.query = query; this.router = router; this.resolver = resolver; this.entity = query.getMetaData(resolver).getObjEntity(); this.inheritanceTree = resolver.lookupInheritanceTree(entity); query.getPrefetchTree().traverse(this); } }
query.getPrefetchTree().traverse(new ToCacheKeyPrefetchProcessor(key));
rootPrefetch.traverse(new PrefetchProcessor() {
/** * Traverses the tree depth-first, invoking callback methods of the * processor when passing through the nodes. */ public void traverse(PrefetchProcessor processor) { boolean result = false; if (isPhantom()) { result = processor.startPhantomPrefetch(this); } else if (isDisjointPrefetch()) { result = processor.startDisjointPrefetch(this); } else if (isDisjointByIdPrefetch()) { result = processor.startDisjointByIdPrefetch(this); } else if (isJointPrefetch()) { result = processor.startJointPrefetch(this); } else { result = processor.startUnknownPrefetch(this); } // process children unless processing is blocked... if (result && children != null) { for (PrefetchTreeNode child : children) { child.traverse(processor); } } // call finish regardless of whether children were processed processor.finishPrefetch(this); }