Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 196:7480d8aa466f
remove fj TreeMap for jungle
author | tatsuki |
---|---|
date | Wed, 06 May 2015 06:30:19 +0900 |
parents | c42e26557279 |
children | 6145866b2ebc |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNodeAttributes.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIndexIterator.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.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/store/index/ParentIndex.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findMongoAttributeThread.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/clonable/DefaultTreeNodeAttributesTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingAttributesTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingChildrenTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingNodeTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultChildrenTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultNodeTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverse/DefaultTraverserTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/functionaljava/FjListTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/functionaljava/FjTreeMapTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/AddChildrenIndexTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/AttributeIndexTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/DeleteChildrenIndexTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/IndexCommitTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/IndexFormTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/ParentIndexTest.java src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/query/SearchQueryTest.java |
diffstat | 28 files changed, 76 insertions(+), 1293 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Wed May 06 06:30:19 2015 +0900 @@ -1,11 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle; -import java.util.Iterator; -import java.util.concurrent.ConcurrentHashMap; - -import fj.Ord; import fj.data.List; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.NullJournal; @@ -13,7 +8,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; @@ -21,7 +15,9 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; 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.tatsuki.jungle.store.index.ParentIndex; + +import java.util.Iterator; +import java.util.concurrent.ConcurrentHashMap; public class DefaultJungle implements Jungle { private Journal journal;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNodeAttributes.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNodeAttributes.java Wed May 06 06:30:19 2015 +0900 @@ -1,17 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; -import java.nio.ByteBuffer; - -import fj.data.List; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Attributes; 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.tatsuki.TreeMap.TreeMap; + +import java.nio.ByteBuffer; +import java.util.Iterator; public interface TreeNodeAttributes extends Attributes { public Either<Error,TreeNode> delete(String key); public Either<Error,TreeNode> put(String key,ByteBuffer value); public TreeMap<String,ByteBuffer> getAttributesAsRawMap(); - public List<String> getKeys(); + public Iterator<String> getKeys(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Wed May 06 06:30:19 2015 +0900 @@ -1,11 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import java.util.Iterator; -import java.util.concurrent.atomic.AtomicReference; - -import fj.data.List; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext; @@ -17,7 +12,9 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultError; 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.tatsuki.jungle.store.index.ParentIndex; + +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicReference; public class DefaultTransactionManager implements TransactionManager { private final AtomicReference<TreeContext> repository;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Wed May 06 06:30:19 2015 +0900 @@ -1,14 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import java.nio.ByteBuffer; - -import fj.Ord; import fj.data.List; -import fj.data.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.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; + +import java.nio.ByteBuffer; public class DefaultTreeNode implements TreeNode { @@ -17,11 +16,10 @@ private TreeMap<String,ByteBuffer> attrs; private static final List<TreeNode> NIL_LIST = List.nil(); - private static final TreeMap<String,ByteBuffer> NIL_MAP = TreeMap.empty(Ord.stringOrd); - + public DefaultTreeNode() { - this(NIL_LIST,NIL_MAP); + this(NIL_LIST,new TreeMap()); } public DefaultTreeNode(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs) @@ -54,7 +52,7 @@ @Override public Either<Error, TreeNode> appendRootNode() { - TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, NIL_MAP); + TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap()); Either<Error, TreeNode> either = newRootChildren.addExistTreeNodeToChildren(this, 0); return either; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Wed May 06 06:30:19 2015 +0900 @@ -1,16 +1,16 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import java.nio.ByteBuffer; - import fj.data.List; -import fj.data.Option; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; 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.tatsuki.TreeMap.TreeMap; + +import java.nio.ByteBuffer; +import java.util.Iterator; public class DefaultTreeNodeAttribute implements TreeNodeAttributes { public List<TreeNode> children; @@ -33,7 +33,7 @@ return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - if (null != attrs.getLoop(_key)) { + if (null != attrs.get(_key)) { return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } @@ -48,7 +48,7 @@ return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - TreeMap<String, ByteBuffer> newMap = attrs.set(_key, _value); + TreeMap<String, ByteBuffer> newMap = attrs.put(_key, _value); TreeNode newNode = new DefaultTreeNode(children, newMap); return DefaultEither.newB(newNode); } @@ -58,9 +58,7 @@ if (_key == null) { return null; } - - ByteBuffer result = attrs.getLoop(_key); - return result; + return attrs.get(_key).get(); } @Override @@ -72,7 +70,7 @@ } @Override - public List<String> getKeys() { + public Iterator<String> getKeys() { return attrs.keys(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Wed May 06 06:30:19 2015 +0900 @@ -1,17 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; -import java.nio.ByteBuffer; -import java.util.Iterator; - import fj.P2; import fj.data.List; -import fj.data.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.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; 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.tatsuki.TreeMap.TreeMap; + +import java.nio.ByteBuffer; +import java.util.Iterator; public class DefaultTreeNodeChildren implements TreeNodeChildren {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIndexIterator.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query; - -import java.util.Iterator; -import java.util.Stack; - -import fj.data.List; -import fj.data.TreeMap; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; -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.Pair; - -public class PathNodeIndexIterator implements Iterator<Pair<TreeNode, NodePath>> { - - TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index; - NodePath path; - TreeNode root; - TreeNode node; - int childNumber; - private TreeNodeChildren children; - private Stack<TreeNode> nodeStack = new Stack<TreeNode>(); - private Stack<Integer> searchStack = new Stack<Integer>(); - - /* - * get queryIndexCondition from query - * if already index exists, use index - * otherwise traverse tree and create index - * - * */ - public PathNodeIndexIterator(TreeNode root, TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index) { - this.root = root; - this.index = index; - path = new DefaultNodePath(); - node = root; - } - - @Override - public boolean hasNext() { - return node != null; - } - - @Override - public Pair<TreeNode, NodePath> next() { - TreeNode now = node; - NodePath currentPath = path; - if (node.getChildren().size() > 0) { // - nodeStack.push(node); - path = path.add(0); - children = node.getChildren(); - node = children.at(0).b(); - childNumber = 1; - searchStack.push(childNumber); - } else if (node == root) { - node = null; // no more node - children = null; - return new Pair<TreeNode, NodePath>(now, currentPath); - }else if (children != null && children.size() > childNumber) { - childNumber = searchStack.pop(); - node = children.at(childNumber).b(); - path = path.tail().add(childNumber); - searchStack.push(++childNumber); - } else { - path = path.tail(); - node = nodeStack.pop(); - children = node.getChildren(); - childNumber = searchStack.pop(); - for (; children.size() == childNumber;) { - if (node == root) { - node = null; // no more node - children = null; - return new Pair<TreeNode, NodePath>(now, currentPath); - } - path = path.tail(); - node = nodeStack.pop(); - children = node.getChildren(); - childNumber = searchStack.pop(); - } - if (node != null && childNumber < children.size()) { - path = path.add(childNumber); - nodeStack.push(node); - node = children.at(childNumber).b(); - searchStack.push(++childNumber); - } - } - System.out.println("path = " + path.toString()); - return new Pair<TreeNode, NodePath>(now, currentPath); - } - - @Override - public void remove() { - // TODO Auto-generated method stub - - } - - public TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> getIndex() { - return index; - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/PathNodeIterator.java Wed May 06 06:30:19 2015 +0900 @@ -1,11 +1,11 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query; +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 java.util.Iterator; import java.util.Stack; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeChildren; - public class PathNodeIterator implements Iterator<TreeNode> { TreeNode root;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Wed May 06 06:30:19 2015 +0900 @@ -1,13 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index; +import fj.data.List; +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.tatsuki.TreeMap.TreeMap; + +import java.util.Iterator; import java.util.Optional; import java.util.Stack; -import fj.data.List; -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; - public class IndexCreater { TreeNode root; @@ -24,8 +25,9 @@ this.node = rootNode; while (node != null) { TreeNode targetNode = node; - List<String> keys = targetNode.getAttributes().getKeys(); - for (String key : keys) { + Iterator<String> keys = targetNode.getAttributes().getKeys(); + for (;keys.hasNext();) { + String key = keys.next(); String value = targetNode.getAttributes().getString(key); if (value != null) indexList = set(key, value, targetNode);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Wed May 06 06:30:19 2015 +0900 @@ -1,18 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index; -import java.util.Iterator; - 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; -import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; + +import java.util.Iterator; public class ParentIndex { private TreeMap<TreeNode, TreeNode> parentIndex; public ParentIndex() { - parentIndex = TreeMap.empty(TreeMapOrd.treeNodeOrd); + parentIndex = new TreeMap(); } public boolean isEmpty(){ @@ -20,14 +19,11 @@ } public TreeNode get(TreeNode child) { - TreeNode parent = parentIndex.getLoop(child); - if (parent != null) - return parent; - return null; + return parentIndex.get(child).get(); } public ParentIndex set(TreeNode parent ,TreeNode child) { - parentIndex = parentIndex.set(child, parent); + parentIndex = parentIndex.put(child, parent); return this; } @@ -51,7 +47,7 @@ Iterator<TreeNode> childrenIterator = children.iterator(); for (; childrenIterator.hasNext();) { TreeNode child = childrenIterator.next(); - parentIndex = parentIndex.set(child, parentNode); + parentIndex = parentIndex.put(child, parentNode); } return this; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findMongoAttributeThread.java Fri May 01 13:06:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findMongoAttributeThread.java Wed May 06 06:30:19 2015 +0900 @@ -1,13 +1,10 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; -import com.mongodb.BasicDBObject; import com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import org.bson.Document; -import java.util.ArrayList; - /** * Created by e115731 on 15/04/30. */ @@ -33,8 +30,6 @@ @Override public void run() { - ArrayList<BasicDBObject> list = new ArrayList<BasicDBObject>(); - list.add(new BasicDBObject("key","1")); while (loop) { FindIterable<Document> searchResultList = coll.find(new Document("key","1")); MongoCursor<Document> iterator = searchResultList.iterator();
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/clonable/DefaultTreeNodeAttributesTest.java Fri May 01 13:06:16 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/clonable/DefaultTreeNodeAttributesTest.java Wed May 06 06:30:19 2015 +0900 @@ -1,18 +1,17 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.clonable; -import java.nio.ByteBuffer; - -import fj.Ord; import fj.P2; import fj.data.List; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Attributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesTest; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import junit.framework.TestCase; import junit.framework.TestSuite; +import java.nio.ByteBuffer; + public class DefaultTreeNodeAttributesTest extends TestCase { public static TestSuite suite() @@ -26,10 +25,10 @@ public static DefaultTreeNode instance() { List<TreeNode> rawList = List.nil(); - TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); for(P2<String,ByteBuffer> entry : AttributesTest.ENTRIES){ - rawMap = rawMap.set(entry._1(),entry._2()); + rawMap = rawMap.put(entry._1(),entry._2()); } return new DefaultTreeNode(rawList,rawMap);
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingAttributesTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.logging; - -import java.nio.ByteBuffer; - -import fj.Ord; -import fj.P2; -import fj.data.List; -import fj.data.TreeMap; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Attributes; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.nodeeditor.EditableAttributesTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.EditableNodeWrapper; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableAttributes; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class LoggingAttributesTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(AttributeTestImpl.class); - suite.addTestSuite(EditableAttributesTestImpl.class); - return suite; - } - - public static LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance() - { - List<DefaultTreeNode> rawList = List.nil(); - TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); - - for(P2<String, ByteBuffer> entry : AttributesTest.ENTRIES){ - rawMap = rawMap.set(entry._1(),entry._2()); - } - - EditableNodeWrapper<DefaultTreeNode> wrapper = new EditableNodeWrapper<DefaultTreeNode>(new DefaultTreeNode (rawList,rawMap)); - return new LoggingNode<EditableNodeWrapper<DefaultTreeNode>>(wrapper); - } - - public static class AttributeTestImpl extends AttributesTest - { - - @Override - public Attributes instance() - { - return LoggingAttributesTest.instance().getAttributes(); - } - - } - - public static class EditableAttributesTestImpl extends EditableAttributesTest<LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> - { - @Override - public EditableAttributes<LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> instance() - { - return LoggingAttributesTest.instance().getAttributes(); - } - - } -} -*/ \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingChildrenTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.logging; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.nodeeditor.EditableChildrenTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.EditableNodeWrapper; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableChildren; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class LoggingChildrenTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(EditableChildrenTestImpl.class); - return suite; - } - - public static LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance() - { - EditableNodeWrapper<DefaultTreeNode> wrapper = new EditableNodeWrapper<DefaultTreeNode>(new DefaultTreeNode()); - return new LoggingNode<EditableNodeWrapper<DefaultTreeNode>>(wrapper); - } - - public static class EditableChildrenTestImpl extends EditableChildrenTest<LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> - { - @Override - public EditableChildren<LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> instance() - { - return LoggingChildrenTest.instance().getChildren(); - } - } -} -*/ \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/logging/LoggingNodeTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.logging; - -import java.nio.ByteBuffer; -import org.junit.Assert; -import fj.data.List; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainer; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainerTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.ParentTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.EditableNodeWrapper; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class LoggingNodeTest extends TestCase -{ - public void testGetLoggerIsNotNull() - { - LoggingNode<?> instance = instance(); - OperationLog log = instance.getOperationLog(); - Assert.assertNotNull(log); - } - - public void testGetWrappedIsNotNull() - { - LoggingNode<?> instance = instance(); - Object wrap = instance.getWrap(); - Assert.assertNotNull(wrap); - } - - public void testLoggingAddNewChildAt() - { - LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance = instance(); - Either<Error, LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> either = instance.getChildren().addNewChildAt(0); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - - List<Command> expectOps = List.list(Command.APPEND_CHILD); - for(NodeOperation op : instance.getOperationLog()){ - Command actual = op.getCommand(); - Command expect = expectOps.head(); - Assert.assertEquals(expect,actual); - expectOps = expectOps.tail(); - } - - Assert.assertEquals(0,expectOps.length()); - } - - public void testLoggingDeleteChildAt() - { - LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance = instance(); - Either<Error, LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> either = instance.getChildren().addNewChildAt(0); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - either = instance.getChildren().deleteChildAt(0); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - - List<Command> expectOps = List.list(Command.APPEND_CHILD,Command.DELETE_CHILD); - for(NodeOperation op : instance.getOperationLog()){ - Command actual = op.getCommand(); - Command expect = expectOps.head(); - Assert.assertEquals(expect,actual); - expectOps = expectOps.tail(); - } - - Assert.assertEquals(0,expectOps.length()); - } - - public void testPutAttributeTest() - { - String key = "KEY"; - ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance = instance(); - Either<Error, LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> either = instance.getAttributes().put(key,value); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - - List<Command> expectOps = List.list(Command.PUT_ATTRIBUTE); - for(NodeOperation op : instance.getOperationLog()){ - Command actual = op.getCommand(); - Command expect = expectOps.head(); - Assert.assertEquals(expect,actual); - } - - Assert.assertEquals(1,expectOps.length()); - } - - public void testDeleteAttributeTest() - { - String key = "KEY"; - ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance = instance(); - Either<Error, LoggingNode<EditableNodeWrapper<DefaultTreeNode>>> either = instance.getAttributes().put(key,value); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - either = instance.getAttributes().delete(key); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - - List<Command> expectOps = List.list(Command.PUT_ATTRIBUTE,Command.DELETE_ATTRIBUTE); - for(NodeOperation op : instance.getOperationLog()){ - Command actual = op.getCommand(); - Command expect = expectOps.head(); - Assert.assertEquals(expect,actual); - expectOps = expectOps.tail(); - } - - Assert.assertEquals(0,expectOps.length()); - } - - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(ParentTestImpl.class); - suite.addTestSuite(AttributesContainerTestImpl.class); - suite.addTestSuite(LoggingNodeTest.class); - return suite; - } - - public static LoggingNode<EditableNodeWrapper<DefaultTreeNode>> instance() - { - EditableNodeWrapper<DefaultTreeNode> wrapper = new EditableNodeWrapper<DefaultTreeNode>(new DefaultTreeNode()); - return new LoggingNode<EditableNodeWrapper<DefaultTreeNode>>(wrapper); - } - - public static class ParentTestImpl extends ParentTest<LoggingNode<?>> - { - @Override - public LoggingNode<?> instance() - { - return LoggingNodeTest.instance(); - } - } - - public static class AttributesContainerTestImpl extends AttributesContainerTest - { - @Override - public AttributesContainer instance() - { - return LoggingNodeTest.instance(); - } - } -}*/
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java Fri May 01 13:06:16 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java Wed May 06 06:30:19 2015 +0900 @@ -1,30 +1,28 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; -import java.nio.ByteBuffer; - -import org.junit.Assert; - -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.shoshi.jungle.core.AttributesTest; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; +import org.junit.Assert; + +import java.nio.ByteBuffer; +import java.util.Optional; public class DefaultAttributesTest extends AttributesTest { public TreeNodeAttributes instance() { List<TreeNode> rawList = List.nil(); - TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); // add attributes for(P2<String, ByteBuffer> entry : ENTRIES){ - rawMap = rawMap.set(entry._1(),entry._2()); + rawMap = rawMap.put(entry._1(),entry._2()); } TreeNode node = new DefaultTreeNode(rawList,rawMap); @@ -44,12 +42,12 @@ String key = entry._1(); ByteBuffer value = entry._2(); - Option<ByteBuffer> option = rawMap.get(key); - if(option.isNone()){ + Optional<ByteBuffer> option = rawMap.get(key); + if(!option.isPresent()){ Assert.fail(); } - ByteBuffer actual = option.some(); + ByteBuffer actual = option.get(); Assert.assertEquals(0,actual.compareTo(value)); } }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultChildrenTest.java Fri May 01 13:06:16 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultChildrenTest.java Wed May 06 06:30:19 2015 +0900 @@ -1,16 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; -import java.nio.ByteBuffer; - -import org.junit.Assert; - -import fj.Ord; import fj.data.List; -import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.ChildrenTest; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNodeChildren; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; +import org.junit.Assert; + +import java.nio.ByteBuffer; public class DefaultChildrenTest extends ChildrenTest<TreeNode> { @@ -23,7 +21,7 @@ rawList = rawList.cons(new DefaultTreeNode()); } - TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); return new DefaultTreeNode(rawList,rawMap).getChildren(); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultNodeTest.java Fri May 01 13:06:16 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultNodeTest.java Wed May 06 06:30:19 2015 +0900 @@ -1,15 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.impl.node; +import fj.data.List; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; +import junit.framework.TestCase; +import junit.framework.TestSuite; + import java.nio.ByteBuffer; -import fj.Ord; -import fj.data.List; -import fj.data.TreeMap; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -import junit.framework.TestCase; -import junit.framework.TestSuite; - public class DefaultNodeTest extends TestCase { public DefaultNodeTest(String _name) @@ -28,7 +27,7 @@ public static DefaultTreeNode instance() { List<TreeNode> rawList = List.nil(); - TreeMap<String,ByteBuffer> rawMap = TreeMap.empty(Ord.stringOrd); + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); DefaultTreeNode node = new DefaultTreeNode(rawList,rawMap); return node;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverse/DefaultTraverserTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverse; - - -import fj.Ord; -import fj.data.List; -import fj.data.TreeMap; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultJungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.Traverser; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class DefaultTraverserTest extends TestCase -{ - public static TestSuite suite() - { - TestSuite suite = new TestSuite(); - suite.addTestSuite(TraverserTestImpl.class); - suite.addTestSuite(BruteForceTraverserTestImpl.class); - return suite; - } - - - public static class TraverserTestImpl extends TraverserTest - { - - @Override - public Traverser instance() - { - return new DefaultTraverser(); - } - - } - - public static class BruteForceTraverserTestImpl extends BruteForceTraverserTest - { - - @Override - public InterfaceTraverser instance(TreeNode root) - { - TreeMap<String,TreeMap<String, List<TreeNode>>> index = TreeMap.empty(Ord.stringOrd); - DefaultTraverser traverser = new DefaultTraverser(); - DefaultTreeEditor treeEditor = new DefaultTreeEditor(traverser); - JungleTreeEditor editor = new DefaultJungleTreeEditor(root,null,treeEditor,null); - return new InterfaceTraverser(root,index,editor); - } - - } -}*/
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/functionaljava/FjListTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.tatsuki.functionaljava; - -import java.nio.ByteBuffer; - -import fj.F; -import fj.data.List; - -public class FjListTest { - - static public void main(String args[]){ - - List<String> list = List.nil(); - list = list.cons("wei"); - String aaa = list.head(); - boolean t1 = list.isEmpty(); - list = list.tail(); - boolean t2 = list.isEmpty(); - System.out.println(aaa); - } -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/functionaljava/FjTreeMapTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.tatsuki.functionaljava; - - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; - -import org.junit.Assert; -import org.junit.Test; - - -import fj.F; -import fj.Ord; -import fj.P; -import fj.P1; -import fj.data.List; -import fj.data.Option; -import fj.data.TreeMap; - -public class FjTreeMapTest<A> { - - F<TreeNode, P1<String>> toP3 = new F<TreeNode, P1<String>> () { - - @Override - public P1<String> f(TreeNode node) { - return P.p(node.toString()); - } - - }; - - - @Test - public void testTreeMap() { - - Ord<P1<String>> aaa = Ord.p1Ord(Ord.stringOrd); - Ord<TreeNode> test = aaa.comap(toP3); - TreeMap<TreeNode, TreeNode> treeMap = TreeMap.empty(test); - TreeNode node1 = new DefaultTreeNode(); - TreeNode node2 = new DefaultTreeNode(); - treeMap = treeMap.set(node1,node2); - treeMap = treeMap.delete(node2); - System.out.println(node1.toString()); - System.out.println(node2.toString()); - System.out.println(node1.toString()); - System.out.println(node2.toString()); - Option<TreeNode> nodee = treeMap.get(node1); - TreeNode node = nodee.some(); - System.out.println(node.toString()); - List<Integer> list = List.nil(); - list = list.cons(1).cons(2).cons(3); - System.out.println(list.toString()); - list.length(); - TreeMap<String, String> map = TreeMap.empty(Ord.stringOrd); - TreeMap<String, String> newMap = map.set("name", "tatsuki"); - Option<String> op = newMap.get("name"); - if (op.isNone()) { - - } - String str = op.some(); - - TreeMap<String, String> newMap2 = map.set("name", "kanagawa"); - String str2 = newMap2.get("name").some(); - Assert.assertEquals(str, "tatsuki"); - Assert.assertEquals(str2, "kanagawa"); - } - -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/AddChildrenIndexTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; -// -//import java.nio.ByteBuffer; -//import java.util.Iterator; -// -//import org.junit.Test; -//import org.junit.experimental.theories.suppliers.TestedOn; -// -//import fj.data.List; -//import fj.data.Option; -//import fj.data.TreeMap; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//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.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.IndexTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; -//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.store.index.Index; -//import junit.framework.Assert; -// -//public class AddChildrenIndexTest { -// -// @Test -// public void DeleteChildrenTest() { -// Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTreeEditor(new DefaultTraverser())); -// jungle.createNewTree("tree"); -// JungleTree tree = jungle.getTreeByName("tree"); -// createTree(tree); -// tree.getRootNode(); -// InterfaceTraverser ifTraverser = tree.getTraverser(true); -// -// Iterator<TreeNode> pairIterator = ifTraverser.find((TreeNode node) -> { -// ByteBuffer attribute = node.getAttributes().get(key); -// if (attribute != null) { -// byte[] byteAttribute = attribute.array(); -// String str = new String(byteAttribute); -// System.out.println("attribute = " + str); -// return str.equals("<-1,0,1>"); -// } -// return false; -// }, key, "<-1,0,1>"); -// -// for (; pairIterator.hasNext(); pairIterator.next()) { -// -// } -// ifTraverser.commit(); -// -// JungleTreeEditor editor = tree.getTreeEditor(); -// Either<Error, JungleTreeEditor> either = editor.addNewChildAt(new DefaultNodePath().add(0), 0); -// either.b().success(); -// -// InterfaceTraverser newIfTraverser = tree.getTraverser(true); -// Index newIndex = newIfTraverser.getIndex(); -// Assert.assertEquals(newIndex.get(key,"<-1,0,1>").head().toString(), "<-1,0,2>"); -// -// } -// -// public static String key = "KEY"; -// public static DefaultTreeNode factory = new DefaultTreeNode(); -// -// public void createTree(JungleTree tree) { -// NodePath root = new DefaultNodePath(); -// createChildren(tree, root, 0); -// -// for (int x = 0; x < 3; x++) { -// createChildren(tree, root.add(0), x); -// for (int y = 0; y < 3; y++) { -// createChildren(tree, root.add(0).add(x), y); -// } -// } -// -// } -// -// public void createChildren(JungleTree tree, NodePath root, int num) { -// JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 -// Either<Error, JungleTreeEditor> either = editor.addNewChildAt(root, num); // 新しく入れるところへのパス -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// if (either.isA()) { -// Assert.fail(); -// } -// NodePath childPath = root.add(num); -// editor = tree.getTreeEditor(); -// NodePath attribute = root.add(num); -// System.out.println(attribute.toString()); -// either = editor.putAttribute(childPath, key, ByteBuffer.wrap(attribute.toString().getBytes())); -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/AttributeIndexTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; -// -// -// -//import java.nio.ByteBuffer; -// -//import org.junit.Test; -// -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//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.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.IndexJungleTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -//import junit.framework.Assert; -//import fj.data.List; -//import fj.data.Option; -//import fj.data.TreeMap; -// -//public class AttributeIndexTest { -// -// @Test -// public void PutAttributeIndexTest(){ -// DefaultJungle jungle = new DefaultJungle(null,"hoge",new DefaultTraverser()); -// JungleTree tree = jungle.createNewTree("fuga"); -// IndexJungleTreeEditor editor = tree.getIndexTreeEditor(); -// TreeMap<String, TreeMap<String, List<TreeNode>>> emptyIndex = editor.getIndex(); -// Assert.assertTrue(emptyIndex.isEmpty()); -// NodePath path = new DefaultNodePath(); -// Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, 0); -// Assert.assertFalse(either.isA()); -// -// JungleTreeEditor editor2 = either.b(); -// Either<Error, JungleTreeEditor> either2 = editor2.putAttribute(path.add(0),"key", ByteBuffer.wrap("test".toString().getBytes())); -// Assert.assertFalse(either2.isA()); -// JungleTreeEditor editor3 = either2.b(); -// editor3 = editor3.success().b(); -// -// editor3.putAttribute(path.add(0),"key", ByteBuffer.wrap("tatsuki".toString().getBytes())).b().success().b(); -// TreeNode targetNode = tree.getRootNode().getChildren().at(0).b(); -// IndexJungleTreeEditor IndexEditor = tree.getIndexTreeEditor(); -// TreeMap<String, TreeMap<String, List<TreeNode>>> index = IndexEditor.getIndex(); -// List<TreeNode> NodeList = index.get("key").some().get("tatsuki").some(); -// String attributeIndex = NodeList.head().getAttributes().getString("key"); -// Assert.assertEquals(attributeIndex,"tatsuki"); -// Assert.assertEquals(NodeList.head(),targetNode); -// -// JungleTreeEditor editor4 = tree.getIndexTreeEditor(); -// Either<Error, JungleTreeEditor> either3 = editor4.deleteAttribute(path.add(0), "key").b().success(); -// Assert.assertFalse(either3.isA()); -// JungleTreeEditor editor5 = either3.b(); -// editor5.success(); -// -// IndexJungleTreeEditor IndexEditor2 = tree.getIndexTreeEditor(); -// TreeMap<String, TreeMap<String, List<TreeNode>>> deleteIndexList = IndexEditor2.getIndex(); -// Option<TreeMap<String, List<TreeNode>>> deleteIndexOp = deleteIndexList.get("key"); -// TreeMap<String, List<TreeNode>> deleteIndex = deleteIndexOp.some(); -// Assert.assertTrue(deleteIndex.get("test").some().isEmpty()); -// Assert.assertTrue(deleteIndex.get("tatsuki").some().isEmpty()); -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/DeleteChildrenIndexTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; -// -//import java.nio.ByteBuffer; -//import java.util.Iterator; -// -//import org.junit.Test; -//import org.junit.experimental.theories.suppliers.TestedOn; -// -//import fj.data.List; -//import fj.data.Option; -//import fj.data.TreeMap; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//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.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.IndexTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.IndexJungleTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; -//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 junit.framework.Assert; -// -//public class DeleteChildrenIndexTest { -// -// @Test -// public void DeleteChildrenTest(){ -// Jungle jungle = new DefaultJungle(null, "hogehoge",new DefaultTraverser()); -// jungle.createNewTree("tree"); -// JungleTree tree = jungle.getTreeByName("tree"); -// createTree(tree); -// tree.getRootNode(); -// InterfaceTraverser ifTraverser = tree.getTraverser(); -// -// Iterator<Pair<TreeNode, NodePath>> pairIterator = ifTraverser.find((TreeNode node) -> { -// ByteBuffer attribute = node.getAttributes().get(key); -// if (attribute != null) { -// byte[] byteAttribute = attribute.array(); -// String str = new String(byteAttribute); -// System.out.println("attribute = " + str); -// return str.equals("<-1,0,1>"); -// } -// return false; -// }, key, "<-1,0,1>"); -// -// for (;pairIterator.hasNext();pairIterator.next()) { -// -// } -// //check index -// ifTraverser.commitIndex(); -// TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index = ifTraverser.getIndex(); -// Assert.assertTrue(index.get(key).some().get("<-1,0,0>").isSome()); -// -// IndexJungleTreeEditor editor = tree.getIndexTreeEditor(); -// Either<Error, JungleTreeEditor> either = editor.deleteChildAt(new DefaultNodePath().add(0), 0); -// either.b().success(); -// -// InterfaceTraverser newIfTraverser = tree.getTraverser(); -// TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> newIndex = newIfTraverser.getIndex(); -// Assert.assertEquals(newIndex.get(key).some().get("<-1,0,1>").some().head().right().toString(),"<-1,0,0>"); -// -// } -// public static String key = "KEY"; -// public static DefaultTreeNode factory = new DefaultTreeNode(); -// -// public void createTree(JungleTree tree) { -// NodePath root = new DefaultNodePath(); -// createChildren(tree, root, 0); -// -// for (int x = 0; x < 3; x++) { -// createChildren(tree, root.add(0), x); -// for (int y = 0; y < 3; y++) { -// createChildren(tree, root.add(0).add(x), y); -// } -// } -// -// } -// -// public void createChildren(JungleTree tree, NodePath root, int num) { -// JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 -// Either<Error, JungleTreeEditor> either = editor -// .addNewChildAt(root, num); // 新しく入れるところへのパス -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// if (either.isA()) { -// Assert.fail(); -// } -// NodePath childPath = root.add(num); -// editor = tree.getTreeEditor(); -// NodePath attribute = root.add(num); -// System.out.println(attribute.toString()); -// either = editor.putAttribute(childPath, key, -// ByteBuffer.wrap(attribute.toString().getBytes())); -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/IndexCommitTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; -// -//import java.util.Iterator; -// -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//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.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.IndexTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; -//import junit.framework.Assert; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -//import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Index; -// -//import java.nio.ByteBuffer; -// -//import org.junit.Test; -// -//import fj.data.List; -//import fj.data.Option; -//import fj.data.TreeMap; -// -//public class IndexCommitTest { -// -// @Test -// public void IndexCommitTest() throws InterruptedException { -// -// Jungle jungle = new DefaultJungle(null, "hogehoge",new DefaultTreeEditor(new DefaultTraverser())); -// jungle.createNewTree("tree"); -// JungleTree tree = jungle.getTreeByName("tree"); -// createTree(tree); -// tree.getRootNode(); -// InterfaceTraverser ifTraverser = tree.getTraverser(); -// -// ifTraverser.find((TreeNode node) -> { -// ByteBuffer attribute = node.getAttributes().get(key); -// if (attribute != null) { -// byte[] byteAttribute = attribute.array(); -// String str = new String(byteAttribute); -// System.out.println("attribute = " + str); -// return str.equals("<-1,0,1>"); -// } -// return false; -// }, key, "<-1,0,1>"); -// -// //check index -// Index index = ifTraverser.getIndex(); -// index.get(key,"<-1,0,1>"); -// ifTraverser.commit(); -// -// JungleTree newTree = jungle.getTreeByName("tree"); -// InterfaceTraverser newIfTraverser = newTree.getTraverser(); -// Index newIndex = newIfTraverser.getIndex(); -// newIndex.get(key,"<-1,0,1>"); -// JungleTreeEditor editor = tree.getTreeEditor(); -// Either<Error, JungleTreeEditor> either = editor.addNewChildAt(new DefaultNodePath(), 0); -// editor = either.b(); -// editor.success(); -// -// ifTraverser.commit(); -//// Assert.assertTrue(newIndex.isEmpty()); -//// -//// InterfaceTraverser ifTraverser1= tree.getTraverser(); -//// -//// ifTraverser1.find((TreeNode node) -> { -//// ByteBuffer attribute = node.getAttributes().get(key); -//// if (attribute != null) { -//// byte[] byteAttribute = attribute.array(); -//// String str = new String(byteAttribute); -//// System.out.println("attribute = " + str); -//// return str.equals("<-1,0,1>"); -//// } -//// return false; -//// }, key, "<-1,0,1>"); -//// -//// ifTraverser1.commit(); -//// JungleTree newTree2 = jungle.getTreeByName("tree"); -//// InterfaceTraverser newIfTraverser2 = newTree2.getTraverser(); -//// TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> newIndex1 = newIfTraverser2.getIndex(); -//// Assert.assertFalse(newIndex1.isEmpty()); -// -// } -// -// public boolean compare(TreeNode compareNode, String compareAttribute) { -// String labName = compareNode.getAttributes().getString(key); -// if (labName.equals(compareAttribute)) -// return true; -// return false; -// } -// -// public static String key = "KEY"; -// public static DefaultTreeNode factory = new DefaultTreeNode(); -// -// public void createTree(JungleTree tree) { -// NodePath root = new DefaultNodePath(); -// createChildren(tree, root, 0); -// -// for (int x = 0; x < 2; x++) { -// createChildren(tree, root.add(0), x); -// for (int y = 0; y < 2; y++) { -// createChildren(tree, root.add(0).add(x), y); -// } -// } -// -// } -// -// public void createChildren(JungleTree tree, NodePath root, int num) { -// JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 -// Either<Error, JungleTreeEditor> either = editor -// .addNewChildAt(root, num); // 新しく入れるところへのパス -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// if (either.isA()) { -// Assert.fail(); -// } -// NodePath childPath = root.add(num); -// editor = tree.getTreeEditor(); -// NodePath attribute = root.add(num); -// System.out.println(attribute.toString()); -// either = editor.putAttribute(childPath, key, -// ByteBuffer.wrap(attribute.toString().getBytes())); -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/IndexFormTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; - -import java.nio.ByteBuffer; - -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -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 org.junit.Assert; -import org.junit.Test; - -import fj.Ord; -import fj.data.List; -import fj.data.Option; -import fj.data.TreeMap; - -public class IndexFormTest { - - TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index = TreeMap - .empty(Ord.stringOrd); - - @Test - public void IndexFormTest() { - - NodePath path = new DefaultNodePath(); - TreeNode node = createTree(3, 0, 3, path); - TreeMap<String, List<Pair<TreeNode, NodePath>>> map = index.get(key).some(); - Option<List<Pair<TreeNode, NodePath>>> opList = map.get("<-1,0,0,2>"); - List<Pair<TreeNode, NodePath>> list = opList.some(); - Pair<TreeNode, NodePath> Pair = list.head(); - NodePath newPath = Pair.right(); - String pathStr = newPath.toString(); - Assert.assertEquals(pathStr,"<-1,0,0,2>"); - System.out.println("aaa"); - } - - public static String key = "KEY"; - public static ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - public static DefaultTreeNode factory = new DefaultTreeNode(); - - public TreeNode createTree(int _curX, int _curY, int _maxHeight, - NodePath _address) { - TreeNode parent = factory.createNewNode(); - Either<Error, TreeNode> either = parent.getAttributes().put(key,ByteBuffer.wrap(_address.toString().getBytes())); - if (either.isA()) { - Assert.fail(); - } - editIndex(parent, _address, _address.toString(), key); - parent = either.b(); - - if (_curY == _maxHeight) { - return parent; - } - - for (int i = 0; i < _curY + 1; i++) { - TreeNode ch = createTree(i, _curY + 1, _maxHeight, _address.add(i)); - either = parent.getChildren().addNewChildAt(i, ch); - if (either.isA()) { - Assert.fail(); - } - - parent = either.b(); - } - - return parent; - } - - - public void editIndex(TreeNode node, NodePath path, String attribute,String key) { - - Pair<TreeNode, NodePath> pair = new Pair<TreeNode, NodePath>(node, path); - Option<TreeMap<String, List<Pair<TreeNode, NodePath>>>> opAttributeList = index.get(key); - - if (opAttributeList.isNone()) { - TreeMap<String, List<Pair<TreeNode, NodePath>>> nodeIndex = TreeMap.empty(Ord.stringOrd); - List<Pair<TreeNode, NodePath>> list = List.nil(); - list = list.cons(pair); - nodeIndex = nodeIndex.set(attribute, list); - index = index.set(key, nodeIndex); - } else { - TreeMap<String, List<Pair<TreeNode, NodePath>>> indexMap = opAttributeList.some(); - Option<List<Pair<TreeNode, NodePath>>> opNodeIndex = indexMap.get(attribute); - - if (opNodeIndex.isNone()) { - List<Pair<TreeNode, NodePath>> pairList = List.nil(); - pairList = pairList.cons(pair); - indexMap = indexMap.set(attribute, pairList); - - } else { - List<Pair<TreeNode, NodePath>> pairList = opNodeIndex.some(); - pairList = pairList.cons(pair); - indexMap = indexMap.set(attribute, pairList); - } - index = index.set(key, indexMap); - } - System.out.println(attribute); - - } - -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/index/ParentIndexTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.index; -// -//import java.nio.ByteBuffer; -//import java.util.Iterator; -// -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex; -//import junit.framework.Assert; -//import org.junit.Test; -//import fj.data.Option; -// -//public class ParentIndexTest { -// -// @Test -// public void testParentIndex() { -// Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTraverser()); -// jungle.createNewTree("tree"); -// JungleTree tree = jungle.getTreeByName("tree"); -// JungleTreeEditor editor = tree.getIndexTreeEditor(); -// DefaultNodePath path = new DefaultNodePath(); -// editor = editor.addNewChildAt(path, 0).b(); -// -// for (int num = 0; num < 5; num++) { -// editor = editor.addNewChildAt(path.add(0), num).b(); -// editor = editor.putAttribute(path.add(0).add(num), "test", ByteBuffer.wrap("test".getBytes())).b(); -// editor = editor.success().b(); -// } -// -// ParentIndex parentIndex = tree.getParentIndex(); -// TreeNode node = tree.getRootNode(); -// for (int num = 0; node.getChildren().size() != 0; num++) { -// Iterator<TreeNode> children = node.getChildren().iterator(); -// for (; children.hasNext();) { -// TreeNode child = children.next(); -// TreeNode parent = parentIndex.get(child).some(); -// Assert.assertEquals(parent, node); -// } -// node = node.getChildren().at(num).b(); -// } -// -// JungleTree oldTree = tree.getOldTree(tree.revision() - 1).b(); -// TreeNode oldRoot = oldTree.getRootNode(); -// TreeNode oldNode = oldRoot.getChildren().at(0).b(); -// Option<TreeNode> oldParentOp = parentIndex.get(oldNode); -// Assert.assertTrue(oldParentOp.isNone()); -// ParentIndex oldTreeParentIndex = oldTree.getParentIndex(); -// oldParentOp = oldTreeParentIndex.get(oldNode); -// Assert.assertTrue(oldParentOp.isSome()); -// -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/query/SearchQueryTest.java Fri May 01 13:06:16 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.tatsuki.query; -// -//import java.nio.ByteBuffer; -//import java.security.KeyStore.Entry.Attribute; -//import java.util.Iterator; -// -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungleTree; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; -//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.DefaultNodePath; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.IndexTreeEditor; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; -//import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; -//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 org.junit.Assert; -//import org.junit.Test; -// -//import fj.data.List; -//import fj.data.Option; -//import fj.data.TreeMap; -// -//public class SearchQueryTest { -// -// @Test -// public void SearchQueryTest() { -// Jungle jungle = new DefaultJungle(null, "hogehoge",new DefaultTraverser()); -// jungle.createNewTree("tree"); -// JungleTree tree = jungle.getTreeByName("tree"); -// createTree(tree); -// tree.getRootNode(); -// InterfaceTraverser ifTraverser = tree.getTraverser(); -// TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> cheackIndex = ifTraverser.getIndex(); -// Assert.assertTrue(cheackIndex.isEmpty()); -// -// Iterator<Pair<TreeNode, NodePath>> searchNode = ifTraverser.find( -// (TreeNode node) -> { -// ByteBuffer attribute = node.getAttributes().get(key); -// if(attribute != null){ -// byte[] byteAttribute = attribute.array(); -// String str = new String(byteAttribute); -// System.out.println("attribute = " + str); -// return str.equals("<-1,0,1>"); -// } -// return false; -// } -// ,key,"<-1,0,1>"); -// -// -// while (searchNode.hasNext()){ -// Assert.assertTrue(compare(searchNode.next().left(),"<-1,0,1>")); -// } -// -// 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()); -// TreeMap<String, List<Pair<TreeNode, NodePath>>> innerIndex = opIndex.some(); -// Assert.assertTrue(!innerIndex.get("<-1,0,0>").isNone()); -// } -// -// -// public boolean compare(TreeNode compareNode, String compareAttribute) { -// String labName = compareNode.getAttributes().getString(key); -// if (labName.equals(compareAttribute)) -// return true; -// return false; -// } -// -// public static String key = "KEY"; -// public static DefaultTreeNode factory = new DefaultTreeNode(); -// -// public void createTree(JungleTree tree) { -// NodePath root = new DefaultNodePath(); -// createChildren(tree, root, 0); -// -// for (int x = 0; x < 2; x++) { -// createChildren(tree, root.add(0), x); -// for (int y = 0; y < 2; y++) { -// createChildren(tree, root.add(0).add(x), y); -// } -// } -// -// } -// -// public void createChildren(JungleTree tree, NodePath root, int num) { -// JungleTreeEditor editor = tree.getTreeEditor();// Treeのeditorを作成 -// Either<Error, JungleTreeEditor> either = editor.addNewChildAt(root,num); // 新しく入れるところへのパス -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// if (either.isA()) { -// Assert.fail(); -// } -// NodePath childPath = root.add(num); -// editor = tree.getTreeEditor(); -// NodePath attribute = root.add(num); -// System.out.println(attribute.toString()); -// either = editor.putAttribute(childPath, key,ByteBuffer.wrap(attribute.toString().getBytes())); -// if (either.isA()) { -// Assert.fail(); -// } -// editor = either.b(); -// either = editor.success(); -// } -//}