Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 184:d2b710337eaa
change TreeMap
author | tatsuki |
---|---|
date | Sun, 29 Mar 2015 23:29:27 +0900 |
parents | 066d9c5758dc |
children | 6d125ba315d8 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTree.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeContext.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findTreeAttributeThread.java |
diffstat | 7 files changed, 38 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Sun Mar 29 23:29:27 2015 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle; import fj.data.List; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTree.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/JungleTree.java Sun Mar 29 23:29:27 2015 +0900 @@ -2,7 +2,7 @@ import fj.data.List; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; 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.traverser.InterfaceTraverser;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeContext.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeContext.java Sun Mar 29 23:29:27 2015 +0900 @@ -2,7 +2,7 @@ import fj.data.List; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java Sun Mar 29 23:29:27 2015 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; import fj.data.List; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Sun Mar 29 23:29:27 2015 +0900 @@ -1,14 +1,12 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser; import java.util.Iterator; +import java.util.Optional; import fj.Ord; -import fj.P2; import fj.data.List; -import fj.data.Option; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NulIterator; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.PathNodeIterator; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.Query; @@ -24,7 +22,7 @@ boolean useIndex; public InterfaceTraverser(TreeNode root, boolean indexFlag) { - this(root, TreeMap.empty(Ord.stringOrd), new ParentIndex(), indexFlag); + this(root, new TreeMap<>(), new ParentIndex(), indexFlag); } public InterfaceTraverser(TreeNode root, TreeMap<String, TreeMap<String, List<TreeNode>>> index, @@ -309,14 +307,14 @@ // } public Iterator<TreeNode> get(String key, String value) { - - TreeMap<String, List<TreeNode>> index = indexList.getLoop(key); - if (index == null) + Optional<TreeMap<String, List<TreeNode>>> indexOp = indexList.getLoop(key); + if (!indexOp.isPresent()) return null; - List<TreeNode> nodeList = index.getLoop(value); - if (nodeList == null) + Optional<List<TreeNode>> nodeListOp = indexOp.get().getLoop(value); + if (!nodeListOp.isPresent()) return new NulIterator<TreeNode>(); - return nodeList.iterator(); + + return nodeListOp.get().iterator(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Sun Mar 29 23:29:27 2015 +0900 @@ -1,14 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index; +import java.util.Optional; import java.util.Stack; import fj.Ord; import fj.data.List; -import fj.data.Option; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeChildren; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.TreeMapOrd; public class IndexCreater { @@ -19,7 +18,7 @@ private Stack<TreeNode> nodeStack = new Stack<TreeNode>(); private Stack<Integer> searchStack = new Stack<Integer>(); ParentIndex parentIndex = new ParentIndex(); - TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = TreeMap.empty(Ord.stringOrd); + TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = new TreeMap(); public IndexCreater(TreeNode rootNode) { this.root = rootNode; @@ -77,28 +76,33 @@ } public TreeMap<String, TreeMap<String, List<TreeNode>>> set(String key, String value, TreeNode node) { - - TreeMap<String, List<TreeNode>> index = indexList.getLoop(key); - if (index == null) { - index = TreeMap.empty(Ord.stringOrd); + if (key == null ) + System.out.println(""); + Optional<TreeMap<String, List<TreeNode>>> indexOp = indexList.getLoop(key); + if (!indexOp.isPresent()) { + TreeMap<String, List<TreeNode>> index = new TreeMap(); List<TreeNode> nodeList = List.nil(); nodeList = nodeList.cons(node); - TreeMap<String, List<TreeNode>> newIndex = index.set(value, nodeList); - indexList = indexList.set(key, newIndex); + TreeMap<String, List<TreeNode>> newIndex = index.put(value, nodeList); + indexList = indexList.put(key, newIndex); return indexList; } - List<TreeNode> nodeList = index.getLoop(value); + TreeMap<String, List<TreeNode>> index = indexOp.get(); + Optional<List<TreeNode>> nodeListOp = index.getLoop(value); List<TreeNode> newNodeList; - if (nodeList != null) { - newNodeList = nodeList.cons(node); + + if (nodeListOp.isPresent()) { + newNodeList = nodeListOp.get().cons(node); + } else { - nodeList = List.nil(); + List<TreeNode> nodeList = List.nil(); newNodeList = nodeList.cons(node); + } - TreeMap<String, List<TreeNode>> newIndex = index.set(value, newNodeList); - indexList = indexList.set(key, newIndex); + TreeMap<String, List<TreeNode>> newIndex = index.put(value, newNodeList); + indexList = indexList.put(key, newIndex); return indexList; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findTreeAttributeThread.java Mon Mar 23 15:44:28 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findTreeAttributeThread.java Sun Mar 29 23:29:27 2015 +0900 @@ -19,7 +19,7 @@ public findTreeAttributeThread(JungleTree tree) { this.tree = tree; - // this.traverser = tree.getTraverser(true); + // this.traverser = tree.getTraverser(true); this.findCount = 0; } @@ -37,12 +37,11 @@ public void run() { while (loop) { InterfaceTraverser traverser = tree.getTraverser(false); - // Iterator<TreeNode> it = traverser.find((TreeNode node) -> {return true;}, "key", "0"); + Iterator<TreeNode> it = traverser.find(null, "key", "0"); - // if (it.hasNext()) { - findCount++; - // } else - // System.out.println("faild"); + if (it.hasNext()) { + findCount++; + } } } }