Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 271:64123c7e9abf Implementation_of_communication
implement Difference List
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Fri Dec 16 02:45:46 2016 +0900 @@ -11,14 +11,14 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeContext; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DifferenceTreeContext; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DifferenceTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DifferenceTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; 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.transaction.node.UnDefineNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traverser; @@ -110,19 +110,18 @@ @Override public JungleTree createNewDifferenceTree(final String name) { TreeNode rootNode = new DefaultTreeNode(); - TreeNode unDefineNode = new UnDefineNode(); + return createNewDifferenceTree(name, rootNode); + } + + @Override + public JungleTree createNewDifferenceTree(final String name, TreeNode rootNode) { + TreeNode unDefineNode = new DefaultTreeNode(); TreeNodeChildren children = rootNode.getChildren(); Either<Error, TreeNode> either = children.addNewChildAt(0, unDefineNode); if (either.isA()) { return null; } TreeNode newRootNode = either.b(); - return createNewDifferenceTree(name, newRootNode); - } - - @Override - public JungleTree createNewDifferenceTree(final String name, TreeNode rootNode) { - ChangeList list = new ChangeList() { @Override public Iterator<TreeOperation> iterator() { @@ -146,8 +145,8 @@ } }; - InterfaceTraverser traverser = new InterfaceTraverser(rootNode, true); - TreeContext tc = new DefaultTreeContext(rootNode, null, list, uuid, name, 0, traverser); + InterfaceTraverser traverser = new InterfaceTraverser(newRootNode, true); + TreeContext tc = new DifferenceTreeContext(newRootNode, unDefineNode,null ,list, uuid, name, 0, traverser); JungleTree newTree = new DifferenceListJungleTree(tc, uuid, journal.getWriter(), differenceEditor); if (trees.putIfAbsent(name, newTree) != null) { return null;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/Command.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/Command.java Fri Dec 16 02:45:46 2016 +0900 @@ -2,6 +2,7 @@ public enum Command { + COMMIT, APPEND_CHILD, DELETE_CHILD, PUT_ATTRIBUTE,
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/DefaultOperationLog.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/DefaultOperationLog.java Fri Dec 16 02:45:46 2016 +0900 @@ -16,7 +16,10 @@ { this(EMPTY); } - + + public DefaultOperationLog(NodeOperation op) { + log = EMPTY.addLast(op); + } private DefaultOperationLog(List<NodeOperation> _log) { log = _log;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/DefaultNodePath.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/DefaultNodePath.java Fri Dec 16 02:45:46 2016 +0900 @@ -19,17 +19,6 @@ path = new List<Integer>().addLast(-1); } - - /* - * 基本使わない - * 差分リストTreeの指定のときのみ使用する - * 差分リストTreeでは、<0>の時一番後ろの不定ノードを指定するようにする - * DefaultNodePath(0)で一番後ろの不定ノードを指定するPathを作成する際にのみ使用する - */ - public DefaultNodePath(int num) { - path = new List<Integer>().addLast(num); - } - public DefaultNodePath(String nodePath) { List<Integer> _path = new List<>(); String[] nums = nodePath.split(",");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/Commit.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,42 @@ +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.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; + +import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.NOT_USE_METHOD; + +/** + * Created by e115731 on 2016/12/16. + */ +public class Commit implements NodeOperation { + + @Override + public Command getCommand() { + return Command.COMMIT; + } + + @Override + public Either<Error, TreeNode> invoke(TreeNode _target) { + return DefaultEither.newA(NOT_USE_METHOD); + } + + @Override + public int getPosition() { + return 0; + } + + @Override + public String getKey() { + return null; + } + + @Override + public ByteBuffer getValue() { + return null; + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/replaceRootNodeAt.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/replaceRootNodeAt.java Fri Dec 16 02:45:46 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -public class replaceRootNodeAt implements NodeEditor { +public class ReplaceRootNodeAt implements NodeEditor { public Either<Error, LoggingNode> _edit(LoggingNode _e)
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DefaultJungleTreeEditor.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DefaultJungleTreeEditor.java Fri Dec 16 02:45:46 2016 +0900 @@ -64,7 +64,6 @@ Iterable<TreeOperation> iterable = new IterableConverter<>(newLog,converter); DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); TreeOperationLog newTreeOpLog = log.append(treeOperationLog); - JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog); return DefaultEither.newB(newEditor); } @@ -72,7 +71,7 @@ @Override public Either<Error,JungleTreeEditor> replaceNewRootNode() { - replaceRootNodeAt appendChildAt = new replaceRootNodeAt(); + ReplaceRootNodeAt appendChildAt = new ReplaceRootNodeAt(); return _edit(new DefaultNodePath(),appendChildAt); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DifferenceJungleTreeEditor.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DifferenceJungleTreeEditor.java Fri Dec 16 02:45:46 2016 +0900 @@ -4,14 +4,15 @@ 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.logger.TreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.DefaultTreeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.AppendChildAt; -import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.*; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial.DifferencialTreeNode; 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; @@ -20,32 +21,30 @@ import java.nio.ByteBuffer; -import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.NOT_USE_METHOD; - public class DifferenceJungleTreeEditor implements JungleTreeEditor { private final TransactionManager txManager; - private final TreeNode root; private final TreeEditor editor; private final TreeOperationLog log; + private final TreeNode subTreeRoot; public DifferenceJungleTreeEditor(TreeNode _root, TransactionManager _txManager, TreeEditor _editor) { this(_root, _txManager, _editor, new DefaultTreeOperationLog()); } - public DifferenceJungleTreeEditor(TreeNode newNode, TransactionManager _txManager, TreeEditor _editor, TreeOperationLog _log) { - this.root = newNode; + public DifferenceJungleTreeEditor(TreeNode subTreeRoot, TransactionManager _txManager, TreeEditor _editor, TreeOperationLog _log) { this.txManager = _txManager; this.editor = _editor; this.log = _log; + this.subTreeRoot = subTreeRoot; } private Either<Error, JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) { - Either<Error, LoggingNode> editEither = editor.edit(root, _path, _e); + Either<Error, LoggingNode> editEither = editor.edit(subTreeRoot, _path, _e); - if(editEither.isA()){ + if (editEither.isA()) { return DefaultEither.newA(editEither.a()); } @@ -53,67 +52,79 @@ OperationLog newLog = newLogging.getOperationLog(); TreeNode newNode = newLogging.getWrap(); - IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ + IterableConverter.Converter<TreeOperation, NodeOperation> converter = new IterableConverter.Converter<TreeOperation, NodeOperation>() { @Override - public TreeOperation conv(NodeOperation _b){ - return new DefaultTreeOperation(_path,_b); + public TreeOperation conv(NodeOperation _b) { + return new DefaultTreeOperation(_path, _b); } }; - Iterable<TreeOperation> iterable = new IterableConverter<>(newLog,converter); - DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); + Iterable<TreeOperation> iterable = new IterableConverter<>(newLog, converter); + DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable, newLog.length()); TreeOperationLog newTreeOpLog = log.append(treeOperationLog); - JungleTreeEditor newEditor = new DifferenceJungleTreeEditor(newNode,txManager,editor,newTreeOpLog); + JungleTreeEditor newEditor = new DifferenceJungleTreeEditor(newNode, txManager, editor, newTreeOpLog); return DefaultEither.newB(newEditor); } @Override - public Either<Error, JungleTreeEditor> addNewChildAt(NodePath path, int pos) { - AppendChildAt appendChildAt = new AppendChildAt(pos); - return _edit(path,appendChildAt); + public Either<Error, JungleTreeEditor> replaceNewRootNode() { + ReplaceRootNodeAt replaceRootNodeAt = new ReplaceRootNodeAt(); + return _edit(new DefaultNodePath(), replaceRootNodeAt); } @Override - public Either<Error, JungleTreeEditor> deleteChildAt(NodePath path, int pos) { - return null; + public Either<Error, JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) { + AppendChildAt appendChildAt = new AppendChildAt(_pos); + return _edit(_path, appendChildAt); + } + + @Override + public Either<Error, JungleTreeEditor> deleteChildAt(NodePath _path, int _pos) { + DeleteChildAt deleteChildAt = new DeleteChildAt(_pos); + return _edit(_path, deleteChildAt); } @Override - public Either<Error, JungleTreeEditor> putAttribute(NodePath path, String key, ByteBuffer value) { - return null; + public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, String _key, ByteBuffer _value) { + PutAttribute putAttribute = new PutAttribute(_key, _value); + return _edit(_path, putAttribute); } @Override - public Either<Error, JungleTreeEditor> deleteAttribute(NodePath path, String key) { - return null; + public Either<Error, JungleTreeEditor> deleteAttribute(NodePath _path, String _key) { + DeleteAttribute deleteAttribute = new DeleteAttribute(_key); + return _edit(_path, deleteAttribute); } @Override - public Either<Error, JungleTreeEditor> replaceNewRootNode() { - return null; + public Either<Error, JungleTreeEditor> moveChild(NodePath path, int childNum, String move) { + MoveChild movechild = new MoveChild(move, childNum); + return _edit(path, movechild); } + @Override - public Either<Error, JungleTreeEditor> edit(NodePath path, NodeEditor editor) { - return null; + public Either<Error, JungleTreeEditor> edit(NodePath _path, NodeEditor _editor) { + return _edit(_path, _editor); } @Override public Either<Error, JungleTreeEditor> success() { - return null; + Either<Error, TransactionManager> either = txManager.commit(subTreeRoot, log); + if (either.isA()) { + return DefaultEither.newA(either.a()); + } + + TransactionManager newTxManager = either.b(); + JungleTreeEditor newTreeEditor = new DifferenceJungleTreeEditor(new DifferencialTreeNode(), newTxManager, editor); + + return DefaultEither.newB(newTreeEditor); } @Override public Either<Error, JungleTreeEditor> flushSuccess() { - return null; + return success(); } - - @Override - public Either<Error, JungleTreeEditor> moveChild(NodePath path, int childNum, String move) { - return DefaultEither.newA(NOT_USE_METHOD); - } - - -} +} \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DefaultTreeEditor.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DefaultTreeEditor.java Fri Dec 16 02:45:46 2016 +0900 @@ -42,7 +42,6 @@ } private Either<Error, LoggingNode> clone(LoggingNode newWrap, Traversal traversal, NodeEditor editor) { - // copying nodes from bottom to root List<Direction<TreeNode>> path = new List<>(); for (Direction<TreeNode> direction : traversal) { path = path.addLast(direction);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DifferenceTreeEditor.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DifferenceTreeEditor.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,12 +1,13 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -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.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.*; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultEvaluator; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Evaluator; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traverser; 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; @@ -19,57 +20,14 @@ } @Override - public Either<Error, LoggingNode> edit(TreeNode root, NodePath path, NodeEditor editor) { - Evaluator evalutor; - if (path.get(0) == -2) { - evalutor = new LastNodeEvaluator(); - } else { - evalutor = new DefaultEvaluator(path); - } - Either<Error,Traversal> traverseEither = traverser.traverse(root, evalutor); + 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()) { return DefaultEither.newA(traverseEither.a()); } Traversal traversal = traverseEither.b(); TreeNode target = traversal.destination(); - Either<Error, LoggingNode> either = editor.edit(target); - if (!target.status()) - return either; - if (either.isA()) { - return DefaultEither.newA(either.a()); - } - LoggingNode newWrap = either.b(); - - return clone(traversal, newWrap, editor); - } - - private Either<Error, LoggingNode> clone(Traversal traversal, LoggingNode newWrap, NodeEditor editor) { - // copying nodes from bottom to root - List<Direction<TreeNode>> path = new List<>(); - for (Direction<TreeNode> direction : traversal) { - path = path.addLast(direction); - } - - Direction<TreeNode> editedNodeDirection = path.head(); - - // top - int pos = editedNodeDirection.getPosition(); - TreeNode child = newWrap.getWrap(); - for (Direction<TreeNode> parentDirection : path.deleteHead()) { - - TreeNodeChildren chs = parentDirection.getTarget().getChildren(); - - Either<Error, TreeNode> ret = chs.replaceNode(pos, child); - if (ret.isA()) { - return DefaultEither.newA(ret.a()); - } - - child = ret.b(); - pos = parentDirection.getPosition(); - } - - TreeNode newRoot = child; - LoggingNode logNode = editor.wrap(newRoot, newWrap.getOperationLog()); - return DefaultEither.newB(logNode); + return editor.edit(target); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DefaultTransactionManager.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DefaultTransactionManager.java Fri Dec 16 02:45:46 2016 +0900 @@ -30,14 +30,6 @@ uuid = _uuid; } - /* - * DefaultTransactionManagerでは使わない - * 間違えてnewUnDefineNodeを入れてもここで落とす - */ - @Override - public Either<Error, TransactionManager> commit(TreeNode newRoot, TreeNode newUnDefineNode, final TreeOperationLog log) { - return commit(newRoot, log); - } @Override public Either<Error, TransactionManager> commit(TreeNode newRoot, final TreeOperationLog _log) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java Fri Dec 16 02:45:46 2016 +0900 @@ -3,20 +3,26 @@ import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeListWriter; import jp.ac.u_ryukyu.ie.cr.jungle.store.TreeContext; +import jp.ac.u_ryukyu.ie.cr.jungle.store.index.ParentIndex; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.Commit; +import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DifferenceTreeContext; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial.DifferencialTreeNode; 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.traverser.InterfaceTraverser; 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.DefaultError; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.Iterator; +import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; -import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TransactionError.INVALID_ARGUMENT; +import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.*; /** * Created by e115731 on 2016/12/13. @@ -34,27 +40,18 @@ uuid = _uuid; } - /** - * - *差分Treeの場合unDefineNodeが必要なのでcommitの引数に無かった場合 - * エラーを返す - * - **/ @Override - public Either<Error, TransactionManager> commit(TreeNode _newRoot, TreeOperationLog _log) { - return DefaultEither.newA(INVALID_ARGUMENT); - } - - @Override - public Either<Error, TransactionManager> commit(TreeNode newRoot, TreeNode newUnDefineNode, final TreeOperationLog log) { + public Either<Error, TransactionManager> commit(TreeNode subTreeRoot, TreeOperationLog log) { long currentRevision = tip.revision(); long nextRevision = currentRevision + 1; + NodeOperation commitOperation = new Commit(); + TreeOperationLog newLog = log.add(new DefaultNodePath(), commitOperation); final String _treeName = tip.getTreeName(); ChangeList list = new ChangeList() { @Override public Iterator<TreeOperation> iterator() { - return log.iterator(); + return newLog.iterator(); } @Override @@ -64,7 +61,7 @@ @Override public TreeOperationLog getLog() { - return log; + return newLog; } @Override @@ -74,16 +71,47 @@ }; - InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); + TreeNode newUnDefineNode = new DifferencialTreeNode(); + Either<Error, TreeNode> either = createSubTreeUnDefineNode(subTreeRoot, newUnDefineNode); + if (either.isA()) + return DefaultEither.newA(ADD_NEW_CHILD_ERROR); + TreeNode root = tip.getRoot(); + InterfaceTraverser traverser = new InterfaceTraverser(root, true); traverser.createIndex(); - TreeContext newTreeContext = new DifferenceTreeContext(newRoot,newUnDefineNode, tip, list, uuid, _treeName, nextRevision, traverser); + TreeContext newTreeContext = new DifferenceTreeContext(root, newUnDefineNode, tip, list, uuid, _treeName, nextRevision, traverser); if (repository.compareAndSet(newTreeContext.prev(), newTreeContext)) { - TransactionManager txManager = new DefaultTransactionManager(writer, newTreeContext, repository, uuid); + either = replaceUnDefineNode(subTreeRoot); + if (either.isA()) + return DefaultEither.newA(either.a()); + TransactionManager txManager = new DifferenceTransactionManager(writer, newTreeContext, repository, uuid); return DefaultEither.newB(txManager); } - return DefaultEither.newA((Error) new DefaultError()); + return DefaultEither.newA(CAS_MISS); + } + + private Either<Error, TreeNode> replaceUnDefineNode(TreeNode subTreeRoot) { + TreeNode unDefineNode = tip.getUnDefineNode(); + ParentIndex parentIndex = tip.getParentIndex(); + Optional<TreeNode> parentOfUndefineNodeOptional = parentIndex.get(unDefineNode); + if (!parentOfUndefineNodeOptional.isPresent()) + return DefaultEither.newA(UNDEFINENODE_PARENT_NOT_FOUND); + TreeNode parentOfUndefineNode = parentOfUndefineNodeOptional.get(); + TreeNodeChildren children = parentOfUndefineNode.getChildren(); + return children.replaceNode(0,subTreeRoot); + } + + private Either<Error, TreeNode> createSubTreeUnDefineNode(TreeNode subTreeRoot, TreeNode newUnDefineNode) { + TreeNode n = subTreeRoot; + while (true) { + TreeNodeChildren children = n.getChildren(); + Either<Error, TreeNode> either = children.at(0); + if (either.isA()) + break; + n = either.b(); + } + return n.getChildren().addNewChildAt(0, newUnDefineNode); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/TransactionManager.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/TransactionManager.java Fri Dec 16 02:45:46 2016 +0900 @@ -9,7 +9,6 @@ public interface TransactionManager { public Either<Error,TransactionManager> commit(TreeNode _newRoot,TreeOperationLog _log); - public Either<Error,TransactionManager> commit (TreeNode newRoot, TreeNode newUnDefineNode, final TreeOperationLog log); public Either<Error,TransactionManager> flashCommit(TreeNode _newRoot,TreeOperationLog _log); public String getUUID(); public long getRevision();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Default/DefaultTreeNode.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,58 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default; + + +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.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; +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; + +public class DefaultTreeNode implements TreeNode { + private List<TreeNode> children; + private TreeMap<String, ByteBuffer> attrs; + + private static final List<TreeNode> NIL_LIST = new List<>(); + + public DefaultTreeNode() { + this(NIL_LIST, new TreeMap<>()); + } + + public DefaultTreeNode(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { + attrs = _attrs; + children = _children; + } + + @Override + public DefaultTreeNodeChildren getChildren() { + return new DefaultTreeNodeChildren(children, attrs); + } + + @Override + public DefaultTreeNodeAttribute getAttributes() { + return new DefaultTreeNodeAttribute(children, attrs); + } + + @Override + public DefaultTreeNode createNewNode() { + return new DefaultTreeNode(); + } + + public DefaultTreeNode clone() { + return new DefaultTreeNode(children, attrs); + } + + @Override + public Either<Error, TreeNode> appendRootNode() { + TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<>()); + Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); + return either; + } + + @Override + public int compareTo(TreeNode o) { + return this.hashCode() - o.hashCode(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Default/DefaultTreeNodeAttribute.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,113 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default; + +import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; +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; +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 jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; + +import java.nio.ByteBuffer; +import java.util.Iterator; +import java.util.Optional; + +public class DefaultTreeNodeAttribute implements TreeNodeAttributes { + public List<TreeNode> children; + public TreeMap<String, ByteBuffer> attrs; + + + public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { + children = _children; + attrs = _attrs; + } + + @Override + public Either<Error, TreeNode> delete(String _key) { + if (_key == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } + + if (null == attrs.get(_key)) { + return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); + } + + TreeMap<String, ByteBuffer> newMap = attrs.delete(_key); + TreeNode newNode = new DefaultTreeNode(children, newMap); + return DefaultEither.newB(newNode); + } + + @Override + public Either<Error, TreeNode> put(String _key, ByteBuffer _value) { + if (_key == null || _value == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } + + TreeMap<String, ByteBuffer> newMap = attrs.put(_key, _value); + TreeNode newNode = new DefaultTreeNode(children, newMap); + return DefaultEither.newB(newNode); + } + + @Override + public ByteBuffer get(String _key) { + if (_key == null) { + return null; + } + Optional<ByteBuffer> op = attrs.get(_key); + if (op.isPresent()) { + return op.get(); + } + return null; + } + + @Override + public String getString(String key) { + ByteBuffer attribute = get(key); + if (attribute != null) + return new String(attribute.array()); + return null; + } + + @Override + public Iterator<String> getKeys() { + return attrs.keys(); + } + + @Override + public Iterator<String> getFilteringKey(java.util.List<String> filter) { + + return new Iterator<String>() { + private Iterator<String> keys = attrs.keys(); + private String next = init(); + + private String init() { + while (keys.hasNext()) { + String key = keys.next(); + if (filter.contains(key)) + continue; + return key; + } + return null; + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public String next() { + String tmp = next; + next = init(); + return tmp; + } + }; + } + + + @Override + public boolean contain(String key) { + return attrs.get(key) != null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Default/DefaultTreeNodeChildren.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,116 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default; + + +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.trasnformer.NodeEditorError; +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.DefaultEither; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; + +import java.nio.ByteBuffer; +import java.util.Iterator; + +public class DefaultTreeNodeChildren implements TreeNodeChildren { + + public List<TreeNode> children; + public TreeMap<String, ByteBuffer> attrs; + + public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { + children = _children; + attrs = _attrs; + } + + private boolean boundaryCheck(int _pos) { + int size = children.length(); + return size >= _pos && _pos >= 0; + + } + + @Override + public Either<Error, TreeNode> addNewChildAt(int _pos) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + + List<TreeNode> newChildren = children.add(_pos, new DefaultTreeNode()); + TreeNode newNode = new DefaultTreeNode(newChildren, attrs); + return DefaultEither.newB(newNode); + } + + @Override + public Either<Error, TreeNode> deleteChildAt(int _pos) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + + List<TreeNode> newChildren = children.delete(_pos); + TreeNode newNode = new DefaultTreeNode(newChildren, attrs); + + return DefaultEither.newB(newNode); + } + + @Override + public int size() { + return children.length(); + } + + @Override + public Iterator<TreeNode> iterator() { + return children.iterator(); + } + + @Override + public Either<Error, TreeNode> replaceNode(int _pos, TreeNode _replacement) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + List<TreeNode> newChildren = children.replace(_pos, _replacement); + TreeNode node = new DefaultTreeNode(newChildren, attrs); + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> moveChild(int pos, String move) { + int size = children.length(); + TreeNode child = children.get(pos); + List<TreeNode> newChildren; + if (move.equals("up") && pos != 0) { + children = children.delete(pos); + newChildren = children.add((pos - 1), child); + } else if (move.equals("down") && pos < size - 1) { //sizeは0から始まるため -1する + children = children.delete(pos); + newChildren = children.add((pos + 1), child); + } else { + return DefaultEither.newA(new DefaultError()); + } + TreeNode newNode = new DefaultTreeNode(newChildren, attrs); + return DefaultEither.newB(newNode); + } + + @Override + public Either<Error, TreeNode> at(int _pos) { + if (!boundaryCheck(_pos + 1) && _pos > 0 ) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + + TreeNode Node = children.get(_pos); + + return DefaultEither.newB(Node); + } + + @Override + public Either<Error, TreeNode> addNewChildAt(int _pos, TreeNode _newChild) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + List<TreeNode> newChildren = children.add(_pos, _newChild); + TreeNode newNode = new DefaultTreeNode(newChildren, attrs); + + return DefaultEither.newB(newNode); + } + +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNode.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; - - -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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; - -import java.nio.ByteBuffer; - -public class DefaultTreeNode implements TreeNode { - private List<TreeNode> children; - private TreeMap<String, ByteBuffer> attrs; - - private static final List<TreeNode> NIL_LIST = new List<>(); - - public DefaultTreeNode() { - this(NIL_LIST, new TreeMap<>()); - } - - public DefaultTreeNode(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { - attrs = _attrs; - children = _children; - } - - @Override - public DefaultTreeNodeChildren getChildren() { - return new DefaultTreeNodeChildren(children, attrs); - } - - @Override - public DefaultTreeNodeAttribute getAttributes() { - return new DefaultTreeNodeAttribute(children, attrs); - } - - @Override - public boolean status() { - return true; - } - - @Override - public DefaultTreeNode createNewNode() { - return new DefaultTreeNode(); - } - - public DefaultTreeNode clone() { - return new DefaultTreeNode(children, attrs); - } - - @Override - public Either<Error, TreeNode> appendRootNode() { - TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<>()); - Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); - return either; - } - - @Override - public int compareTo(TreeNode o) { - return this.hashCode() - o.hashCode(); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeAttribute.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; - -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditorError; -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 jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; - -import java.nio.ByteBuffer; -import java.util.Iterator; -import java.util.Optional; - -public class DefaultTreeNodeAttribute implements TreeNodeAttributes { - public List<TreeNode> children; - public TreeMap<String, ByteBuffer> attrs; - - - public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { - children = _children; - attrs = _attrs; - } - - @Override - public TreeMap<String, ByteBuffer> getAttributesAsRawMap() { - return attrs; - } - - @Override - public Either<Error, TreeNode> delete(String _key) { - if (_key == null) { - return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); - } - - if (null == attrs.get(_key)) { - return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); - } - - TreeMap<String, ByteBuffer> newMap = attrs.delete(_key); - TreeNode newNode = new DefaultTreeNode(children, newMap); - return DefaultEither.newB(newNode); - } - - @Override - public Either<Error, TreeNode> put(String _key, ByteBuffer _value) { - if (_key == null || _value == null) { - return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); - } - - TreeMap<String, ByteBuffer> newMap = attrs.put(_key, _value); - TreeNode newNode = new DefaultTreeNode(children, newMap); - return DefaultEither.newB(newNode); - } - - @Override - public ByteBuffer get(String _key) { - if (_key == null) { - return null; - } - Optional<ByteBuffer> op = attrs.get(_key); - if (op.isPresent()) { - return op.get(); - } - return null; - } - - @Override - public String getString(String key) { - ByteBuffer attribute = get(key); - if (attribute != null) - return new String(attribute.array()); - return null; - } - - @Override - public Iterator<String> getKeys() { - return attrs.keys(); - } - - @Override - public Iterator<String> getFilteringKey(java.util.List<String> filter) { - - return new Iterator<String>() { - private Iterator<String> keys = attrs.keys(); - private String next = init(); - - private String init() { - while (keys.hasNext()) { - String key = keys.next(); - if (filter.contains(key)) - continue; - return key; - } - return null; - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public String next() { - String tmp = next; - next = init(); - return tmp; - } - }; - } - - - @Override - public boolean contain(String key) { - return attrs.get(key) != null; - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeChildren.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; - - -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.trasnformer.NodeEditorError; -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.DefaultError; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; - -import java.nio.ByteBuffer; -import java.util.Iterator; - -public class DefaultTreeNodeChildren implements TreeNodeChildren { - - public List<TreeNode> children; - public TreeMap<String, ByteBuffer> attrs; - - public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { - children = _children; - attrs = _attrs; - } - - private boolean boundaryCheck(int _pos) { - int size = children.length(); - if (size < _pos) { - return false; - } - - return true; - } - - @Override - public List<TreeNode> getChildrenAsRawList() { - return children; - } - - @Override - public Either<Error, TreeNode> addNewChildAt(int _pos) { - if (!boundaryCheck(_pos) || _pos < 0) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - List<TreeNode> newChildren = children.add(_pos, new DefaultTreeNode()); - TreeNode newNode = new DefaultTreeNode(newChildren, attrs); - return DefaultEither.newB(newNode); - } - - @Override - public Either<Error, TreeNode> deleteChildAt(int _pos) { - if (!boundaryCheck(_pos) || _pos < 0 || size() == 0) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - List<TreeNode> newChildren = children.delete(_pos); - TreeNode newNode = new DefaultTreeNode(newChildren, attrs); - - return DefaultEither.newB(newNode); - } - - @Override - public int size() { - return children.length(); - } - - @Override - public Iterator<TreeNode> iterator() { - return children.iterator(); - } - - @Override - public Either<Error, TreeNode> replaceNode(int _pos, TreeNode _replacement) { - int size = children.length(); - if (!(0 <= _pos && _pos < size)) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - TreeNode replacement = _replacement; - - List<TreeNode> newChildren = children.replace(_pos, replacement); - TreeNode node = new DefaultTreeNode(newChildren, attrs); - return DefaultEither.newB(node); - } - - @Override - public Either<Error, TreeNode> moveChild(int pos, String move) { - int size = children.length(); - TreeNode child = children.get(pos); - List<TreeNode> newChildren; - if (move.equals("up") && pos != 0) { - children = children.delete(pos); - newChildren = children.add((pos - 1), child); - } else if (move.equals("down") && pos < size - 1) { //sizeは0から始まるため -1する - children = children.delete(pos); - newChildren = children.add((pos + 1), child); - } else { - return DefaultEither.newA(new DefaultError()); - } - TreeNode newNode = new DefaultTreeNode(newChildren, attrs); - return DefaultEither.newB(newNode); - } - - @Override - public Either<Error, TreeNode> at(int _pos) { - if (children.length() < _pos + 1) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - TreeNode Node = children.get(_pos); - - return DefaultEither.newB(Node); - } - - @Override - public Either<Error, TreeNode> addNewChildAt(int _pos, TreeNode _newChild) { - if (!boundaryCheck(_pos) || _pos < 0) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - List<TreeNode> newChildren = children.add(_pos, _newChild); - TreeNode newNode = new DefaultTreeNode(newChildren, attrs); - - return DefaultEither.newB(newNode); - } - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNode.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,55 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial; + +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNodeAttribute; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; +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 jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeMap; + +public class DifferencialTreeNode implements TreeNode { + private List<TreeNode> children; + private TreeMap<String, ByteBuffer> attrs; + + public DifferencialTreeNode() { + this(new ArrayList<>(), new TreeMap<>()); + } + + public DifferencialTreeNode(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { + attrs = _attrs; + children = _children; + } + + @Override + public TreeNodeChildren getChildren() { + return new DifferencialTreeNodeChildren(this, children); + } + + @Override + public TreeNodeAttributes getAttributes() { + return new DefaultTreeNodeAttribute(null, null); + } + + @Override + public DefaultTreeNode createNewNode() { + return new DefaultTreeNode(); + } + + @Override + public Either<Error, TreeNode> appendRootNode() { + return DefaultEither.newA(TreeEditorError.NOT_USE_METHOD); + } + + @Override + public int compareTo(TreeNode o) { + return this.hashCode() - o.hashCode(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeAttribute.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,110 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial; + +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; +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; +import java.util.Iterator; +import java.util.List; +import java.util.TreeMap; + +/** + * Created by e115731 on 2016/12/15. + */ +public class DifferencialTreeNodeAttribute implements TreeNodeAttributes { + + private TreeMap<String, ByteBuffer> attrs; + private TreeNode node; + + public DifferencialTreeNodeAttribute(TreeNode node, TreeMap<String, ByteBuffer> _attrs) { + attrs = _attrs; + this.node = node; + } + + @Override + public Either<Error, TreeNode> delete(String _key) { + if (_key == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } + + if (null == attrs.get(_key)) { + return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); + } + + attrs.remove(_key); + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> put(String _key, ByteBuffer _value) { + if (_key == null || _value == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } + + attrs.put(_key, _value); + return DefaultEither.newB(node); + } + + @Override + public ByteBuffer get(String _key) { + if (_key == null) { + return null; + } + + return attrs.get(_key); + } + + @Override + public String getString(String key) { + ByteBuffer attribute = get(key); + if (attribute != null) + return new String(attribute.array()); + return null; + } + + @Override + public Iterator<String> getKeys() { + return attrs.keySet().iterator(); + } + + @Override + public Iterator<String> getFilteringKey(List<String> filter) { + + return new Iterator<String>() { + private Iterator<String> keys = attrs.keySet().iterator(); + private String next = init(); + + private String init() { + while (keys.hasNext()) { + String key = keys.next(); + if (filter.contains(key)) + continue; + return key; + } + return null; + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public String next() { + String tmp = next; + next = init(); + return tmp; + } + }; + } + + + @Override + public boolean contain(String key) { + return attrs.containsKey(key); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeChildren.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,100 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial; + + +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; +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.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; + +import java.util.Iterator; +import java.util.List; + +public class DifferencialTreeNodeChildren implements TreeNodeChildren { + + private List<TreeNode> children; + private TreeNode node; + + public DifferencialTreeNodeChildren(TreeNode node, List<TreeNode> _children) { + this.children = _children; + this.node = node; + } + + private boolean boundaryCheck(int _pos) { + int size = children.size(); + return size >= _pos && _pos >= 0; + } + + @Override + public Either<Error, TreeNode> addNewChildAt(int _pos) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + children.add(_pos, new DifferencialTreeNode()); + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> addNewChildAt(int _pos, TreeNode _newChild) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + children.add(_pos, _newChild); + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> deleteChildAt(int _pos) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + children.remove(_pos); + return DefaultEither.newB(node); + } + + @Override + public int size() { + return children.size(); + } + + @Override + public Iterator<TreeNode> iterator() { + return children.iterator(); + } + + @Override + public Either<Error, TreeNode> replaceNode(int _pos, TreeNode _replacement) { + if (!boundaryCheck(_pos)) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + children.set(_pos, _replacement); + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> moveChild(int pos, String move) { + int size = children.size(); + TreeNode child = children.get(pos); + if (move.equals("up") && pos != 0) { + children.remove(pos); + children.add((pos - 1), child); + } else if (move.equals("down") && pos < size - 1) { //sizeは0から始まるため -1する + children.remove(pos); + children.add((pos + 1), child); + } else { + return DefaultEither.newA(new DefaultError()); + } + return DefaultEither.newB(node); + } + + @Override + public Either<Error, TreeNode> at(int _pos) { + if (!boundaryCheck(_pos + 1) && _pos > 0 ) { + return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); + } + TreeNode n = children.get(_pos); + return DefaultEither.newB(n); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNode.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNode.java Fri Dec 16 02:45:46 2016 +0900 @@ -9,8 +9,6 @@ public TreeNodeAttributes getAttributes(); - public NodeType status(); - public TreeNode createNewNode(); public Either<Error, TreeNode> appendRootNode();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeAttributes.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeAttributes.java Fri Dec 16 02:45:46 2016 +0900 @@ -3,17 +3,16 @@ import jp.ac.u_ryukyu.ie.cr.jungle.core.Attributes; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; import java.nio.ByteBuffer; import java.util.Iterator; +import java.util.List; 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 Iterator<String> getKeys(); public boolean contain(String key); - public Iterator<String> getFilteringKey(java.util.List<String> filter); + public Iterator<String> getFilteringKey(List<String> filter); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,9 +1,8 @@ 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.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; public interface TreeNodeChildren extends Children { @@ -12,5 +11,4 @@ public Either<Error,TreeNode> addNewChildAt(int pos,TreeNode newChild); public Either<Error,TreeNode> replaceNode(int pos,TreeNode replacement); Either<Error,TreeNode> moveChild(int pos, String move); - public List<TreeNode> getChildrenAsRawList(); } \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/UnDefineNode.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; - -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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; - -import java.nio.ByteBuffer; -import java.rmi.dgc.VMID; - -/** - * Created by e115731 on 2016/12/13. - */ -public class UnDefineNode implements TreeNode { - private List<TreeNode> children; - private TreeMap<String, ByteBuffer> attrs; - final String nodeId = new VMID().toString(); - - private static final List<TreeNode> NIL_LIST = new List<>(); - - public UnDefineNode() { - this(NIL_LIST, new TreeMap<>()); - } - - public UnDefineNode(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { - attrs = _attrs; - children = _children; - } - - @Override - public DefaultTreeNodeChildren getChildren() { - return new DefaultTreeNodeChildren(children, attrs); - } - - @Override - public DefaultTreeNodeAttribute getAttributes() { - return new DefaultTreeNodeAttribute(children, attrs); - } - - @Override - public boolean status() { - return false; - } - - @Override - public DefaultTreeNode createNewNode() { - return new DefaultTreeNode(); - } - - public DefaultTreeNode clone() { - return new DefaultTreeNode(children, attrs); - } - - @Override - public Either<Error, TreeNode> appendRootNode() { - TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<>()); - Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); - return either; - } - - @Override - public int compareTo(TreeNode o) { - return this.hashCode() - o.hashCode(); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/LastNodeEvaluator.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.traverser; - - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; - -public class LastNodeEvaluator implements Evaluator { - - /* - *posはLastNodeEvaluatorでは使わない - * このEvaluatorは<-1,0,0,……>にある - * UNDEFINENODEを取得するEvaluatorである - */ - @Override - public Evaluation evaluate(TreeNode _current, int _pos) { - - if (!_current.status()) - return new DefaultEvaluation(Result.GOAL, null); - - Result result = Result.ACCEPT; - - Evaluator nextEvaluator = new LastNodeEvaluator(); - - return new DefaultEvaluation(result, nextEvaluator); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TreeEditorError.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TreeEditorError.java Fri Dec 16 02:45:46 2016 +0900 @@ -4,4 +4,8 @@ { public static final Error NODEPATH_NOTFOUND = new DefaultError(); public static final Error NOT_USE_METHOD = new DefaultError(); + public static final Error ADD_NEW_CHILD_ERROR = new DefaultError(); + public static final Error UNDEFINENODE_PARENT_NOT_FOUND = new DefaultError(); + public static final Error CAS_MISS = new DefaultError(); + }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/core/NetworkDefaultJungle.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/core/NetworkDefaultJungle.java Fri Dec 16 02:45:46 2016 +0900 @@ -13,7 +13,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeContext; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.transaction.NetworkDefaultJungleTree;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungle.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungle.java Fri Dec 16 02:45:46 2016 +0900 @@ -11,7 +11,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.DefaultTreeOperationLog; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import java.util.Enumeration;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Fri Dec 16 02:45:46 2016 +0900 @@ -67,8 +67,8 @@ @Override public Either<Error, JungleTreeEditor> replaceNewRootNode() { - replaceRootNodeAt appendChildAt = new replaceRootNodeAt(); - return _edit(new DefaultNodePath(), appendChildAt); + ReplaceRootNodeAt replaceRootNodeAt = new ReplaceRootNodeAt(); + return _edit(new DefaultNodePath(), replaceRootNodeAt); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Fri Dec 16 02:45:46 2016 +0900 @@ -32,16 +32,6 @@ bufferSize = _bufferSize; } - /* - * DefaultTransactionManagerでは使わない - * 間違えてnewUnDefineNodeを入れてもここで落とす - */ - @Override - public Either<Error, TransactionManager> commit(TreeNode newRoot, TreeNode newUnDefineNode, final TreeOperationLog log) { - return commit(newRoot, log); - } - - @Override public Either<Error, TransactionManager> commit(TreeNode _newRoot, final TreeOperationLog _log) { long currentRevision = tip.revision();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkTransactionManager.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkTransactionManager.java Fri Dec 16 02:45:46 2016 +0900 @@ -33,16 +33,6 @@ treeName = _treeName; } - /* - * DefaultTransactionManagerでは使わない - * 間違えてnewUnDefineNodeを入れてもここで落とす - */ - @Override - public Either<Error, TransactionManager> commit(TreeNode newRoot, TreeNode newUnDefineNode, final TreeOperationLog log) { - return commit(newRoot, log); - } - - @Override public Either<Error, TransactionManager> commit(TreeNode newRoot, final TreeOperationLog _log) { long currentRevision = tip.revision();
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/ChildrenTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/ChildrenTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.core; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNodeChildren; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNodeChildren; import junit.framework.Assert; import junit.framework.TestCase;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.AppendChildAt; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.PutAttribute; import jp.ac.u_ryukyu.ie.cr.jungle.tests.util.TestUtil; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultEvaluator; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/AppendChildAtTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/AppendChildAtTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import junit.framework.TestCase;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteAttributeAtTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteAttributeAtTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,16 +1,16 @@ package jp.ac.u_ryukyu.ie.cr.jungle.core.nodeeditor; -import java.nio.ByteBuffer; - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.DeleteAttribute; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import junit.framework.TestCase; +import java.nio.ByteBuffer; + public class DeleteAttributeAtTest extends TestCase { public void testEdit()
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteChildAtTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteChildAtTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -3,7 +3,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.DeleteChildAt; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/PutAttributeTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/PutAttributeTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -2,7 +2,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.LoggingNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.PutAttribute; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/tree/DefferenceTree.java Tue Dec 13 21:16:13 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.core.tree; - -import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; -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.traverser.DefaultTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; -import org.junit.Test; - -/** - * Created by e115731 on 2016/12/12. - */ -public class DefferenceTree { - @Test - public void DefferenceTreeTest(){ - Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTraverser()); - JungleTree tree = jungle.createNewDifferenceTree("df"); - JungleTreeEditor editor = tree.getJungleTreeEditor(); - NodePath path = new DefaultNodePath(-2); - // editor = editor.addNewChildAt(path,0).b(); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/tree/DifferencialTree/DefferenceTree.java Fri Dec 16 02:45:46 2016 +0900 @@ -0,0 +1,25 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.core.tree.DifferencialTree; + +import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; +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.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; +import org.junit.Test; + +/** + * Created by e115731 on 2016/12/12. + */ +public class DefferenceTree { + @Test + public void DefferenceTreeTest(){ + Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTraverser()); + JungleTree tree = jungle.createNewDifferenceTree("df"); + JungleTreeEditor editor = tree.getJungleTreeEditor(); + NodePath path = new DefaultNodePath(); + System.out.println("test"); + editor = editor.addNewChildAt(path,0).b(); + } +}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultAttributesTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultAttributesTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,16 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; import jp.ac.u_ryukyu.ie.cr.jungle.core.AttributesTest; +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.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import org.junit.Assert; import java.nio.ByteBuffer; -import java.util.Optional; public class DefaultAttributesTest extends AttributesTest { @@ -28,27 +26,4 @@ TreeNode node = new DefaultTreeNode(rawList,rawMap); return node.getAttributes(); } - - public void testGetAttributesAsRawMap() - { - TreeNodeAttributes attrs = instance(); - TreeMap<String,ByteBuffer> rawMap = attrs.getAttributesAsRawMap(); - - // testing rawmap is not null. - Assert.assertNotNull(rawMap); - - // testing rawmap has correct key values. - for(Pair<String,ByteBuffer> entry : ENTRIES){ - String key = entry.left(); - ByteBuffer value = entry.right(); - - Optional<ByteBuffer> option = rawMap.get(key); - if(!option.isPresent()){ - Assert.fail(); - } - - ByteBuffer actual = option.get(); - Assert.assertEquals(0,actual.compareTo(value)); - } - } }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultChildrenTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultChildrenTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -3,11 +3,10 @@ import jp.ac.u_ryukyu.ie.cr.jungle.core.ChildrenTest; 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.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNodeChildren; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNodeChildren; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import org.junit.Assert; import java.nio.ByteBuffer; @@ -32,13 +31,4 @@ { return 3; } - - public void testGetChildrenAsRawList() - { - DefaultTreeNodeChildren instance = instance(); - List<TreeNode> rawList = instance.getChildrenAsRawList(); - - Assert.assertNotNull(rawList); - Assert.assertEquals(expectSize(),rawList.length()); - } } \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/FilteringKeyTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/FilteringKeyTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -2,7 +2,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import org.junit.Assert; import org.junit.Test;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/GetNodePath.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/GetNodePath.java Fri Dec 16 02:45:46 2016 +0900 @@ -6,7 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/tests/util/TestUtil.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/tests/util/TestUtil.java Fri Dec 16 02:45:46 2016 +0900 @@ -1,15 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.jungle.tests.util; -import java.nio.ByteBuffer; - +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import org.junit.Ignore; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; -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; @Ignore public class TestUtil
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/InterfaceTraverserTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/InterfaceTraverserTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -6,7 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Tue Dec 13 21:16:13 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Fri Dec 16 02:45:46 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.*; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error;