Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 125:a0c4a4b8ad10
index test
author | one |
---|---|
date | Wed, 08 Oct 2014 02:47:17 +0900 |
parents | 75ba2f2d6ea3 |
children | f81ec544a155 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/query/SearchQueryTest.java |
diffstat | 2 files changed, 19 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Tue Oct 07 22:45:52 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Wed Oct 08 02:47:17 2014 +0900 @@ -10,20 +10,26 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.PathNodeIndexIterator; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.PathNodeIterator; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.Query; -import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.SearchQuery; -import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.UpdateQuery; public class InterfaceTraverser { InterfaceTraverser traverser; TreeNode node; TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index; + public TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> getIndex() { + return index; + } + + public void setIndex( + TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index) { + this.index = index; + } + + + JungleTreeEditor editor; public InterfaceTraverser(TreeNode _root, JungleTreeEditor editor) { @@ -50,38 +56,7 @@ this.node = root; } - /* - * public IteratorPathNode traverse(TreeNode _node ,NodePath _path ,int - * _pos){ - * - * Children children = _node.getChildren(); Either<Error,TreeNode> either = - * children.at(0); IteratorPathNode list = new IteratorPathNodeImpl(); int - * pathCount = _pos; if(children.size() == 0){ list = list.add(new - * Pair<TreeNode, NodePath>(node, _path.add(_pos))); return list; } - * - * for(TreeNode child : children){ list = - * list.append(traverse(child,_path,pathCount)); pathCount++; } - * - * list = list.add(new Pair<TreeNode,NodePath>(_node, _path.add(_pos))); - * return list; } - * - * public int count(Query _query, String _key, String _attribute){ return - * this.find(_query,_key,_attribute); } - * - * public List<Pair<NodePath,TreeNode>> distinct(String _key ,String... - * _attribute){ return null; } - */ - public JungleTreeEditor update(final Query query) { - /* - * Iterator<Pair<TreeNode, NodePath>> findNode = find(query); //do { for - * (; findNode.hasNext();) { Either<Error, JungleTreeEditor> either = - * editor.putAttribute(findNode.next().right(), "KEY", - * query.getUpdateAttribute()); if (either.isA()) ;// wait delay write - * editor = either.b(); } //} while (editor.success().isA()); - */ - return editor; - } public Iterator<Pair<TreeNode, NodePath>> find(final Query query, String key, String searchValue) {
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/query/SearchQueryTest.java Tue Oct 07 22:45:52 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/query/SearchQueryTest.java Wed Oct 08 02:47:17 2014 +0900 @@ -24,6 +24,10 @@ import org.junit.Assert; import org.junit.Test; +import fj.data.List; +import fj.data.Option; +import fj.data.TreeMap; + public class SearchQueryTest { @Test @@ -69,6 +73,10 @@ Assert.assertTrue(compare(pathNode.left(),"<-1,0,0>")); System.out.println(pathNode.left().getAttributes().getString(key)); } + + TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index = ifTraverser.getIndex(); + Option<TreeMap<String, List<Pair<TreeNode, NodePath>>>> opIndex = index.get(key); + Assert.assertTrue(!opIndex.isNone()); }