Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 158:89ed172137ab
fj Index fix?
author | one |
---|---|
date | Sun, 07 Dec 2014 19:01:08 +0900 |
parents | b8cef4b640a3 |
children | 6b4aab79910d |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/Index.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java |
diffstat | 2 files changed, 16 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/Index.java Wed Nov 26 06:23:07 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/Index.java Sun Dec 07 19:01:08 2014 +0900 @@ -22,9 +22,6 @@ this.indexList = indexList; } - public Index(Index indexList) { - this.indexList = indexList.getIndex(); - } public Index set(String key, String value, TreeNode node) { Option<TreeMap<String, List<TreeNode>>> indexOp = indexList.get(key); @@ -33,10 +30,8 @@ List<TreeNode> nodeList = List.nil(); List<TreeNode> newNodeList = nodeList.cons(node); TreeMap<String, List<TreeNode>> newIndex = index.set(value, newNodeList); - TreeMap<String, TreeMap<String, List<TreeNode>>> newIndexList = indexList.set(key, newIndex); - - - return new Index(newIndexList); + indexList = indexList.set(key, newIndex); + return this; } TreeMap<String, List<TreeNode>> index = indexOp.some(); @@ -51,9 +46,9 @@ newNodeList = nodeList.cons(node); } TreeMap<String, List<TreeNode>> newIndex = index.set(value, newNodeList); - TreeMap<String, TreeMap<String, List<TreeNode>>> newIndexList = indexList.set(key, newIndex); + indexList = indexList.set(key, newIndex); - return new Index(newIndexList); + return this; } @@ -104,7 +99,7 @@ if (indexOp.isNone()) return null; - TreeMap<String, List<TreeNode>> index = indexOp.some(); + final TreeMap<String, List<TreeNode>> index = indexOp.some(); if (!index.isEmpty()) return new NulIterator<TreeNode>(); @@ -142,7 +137,7 @@ } - private TreeMap<String, TreeMap<String, List<TreeNode>>> getIndex() { + public TreeMap<String, TreeMap<String, List<TreeNode>>> getIndex() { return indexList; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Wed Nov 26 06:23:07 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Sun Dec 07 19:01:08 2014 +0900 @@ -11,7 +11,7 @@ public class ParentIndex { - private final TreeMap<TreeNode, TreeNode> parentIndex; + private TreeMap<TreeNode, TreeNode> parentIndex; public ParentIndex() { parentIndex = TreeMap.empty(TreeMapOrd.treeNodeOrd); @@ -24,6 +24,7 @@ public boolean isEmpty(){ return parentIndex.isEmpty(); } + public ParentIndex(ParentIndex parentIndex) { this.parentIndex = parentIndex.getParentIndex(); } @@ -41,39 +42,36 @@ public ParentIndex set(TreeNode parent) { Iterator<TreeNode> childrenIterator = parent.getChildren().iterator(); - TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex; for (; childrenIterator.hasNext();) { TreeNode child = childrenIterator.next(); - newParentIndex = newParentIndex.set(child, parent); + parentIndex = parentIndex.set(child, parent); } - return new ParentIndex(newParentIndex); + return this; } public ParentIndex delete(TreeNode child) { - TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex.delete(child); - return new ParentIndex(newParentIndex); + parentIndex = parentIndex.delete(child); + return this; } public ParentIndex deleteAllChildren(TreeNode parentNode) { TreeNodeChildren children = parentNode.getChildren(); Iterator<TreeNode> childrenIterator = children.iterator(); - TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex; for (; childrenIterator.hasNext();) { TreeNode child = childrenIterator.next(); - newParentIndex = newParentIndex.delete(child); + parentIndex = parentIndex.delete(child); } - return new ParentIndex(newParentIndex); + return this; } public ParentIndex addAllChildren(TreeNode parentNode) { TreeNodeChildren children = parentNode.getChildren(); Iterator<TreeNode> childrenIterator = children.iterator(); - TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex; for (; childrenIterator.hasNext();) { TreeNode child = childrenIterator.next(); - newParentIndex = newParentIndex.set(child, parentNode); + parentIndex = parentIndex.set(child, parentNode); } - return new ParentIndex(newParentIndex); + return this; } }