-
1. Re: node.getChild() returning inconsistent results
galder.zamarreno Jun 24, 2009 6:55 AM (in response to drcallaway)getChild() takes the fqn of the child, it's a relative method. Root already provides the first /, so the name of the child is without that first /: content/timestamp
If u used Cache rather than Node, you'd do the following using the absolute path:cache.getNode("/content/timestamp");
-
2. Re: node.getChild() returning inconsistent results
drcallaway Jun 24, 2009 10:59 AM (in response to drcallaway)"galder.zamarreno@jboss.com" wrote:
getChild() takes the fqn of the child, it's a relative method. Root already provides the first /, so the name of the child is without that first /: content/timestamp
If u used Cache rather than Node, you'd do the following using the absolute path:cache.getNode("/content/timestamp");
Thanks Galder. That makes sense but I'm having trouble reconciling your comments with this code right out of the JBoss Cache Users' Guide:// Let's get a hold of the root node. Node rootNode = cache.getRoot(); // Remember, JBoss Cache stores data in a tree structure. // All nodes in the tree structure are identified by Fqn objects. Fqn peterGriffinFqn = Fqn.fromString("/griffin/peter"); // Create a new Node Node peterGriffin = rootNode.addChild(peterGriffinFqn);
This code uses an absolute value FQN to retrieve a node directly from the root node (not from cache). Perhaps the Users' Guide is incorrect? -
3. Re: node.getChild() returning inconsistent results
galder.zamarreno Jun 26, 2009 4:10 AM (in response to drcallaway)Hi again, actually, I have to apologise because my previous comment was not entirely correct. getChild() takes only the name of the direct child, so root.getChild("content/timestamp") and root.getChild(Fqn.fromString("content/timestamp")) should be return null as well.
Only, root.getChild(Fqn.fromString("content")) or root.getChild("content") should not be returning null.
What JBoss Cache version are you using?
Wrt addChild(), that format is correct. As mentioned in the javadoc, it will take the fqn of the root and combine it with the one passed to it. It doesn't matter if the fqn is /griffin/peter or griffin/peter, both will work the same way: putting a new node under /griffin/peter. -
4. Re: node.getChild() returning inconsistent results
drcallaway Jun 26, 2009 1:46 PM (in response to drcallaway)"galder.zamarreno@jboss.com" wrote:
What JBoss Cache version are you using?
I'm using version 3.1.0.GA and I seem to be able to retrieve fully qualified nodes from the root node just fine (not just the root node's immediate children). Here is some more sample code from the Users' Guide:Map lotsOfData = generateData(); cache.put("/a/b/c", lotsOfData); cache.getRoot().getChild("/a").setResident(true); cache.getRoot().getChild("/a/b").setResident(true);
This seems to suggest that you can ask the root node for descendents beyond its immediate children. However, I haven't been able to get that to work if I include the beginning slash. Regardless, would I be better off using this:cache.getChild(Fqn.fromString("/a/b"))
Rather than this?cache.getRoot().getChild(Fqn.fromString("a/b"))
-
5. Re: node.getChild() returning inconsistent results
galder.zamarreno Jun 30, 2009 3:24 AM (in response to drcallaway)Hi again, I think I have replicated the issue that you're encountering with the code from the UserGuide. I'm currently investigating it.
With regards to your 2nd questions, Cache has no getChild() method, I suppose you're refering to getNode() instead? If so, this is indentical to calling cache.getRoot().getChild(fqn). There's no difference between them two.