Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 314:de68d37fec80
merge miss fix
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/DefaultInterfaceTraverser.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/DefaultInterfaceTraverser.java Fri Jan 27 00:41:06 2017 +0900 @@ -89,11 +89,6 @@ } @Override - public Iterator<TreeNode> find(String key, String searchValue) { - return index.get(key, searchValue); - } - - @Override public Iterator<TreeNode> find(final Query query, final String key, String searchValue) { Iterator<TreeNode> nodeIterator;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/DifferentialInterfaceTraverser.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/DifferentialInterfaceTraverser.java Fri Jan 27 00:41:06 2017 +0900 @@ -89,11 +89,6 @@ } @Override - public Iterator<TreeNode> find(String key, String searchValue) { - return index.get(key, searchValue); - } - - @Override public Iterator<TreeNode> find(final Query query, final String key, String searchValue) { Iterator<TreeNode> nodeIterator; @@ -101,7 +96,7 @@ nodeIterator = index.get(key, searchValue); ; } else { - nodeIterator = new JungleDifferentialTreeNodeIterator(root, endNode); + nodeIterator = new JungleDifferentialTreeNodeIterator(root,endNode); } TreeNode firstMatchNode = null;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/InterfaceTraverser.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/InterfaceTraverser.java Fri Jan 27 00:41:06 2017 +0900 @@ -24,7 +24,5 @@ Iterator<TreeNode> find(Query query); - Iterator<TreeNode> find(String key, String searchValue); - Iterator<TreeNode> find(Query query, String key, String searchValue); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/RedBlackTreeInterfaceTraverser.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/RedBlackTreeInterfaceTraverser.java Fri Jan 27 00:41:06 2017 +0900 @@ -86,13 +86,8 @@ } @Override - public Iterator<TreeNode> find(String key, String searchValue) { - return new RedBlackTreeNodeIterator(root, key, searchValue); - } - - @Override public Iterator<TreeNode> find(Query query, String key, String searchValue) { - Iterator<TreeNode> nodeIterator = new RedBlackTreeNodeIterator(root, key, searchValue); + Iterator<TreeNode> nodeIterator = new RedBlackTreeNodeIterator(root,key,searchValue); TreeNode firstMatchNode = null; for (; nodeIterator.hasNext(); ) { firstMatchNode = nextmatch(nodeIterator.next(), query);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/nodeiterator/DefaultNodeIterator.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/nodeiterator/DefaultNodeIterator.java Fri Jan 27 00:41:06 2017 +0900 @@ -8,9 +8,9 @@ public class DefaultNodeIterator implements Iterator<TreeNode> { - private TreeNode root; - private TreeNode node; - private int childNumber; + TreeNode root; + TreeNode node; + int childNumber; private TreeNodeChildren children; private Stack<TreeNode> nodeStack = new Stack<>(); private Stack<Integer> searchStack = new Stack<>();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/nodeiterator/JungleDifferentialTreeNodeIterator.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/query/traverser/nodeiterator/JungleDifferentialTreeNodeIterator.java Fri Jan 27 00:41:06 2017 +0900 @@ -6,7 +6,9 @@ import java.util.Iterator; import java.util.Stack; - +/** + * Created by e115731 on 2017/01/07. + */ public class JungleDifferentialTreeNodeIterator implements Iterator<TreeNode> { private TreeNode root;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingChildren.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingChildren.java Fri Jan 27 00:41:06 2017 +0900 @@ -2,7 +2,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.core.Children; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.*; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither; @@ -54,8 +53,8 @@ } - public Either<Error, LoggingNode> redBlackTreeDeleteChildAt(int pos, NodePath path) { - NodeOperation deleteChildAt = new RedBlackTreeDeleteChildAtOperation(pos, path); + public Either<Error, LoggingNode> redBlackTreeDeleteChildAt(String key, ByteBuffer value) { + NodeOperation deleteChildAt = new RedBlackTreeDeleteChildAtOperation(key, value); return edit(deleteChildAt); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/TreeOperationLog.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/TreeOperationLog.java Fri Jan 27 00:41:06 2017 +0900 @@ -6,7 +6,7 @@ public interface TreeOperationLog extends Iterable<TreeOperation> { - public TreeOperationLog add(NodePath _p, NodeOperation _op); + public TreeOperationLog add(NodePath _p,NodeOperation _op); public TreeOperationLog append(TreeOperationLog _log); public int length(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/NodePath.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/NodePath.java Fri Jan 27 00:41:06 2017 +0900 @@ -2,12 +2,8 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; -<<<<<<< local import java.nio.ByteBuffer; -======= ->>>>>>> other -<<<<<<< local public interface NodePath extends Iterable<Integer> { public int get(int index); @@ -16,27 +12,9 @@ public NodePath tail(); public int size(); public Pair<Integer,NodePath> last(); -======= -public interface NodePath extends Iterable<Integer> { - public int get(int index); - - public NodePath add(int pos); - - public Pair<Integer, NodePath> pop(); - - public NodePath tail(); - - public int size(); - - public Pair<Integer, NodePath> last(); - ->>>>>>> other public NodePath addHead(int pos); -<<<<<<< local public String getKey(); public ByteBuffer getValue(); public PathType getPathType(); public NodePath setType(PathType type); } -======= -}>>>>>>> other
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DefaultTreeOperation.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DefaultTreeOperation.java Fri Jan 27 00:41:06 2017 +0900 @@ -7,7 +7,7 @@ private final NodePath path; private final NodeOperation operation; - public DefaultTreeOperation(NodePath _path, NodeOperation _operation) + public DefaultTreeOperation(NodePath _path,NodeOperation _operation) { path = _path; operation = _operation;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/RedBlackTreeDeleteChildAtOperation.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/RedBlackTreeDeleteChildAtOperation.java Fri Jan 27 00:41:06 2017 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.jungle.store.operations; import jp.ac.u_ryukyu.ie.cr.jungle.store.Command; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; @@ -14,12 +13,12 @@ */ public class RedBlackTreeDeleteChildAtOperation implements NodeOperation { - private int pos; - private NodePath path; + private String key; + private ByteBuffer value; - public RedBlackTreeDeleteChildAtOperation(int pos, NodePath path) { - this.pos = pos; - this.path = path; + public RedBlackTreeDeleteChildAtOperation(String key, ByteBuffer value) { + this.key = key; + this.value = value; } @Override @@ -30,10 +29,9 @@ @Override public Either<Error, TreeNode> invoke(TreeNode target) { TreeNodeChildren children = target.getChildren(); - return children.matchingChildDeleteAt(pos, path); + return children.matchingChildDeleteAt(key, value); } - @Override public int getPosition() { return -2;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/RedBlackTreeDeleteChildAt.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/RedBlackTreeDeleteChildAt.java Fri Jan 27 00:41:06 2017 +0900 @@ -2,26 +2,27 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.OperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import java.nio.ByteBuffer; + /** * Created by e115731 on 2017/01/04. */ public class RedBlackTreeDeleteChildAt implements NodeEditor { - private final int pos; - private final NodePath path; + private final String key; + private final ByteBuffer value; - public RedBlackTreeDeleteChildAt(int pos, NodePath path) { - this.pos = pos; - this.path = path; + public RedBlackTreeDeleteChildAt(String key, ByteBuffer value) { + this.key = key; + this.value = value; } public Either<Error, LoggingNode> _edit(LoggingNode logNode) { - Either<Error, LoggingNode> either = logNode.getChildren().redBlackTreeDeleteChildAt(pos, path); + Either<Error, LoggingNode> either = logNode.getChildren().redBlackTreeDeleteChildAt(key, value); if (either.isA()) { // error return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/RedBlackJungleTreeEditor.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/RedBlackJungleTreeEditor.java Fri Jan 27 00:41:06 2017 +0900 @@ -99,7 +99,6 @@ @Override public Either<Error, JungleTreeEditor> deleteChildAt(NodePath path, int pos) { -<<<<<<< local if (path.getPathType() != PathType.RedBlack) return DefaultEither.newA(UNDEFINE_NODEPATH); String key = path.getKey(); @@ -109,11 +108,6 @@ ByteBuffer value = path.getValue(); RedBlackTreeDeleteChildAt deleteChildAt = new RedBlackTreeDeleteChildAt(key, value); return _edit(newParh, deleteChildAt); -======= - RedBlackTreeDeleteChildAt deleteChildAt = new RedBlackTreeDeleteChildAt(pos, path); //未実装 - NodePath dummyPath = new DefaultNodePath(-2); - return _edit(dummyPath, deleteChildAt); ->>>>>>> other } @Override @@ -122,17 +116,11 @@ return DefaultEither.newA(UNDEFINE_NODEPATH); if (key.equals(balanceKey)) return DefaultEither.newA(INVALID_ARGUMENT); -<<<<<<< local if (path.getPathType() != PathType.RedBlack) return DefaultEither.newA(INVALID_ARGUMENT); NodeEditor editor = new PutAttribute(key, value); NodePath newParh = path.setType(PathType.RedBlackAttribute); //回転処理を行わないで木の複製を行う設定のPathに変えている… ダサい… return _edit(newParh, editor); -======= - path = new DefaultNodePath(-2); //dummyのPathを作る これはtraverserを避けるために使う - RedBlackTreeDeleteChildAt deleteChildAt = null;//new RedBlackTreeDeleteChildAt(key, value); - return edit(path, deleteChildAt); ->>>>>>> other } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DifferenceTreeEditor.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DifferenceTreeEditor.java Fri Jan 27 00:41:06 2017 +0900 @@ -20,7 +20,7 @@ } @Override - public Either<Error, LoggingNode> edit(TreeNode subTreeRoot, NodePath path, NodeEditor editor) { + public Either<Error, LoggingNode> edit(TreeNode subTreeRoot, NodePath path, NodeEditor editor) { Evaluator evalutor = new DefaultEvaluator(path); Either<Error,Traversal> traverseEither = traverser.traverse(subTreeRoot, evalutor); if (traverseEither.isA()) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/TreeEditor.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/TreeEditor.java Fri Jan 27 00:41:06 2017 +0900 @@ -9,5 +9,5 @@ public interface TreeEditor { - public Either<Error, LoggingNode> edit(TreeNode root, NodePath path, NodeEditor editor) ; + public Either<Error, LoggingNode> edit(TreeNode root, NodePath path, NodeEditor editor) ; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Default/DefaultTreeNodeChildren.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Default/DefaultTreeNodeChildren.java Fri Jan 27 00:41:06 2017 +0900 @@ -3,7 +3,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; @@ -84,7 +83,7 @@ //まだ実装していない もともと赤黒木の編集用 @Override - public Either<Error, TreeNode> matchingChildDeleteAt(int pos , NodePath path) { + public Either<Error, TreeNode> matchingChildDeleteAt(String key, ByteBuffer value) { return null; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeChildren.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeChildren.java Fri Jan 27 00:41:06 2017 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; @@ -57,7 +56,7 @@ @Override - public Either<Error, TreeNode> matchingChildDeleteAt(int pos , NodePath path) { + public Either<Error, TreeNode> matchingChildDeleteAt(String key, ByteBuffer value) { return null; //未使用 }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Fri Jan 27 00:41:06 2017 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; import jp.ac.u_ryukyu.ie.cr.jungle.core.Children; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; @@ -20,5 +19,5 @@ Either<Error, TreeNode> addNewChildAndPutAttribtue(int pos, String key, ByteBuffer value); - Either<Error, TreeNode> matchingChildDeleteAt(int pos , NodePath path) ; + Either<Error, TreeNode> matchingChildDeleteAt(String key, ByteBuffer value); } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Fri Jan 27 00:41:06 2017 +0900 @@ -1,10 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.redBlackTree; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.Rotate; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.*; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; import org.junit.Test; import java.nio.ByteBuffer; @@ -28,7 +25,7 @@ this.leftChild = left; this.rightChild = right; if (value != null) - this.valueStr = new String(value.array()); + this.valueStr = new String(value.array()); } //test用 @@ -113,22 +110,16 @@ */ public abstract int checkDepth(int count, int minCount); - public RebuildNode delete(NodePath path, ColorlessTreeNode parent, Rotate side) { - RebuildNode rebuildNode; + public RebuildNode delete(String insertKey, ByteBuffer deleteValue, ColorlessTreeNode parent, Rotate side) { if (!this.empty()) { - if (path.size() == 1) { - rebuildNode = replaceNode(parent); + RebuildNode rebuildNode; + long result = this.compare(deleteValue); + if (result > 0) { + rebuildNode = right().delete(insertKey, deleteValue, this, Rotate.R); + } else if (result < 0) { + rebuildNode = left().delete(insertKey, deleteValue, this, Rotate.L); } else { - Pair<Integer, NodePath> pair = path.pop(); - path = pair.right(); - int num = pair.left(); - if (num == 1) { - rebuildNode = right().delete(path, this, Rotate.R); - } else if (num == 0) { - rebuildNode = left().delete(path, this, Rotate.L); - } else { - return null; - } + rebuildNode = replaceNode(parent); } if (parent == null || rebuildNode == null) return rebuildNode;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/RedBlackTreeNodeChildren.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/RedBlackTreeNodeChildren.java Fri Jan 27 00:41:06 2017 +0900 @@ -2,7 +2,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.Rotate; import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; @@ -13,6 +12,7 @@ import java.nio.ByteBuffer; import java.util.Iterator; +import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.JungleTreeError.INVALID_ARGUMENT; import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.DELETE_VALUE_NOT_FOUND; /** @@ -45,10 +45,10 @@ } @Override - public Either<Error, TreeNode> matchingChildDeleteAt(int pos , NodePath path) { - path = path.add(pos);//削除するpathを作る - path = path.pop().right();// -1をpathから外す - RebuildNode newNode = node.delete(path, null, Rotate.N); + public Either<Error, TreeNode> matchingChildDeleteAt(String key, ByteBuffer value) { + if (value == null) + return DefaultEither.newA(INVALID_ARGUMENT); + RebuildNode newNode = node.delete(key, value, null, Rotate.N); if (newNode == null) return DefaultEither.newA(DELETE_VALUE_NOT_FOUND); // 削除するノードが無かった場合 ColorlessTreeNode root = newNode.getNode();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DefaultJungleTree.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DefaultJungleTree.java Fri Jan 27 00:41:06 2017 +0900 @@ -18,7 +18,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.GetOldTreeError; -import java.util.Iterator; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -76,11 +75,6 @@ return path.addHead(-1); } - @Override - public Iterator<NodePath> getMathNodePath(String key, String value) { //未実装 - return null; - } - AtomicReference<TreeContext> getRepository(){ return repository; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/JungleTree.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/JungleTree.java Fri Jan 27 00:41:06 2017 +0900 @@ -10,8 +10,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; -import java.util.Iterator; - public interface JungleTree { public JungleTreeEditor getJungleTreeEditor(); @@ -33,7 +31,5 @@ public NodePath getNodePath(TreeNode node); - public Iterator<NodePath> getMathNodePath(String key, String value); - public JungleTreeEditor getLocalJungleTreeEditor(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/RedBlackJungleTree.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/RedBlackJungleTree.java Fri Jan 27 00:41:06 2017 +0900 @@ -1,11 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.tree; -import jp.ac.u_ryukyu.ie.cr.jungle.core.Attributes; import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeListWriter; -import jp.ac.u_ryukyu.ie.cr.jungle.query.traverser.nodeiterator.DefaultNodeAndPathIterator; -import jp.ac.u_ryukyu.ie.cr.jungle.query.traverser.nodeiterator.RedBlackTreeNodeAndPathIterator; import jp.ac.u_ryukyu.ie.cr.jungle.store.TreeContext; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.RedBlackJungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; @@ -13,10 +9,8 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.redBlackTree.ColorlessTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; import org.junit.Test; -import java.util.Iterator; import java.util.concurrent.atomic.AtomicReference; /** @@ -43,72 +37,6 @@ return new RedBlackJungleTreeEditor(root, balanceKey, txManager, treeEditor); } - /** - * もう少し最適化できると思う ノードのPathも返す検索をTraverserに実装する? - */ - @Override - public Iterator<NodePath> getMathNodePath(String key, String value) { - if (!key.equals(balanceKey)) { - Iterator<Pair<TreeNode, NodePath>> iterator = new DefaultNodeAndPathIterator(getRootNode()); - - NodePath path = null; - - while (path == null && iterator.hasNext()) { - path = nextMatch(iterator.next(), key, value); - } - final NodePath finalPath = path; - return new Iterator<NodePath>() { - NodePath matchPath = finalPath; - - @Override - public boolean hasNext() { - return matchPath != null; - } - - - @Override - public NodePath next() { - NodePath currentPath = matchPath; - while (iterator.hasNext()) { - matchPath = nextMatch(iterator.next(), key, value); - } - - return currentPath; - } - }; - } else { - Iterator<Pair<TreeNode, NodePath>> iterator = new RedBlackTreeNodeAndPathIterator(getRootNode(), key, value); - - return new Iterator<NodePath>() { - NodePath path; - @Override - public boolean hasNext() { - if (!iterator.hasNext()) - return false; - Pair<TreeNode, NodePath> p = iterator.next(); - TreeNode node = p.left(); - if (node == null) - return false; - path = p.right(); - return true; - } - - @Override - public NodePath next() { - return path; - } - }; - } - } - private NodePath nextMatch(Pair<TreeNode, NodePath> p, String key, String value) { - TreeNode node = p.left(); - Attributes attribute = node.getAttributes(); - String v = attribute.getString(key); - if (v.equals(value)) - return p.right(); - return null; - } - @Test public void checkDepth() { ColorlessTreeNode root = (ColorlessTreeNode) getRootNode();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTree.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTree.java Fri Jan 27 00:41:06 2017 +0900 @@ -21,7 +21,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.GetOldTreeError; -import java.util.Iterator; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -142,9 +141,4 @@ } return path; } - - @Override - public Iterator<NodePath> getMathNodePath(String key, String value) { //未実装 - return null; - } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Fri Jan 27 00:41:06 2017 +0900 @@ -91,16 +91,7 @@ } @Override -<<<<<<< local public Either<Error, JungleTreeEditor> moveChild(NodePath path,int childNum, String move) { -======= - public Either<Error, JungleTreeEditor> deleteChildAt(NodePath path, int pos, String Key, ByteBuffer value) { - return null; //未実装 - } - - @Override - public Either<Error, JungleTreeEditor> moveChild(NodePath path, int childNum, String move) { ->>>>>>> other MoveChild movechild = new MoveChild(move, childNum); return _edit(path,movechild); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTree.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTree.java Fri Jan 27 00:41:06 2017 +0900 @@ -20,7 +20,6 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.GetOldTreeError; -import java.util.Iterator; import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -147,9 +146,4 @@ } return path; } - - @Override - public Iterator<NodePath> getMathNodePath(String key, String value) { //未実装 - return null; - } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTreeEditor.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTreeEditor.java Fri Jan 27 00:41:06 2017 +0900 @@ -63,7 +63,7 @@ return treeEditor; } - private Either<Error,JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) + private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { Either<Error, LoggingNode> editEither = editor.edit(root, _path, _e); if(editEither.isA()){ @@ -115,7 +115,7 @@ @Override - public Either<Error,JungleTreeEditor> putAttribute(NodePath _path, String _key, ByteBuffer _value) + public Either<Error,JungleTreeEditor> putAttribute(NodePath _path,String _key,ByteBuffer _value) { PutAttribute putAttribute = new PutAttribute(_key,_value); return _edit(_path,putAttribute); @@ -135,7 +135,7 @@ } @Override - public Either<Error,JungleTreeEditor> edit(NodePath _path, NodeEditor _editor) + public Either<Error,JungleTreeEditor> edit(NodePath _path,NodeEditor _editor) { return _edit(_path,_editor); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/RedBlack/RedBlackTreeEditorNodeTest.java Fri Jan 27 00:39:10 2017 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/RedBlack/RedBlackTreeEditorNodeTest.java Fri Jan 27 00:41:06 2017 +0900 @@ -69,38 +69,20 @@ System.out.println("------------------------------------------- delete -----------------------------------------------------------------------------------"); for (int count = 1; count <= testCount; count++) { JungleTreeEditor editor = tree.getJungleTreeEditor(); -<<<<<<< local ByteBuffer value = ByteBuffer.wrap(("value" + count).getBytes()); NodePath redBlackTreeNodePath = new RedBlackTreeNodePath(key,value); Either<Error, JungleTreeEditor> either = editor.deleteChildAt(redBlackTreeNodePath, 0); -======= - String value = "value" + count; - Iterator<NodePath> iterator = tree.getMathNodePath(key, value); - Assert.assertTrue(iterator.hasNext()); - path = iterator.next(); - Either<Error, JungleTreeEditor> either = editor.deleteChildAt(path, 0); ->>>>>>> other Assert.assertFalse(either.isA()); editor = either.b(); either = editor.success(); Assert.assertFalse(either.isA()); ColorlessTreeNode rootNode = (ColorlessTreeNode) tree.getRootNode(); - Iterator<TreeNode> nodeIterator = new DefaultNodeIterator(rootNode); + Iterator<TreeNode> iterator = new DefaultNodeIterator(rootNode); int nodeCount = 0; - int count1 = count + 1; - while (count1 <= testCount) { - String value1 = "value" + count1; - Iterator<NodePath> pathIteratpr = tree.getMathNodePath(key, value1); - Assert.assertTrue(pathIteratpr.hasNext()); - path = pathIteratpr.next(); - Assert.assertNotNull(path); - count1++; - } - - while (nodeIterator.hasNext() && rootNode.getAttributes().get(key) != null) { //削除時間違えて他のノードを消してないかを調べる - ColorlessTreeNode node = (ColorlessTreeNode) nodeIterator.next(); + while (iterator.hasNext() && rootNode.getAttributes().get(key) != null) { //削除時間違えて他のノードを消してないかを調べる + ColorlessTreeNode node = (ColorlessTreeNode) iterator.next(); ByteBuffer seach = node.getAttributes().get(key); Assert.assertTrue(rootNode.get(seach)); nodeCount++; @@ -108,8 +90,6 @@ int expectCount = testCount - count; Assert.assertEquals(expectCount, nodeCount); - ColorlessTreeNode rootNode2 = (ColorlessTreeNode) rootNode; //test用methodを使うためにcastしている - rootNode2.checkDepth(0, 0); //赤黒木のバランスが取れているかを調べる }