Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 266:c62462c28807 Implementation_of_communication
separate edit → traverse edit clone
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataReadBenchMark.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/DataReadBenchMark.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DefaultTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkNodePath; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/JungleLogCopyBenchMark.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/benchMark/persistent/JungleLogCopyBenchMark.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,6 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DefaultTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; 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.jungleNetwork.operations.NetworkNodePath; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle; @@ -39,7 +40,7 @@ for (int j = 0; j < 2000; j++) { count++; editor = tree1.getJungleTreeEditor(); - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, JungleTreeEditor> either = editor.addNewChildAt(path, pos); + Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, pos); NodePath childPath = path.add(pos); Assert.assertFalse(either.isA()); editor = either.b();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/DefaultJungle.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,25 +6,27 @@ import jp.ac.u_ryukyu.ie.cr.jungle.persistent.Journal; import jp.ac.u_ryukyu.ie.cr.jungle.persistent.NullJournal; import jp.ac.u_ryukyu.ie.cr.jungle.store.TreeContext; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DefaultDifferenceTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; 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.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.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.TreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; +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; import jp.ac.u_ryukyu.ie.cr.jungle.tree.DefaultJungleTree; -import jp.ac.u_ryukyu.ie.cr.jungle.tree.DefferenceListJungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.tree.DifferenceListJungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.Enumeration; import java.util.Iterator; @@ -57,7 +59,7 @@ this.trees = new ConcurrentHashMap<String, JungleTree>(); this.uuid = uuid; this.treeEditor = new DefaultTreeEditor(traverser); - this.differenceEditor = new DefaultDifferenceTreeEditor(traverser); + this.differenceEditor = new DifferenceTreeEditor(traverser); } @Override @@ -67,7 +69,7 @@ @Override public JungleTree createNewTree(final String name) { - return createNewTree(name,new DefaultTreeNode()); + return createNewTree(name, new DefaultTreeNode()); } @Override @@ -107,7 +109,15 @@ @Override public JungleTree createNewDifferenceTree(final String name) { - return createNewDifferenceTree(name,new DefaultTreeNode()); + TreeNode rootNode = new DefaultTreeNode(); + TreeNode unDefineNode = new UnDefineNode(); + 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 @@ -138,7 +148,7 @@ }; InterfaceTraverser traverser = new InterfaceTraverser(rootNode, true); TreeContext tc = new DefaultTreeContext(rootNode, null, list, uuid, name, 0, traverser); - JungleTree newTree = new DefferenceListJungleTree(tc, uuid, journal.getWriter(), differenceEditor); + JungleTree newTree = new DifferenceListJungleTree(tc, uuid, journal.getWriter(), differenceEditor); if (trees.putIfAbsent(name, newTree) != null) { return null; } @@ -148,7 +158,7 @@ @Override public Iterator<String> getTreeNames() { Enumeration<String> treeNames = trees.keys(); - return new Iterator<String>(){ + return new Iterator<String>() { @Override public boolean hasNext() {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/commandline/commandline.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/commandline/commandline.java Tue Dec 13 16:48:23 2016 +0900 @@ -2,18 +2,18 @@ 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.store.nodepath.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.omnigraffle.OmniGraffleCreater; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; 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.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither; -import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultError; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.xml.reader.XmlReader; import javax.xml.parsers.ParserConfigurationException;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/App.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/App.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/Children.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/core/Children.java Tue Dec 13 16:48:23 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface Children extends Iterable<TreeNode> {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/persistent/DefaultJournal.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/persistent/DefaultJournal.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import java.nio.channels.FileChannel.MapMode; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; /* * text based journal.
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingAttributes.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingAttributes.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.PutAttributeOperation; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingChildren.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingChildren.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class LoggingChildren {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingNode.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/logger/LoggingNode.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.store.logger; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.ReplaceRootNodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/InsertNodePositionData.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/omnigraffle/InsertNodePositionData.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,7 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; import jp.ac.u_ryukyu.ie.cr.jungle.store.index.ParentIndex; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.Iterator; import java.util.LinkedList;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/AppendChildAtOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/AppendChildAtOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; 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.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public final class AppendChildAtOperation implements NodeOperation
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ChildMoveOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ChildMoveOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -3,7 +3,7 @@ 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.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DeleteAttributeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DeleteAttributeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ 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.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public final class DeleteAttributeOperation implements NodeOperation {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DeleteChildAtOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/DeleteChildAtOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ 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.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class DeleteChildAtOperation implements NodeOperation {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/NodeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/NodeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ 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.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface NodeOperation {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/PutAttributeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/PutAttributeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; 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.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class PutAttributeOperation implements NodeOperation
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ReplaceRootNodeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/operations/ReplaceRootNodeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.Command; 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.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class ReplaceRootNodeOperation implements NodeOperation {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/AppendChildAt.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/AppendChildAt.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.OperationLog; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class AppendChildAt implements NodeEditor {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/DeleteAttribute.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/DeleteAttribute.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; 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.logger.OperationLog; @@ -18,7 +18,7 @@ public Either<Error,LoggingNode> _edit(LoggingNode logNode) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,LoggingNode> either = logNode.getAttributes().delete(key); + Either<Error,LoggingNode> either = logNode.getAttributes().delete(key); if(either.isA()){ // error return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/DeleteChildAt.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/DeleteChildAt.java Tue Dec 13 16:48:23 2016 +0900 @@ -3,7 +3,7 @@ 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.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; 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; @@ -18,7 +18,7 @@ public Either<Error,LoggingNode> _edit(LoggingNode logNode) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,LoggingNode> either = logNode.getChildren().deleteChildAt(pos); + Either<Error,LoggingNode> either = logNode.getChildren().deleteChildAt(pos); if(either.isA()){ // error return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/MoveChild.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/MoveChild.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,7 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.OperationLog; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class MoveChild implements NodeEditor {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/NodeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/NodeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,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.logger.OperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface NodeEditor {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/NodeEditorError.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/NodeEditorError.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; public class NodeEditorError {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/PutAttribute.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/PutAttribute.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.OperationLog; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public class PutAttribute implements NodeEditor {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/replaceRootNodeAt.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/trasnformer/replaceRootNodeAt.java Tue Dec 13 16:48:23 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.logger.OperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; 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; @@ -12,7 +12,7 @@ public Either<Error, LoggingNode> _edit(LoggingNode _e) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,LoggingNode> either = _e.replaceNewRootNode(); + Either<Error,LoggingNode> either = _e.replaceNewRootNode(); if(either.isA()){ // error return either;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/DefaultTransactionManager.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction; - - -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.logger.TreeOperationLog; -import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -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.DefaultError; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; - -import java.util.Iterator; -import java.util.concurrent.atomic.AtomicReference; - -public class DefaultTransactionManager implements TransactionManager { - private final AtomicReference<TreeContext> repository; - private final TreeContext tip; - private final ChangeListWriter writer; - private final String uuid; - - public DefaultTransactionManager(ChangeListWriter _writer, TreeContext _tip, - AtomicReference<TreeContext> _repository, String _uuid) { - repository = _repository; - tip = _tip; - writer = _writer; - uuid = _uuid; - } - - @Override - public Either<Error, TransactionManager> commit(TreeNode newRoot, final TreeOperationLog _log) { - long currentRevision = tip.revision(); - long nextRevision = currentRevision + 1; - - final String _treeName = tip.getTreeName(); - ChangeList list = new ChangeList() { - @Override - public Iterator<TreeOperation> iterator() { - return _log.iterator(); - } - - @Override - public String getTreeName() { - return _treeName; - } - - @Override - public TreeOperationLog getLog() { - return _log; - } - - @Override - public String uuid() { - return uuid; - } - - }; - - InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); - traverser.createIndex(); - TreeContext newTreeContext = new DefaultTreeContext(newRoot , tip, list, uuid, _treeName, nextRevision,traverser); - - if (repository.compareAndSet(newTreeContext.prev(),newTreeContext)) { - TransactionManager txManager = new DefaultTransactionManager(writer, newTreeContext, repository, uuid); - return DefaultEither.newB(txManager); - } - - return DefaultEither.newA((jp.ac.u_ryukyu.ie.cr.jungle.util.Error) new DefaultError()); - } - - @Override - public Either<Error, TransactionManager> flashCommit(TreeNode _newRoot, TreeOperationLog _log) { - return commit(_newRoot,_log); - } - - @Override - public String getUUID() { - return uuid; - } - - @Override - public long getRevision() { - return tip.revision(); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/TransactionManager.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction; - - -import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; -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.util.Error; - -public interface TransactionManager -{ - public Either<Error,TransactionManager> commit(TreeNode _newRoot,TreeOperationLog _log); - public Either<Error,TransactionManager> flashCommit(TreeNode _newRoot,TreeOperationLog _log); - public String getUUID(); - public long getRevision(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/Error/TreeEditorError.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.Error; - -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultError; - -public class TreeEditorError -{ - public static final Error NODEPATH_NOTFOUND = new DefaultError(); - public static final Error NOT_USE_METHOD = new DefaultError(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DefaultDifferenceJungleTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor; - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.DefaultTreeOperationLog; -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.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.transaction.TransactionManager; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; -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; -import jp.ac.u_ryukyu.ie.cr.jungle.util.IterableConverter; - -import java.nio.ByteBuffer; - -import static jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.Error.TreeEditorError.NOT_USE_METHOD; - -/** - * Created by e115731 on 2016/12/11. - */ -public class DefaultDifferenceJungleTreeEditor implements JungleTreeEditor { - - private final TransactionManager txManager; - private final TreeNode root; - private final TreeEditor editor; - private final TreeOperationLog log; - - public DefaultDifferenceJungleTreeEditor(TreeNode _root, TransactionManager _txManager, TreeEditor _editor) { - this(_root, _txManager, _editor, new DefaultTreeOperationLog()); - } - - - public DefaultDifferenceJungleTreeEditor(TreeNode newNode, TransactionManager _txManager, TreeEditor _editor, TreeOperationLog _log) { - this.root = newNode; - this.txManager = _txManager; - this.editor = _editor; - this.log = _log; - } - - private Either<Error, JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) { - Either<Error, LoggingNode> either = editor.edit(root, _path, _e); - if(either.isA()){ - return DefaultEither.newA(either.a()); - } - - LoggingNode newLogging = either.b(); - OperationLog newLog = newLogging.getOperationLog(); - TreeNode newNode = newLogging.getWrap(); - - IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ - @Override - public TreeOperation conv(NodeOperation _b){ - return new DefaultTreeOperation(_path,_b); - } - }; - - Iterable<TreeOperation> iterable = new IterableConverter<>(newLog,converter); - DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); - TreeOperationLog newTreeOpLog = log.append(treeOperationLog); - - JungleTreeEditor newEditor = new DefaultDifferenceJungleTreeEditor(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); - } - - @Override - public Either<Error, JungleTreeEditor> deleteChildAt(NodePath path, int pos) { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> putAttribute(NodePath path, String key, ByteBuffer value) { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> deleteAttribute(NodePath path, String key) { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> replaceNewRootNode() { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> edit(NodePath path, NodeEditor editor) { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> success() { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> flushSuccess() { - return null; - } - - @Override - public Either<Error, JungleTreeEditor> moveChild(NodePath path, int childNum, String move) { - return DefaultEither.newA(NOT_USE_METHOD); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DefaultJungleTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DefaultJungleTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -11,11 +11,12 @@ 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.*; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.IterableConverter; import java.nio.ByteBuffer; @@ -44,12 +45,19 @@ private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { - Either<Error,LoggingNode> either = editor.edit(root,_path,_e); - if(either.isA()){ - return DefaultEither.newA(either.a()); + Either<Error,Traversal> traverseEither = editor.traverse(root,_path); + if (traverseEither.isA()) { + return DefaultEither.newA(traverseEither.a()); } - - LoggingNode newLogging = either.b(); + Traversal traversal = traverseEither.b(); + + Either<Error, LoggingNode> editEither = editor.edit(root, traversal, _e); + + if(editEither.isA()){ + return DefaultEither.newA(editEither.a()); + } + + LoggingNode newLogging = editEither.b(); OperationLog newLog = newLogging.getOperationLog(); TreeNode newNode = newLogging.getWrap();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/DifferenceJungleTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,124 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor; + +import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.DefaultTreeOperationLog; +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.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.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.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; +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.IterableConverter; + +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; + + 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; + this.txManager = _txManager; + this.editor = _editor; + this.log = _log; + } + + private Either<Error, JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) { + Either<Error,Traversal> traverseEither = editor.traverse(root,_path); + if (traverseEither.isA()) { + return DefaultEither.newA(traverseEither.a()); + } + Traversal traversal = traverseEither.b(); + + Either<Error, LoggingNode> editEither = editor.edit(root, traversal, _e); + + if(editEither.isA()){ + return DefaultEither.newA(editEither.a()); + } + + LoggingNode newLogging = editEither.b(); + OperationLog newLog = newLogging.getOperationLog(); + TreeNode newNode = newLogging.getWrap(); + + IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ + @Override + public TreeOperation conv(NodeOperation _b){ + return new DefaultTreeOperation(_path,_b); + } + }; + + 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); + return DefaultEither.newB(newEditor); + } + + + @Override + 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) { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> putAttribute(NodePath path, String key, ByteBuffer value) { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> deleteAttribute(NodePath path, String key) { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> replaceNewRootNode() { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> edit(NodePath path, NodeEditor editor) { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> success() { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> flushSuccess() { + return null; + } + + @Override + public Either<Error, JungleTreeEditor> moveChild(NodePath path, int childNum, String move) { + return DefaultEither.newA(NOT_USE_METHOD); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/JungleTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/jungleTreeEditor/JungleTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -3,7 +3,7 @@ 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DefaultDifferenceTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -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.util.DefaultEither; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; - -/** - * Created by e115731 on 2016/12/11. - */ -public class DefaultDifferenceTreeEditor implements TreeEditor { - private Traverser traverser; - - public DefaultDifferenceTreeEditor(Traverser traverser) { - this.traverser = traverser; - } - - @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> either = traverser.traverse(root, evalutor); - - if (either.isA()) { - return DefaultEither.newA(either.a()); - } - Traversal t = either.b(); - return clone(t, editor); - } - - private Either<Error, LoggingNode> clone(Traversal t, NodeEditor editor) { - // copying nodes from bottom to root - - List<Direction<TreeNode>> path = new List<>(); - for (Direction<TreeNode> direction : t) { - path = path.addLast(direction); - } - - // target - Direction<TreeNode> targetDirection = path.head(); - TreeNode target = targetDirection.getTarget(); - Either<Error, LoggingNode> either = editor.edit(target); - if (either.isA()) { - return DefaultEither.newA(either.a()); - } - - LoggingNode newWrap = either.b(); - - // top - int pos = targetDirection.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); - } -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DefaultTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DefaultTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -13,69 +13,63 @@ 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; + +public class DefaultTreeEditor implements TreeEditor { + private final Traverser traverser; + + public DefaultTreeEditor(Traverser traverser) { + this.traverser = traverser; + } + + + @Override + public Either<Error, LoggingNode> edit(TreeNode root, Traversal traversal, NodeEditor editor) { + // target + TreeNode target = traversal.destination(); + Either<Error, LoggingNode> either = editor.edit(target); + if (either.isA()) { + return DefaultEither.newA(either.a()); + } + LoggingNode newWrap = either.b(); + + return clone(newWrap, traversal, editor); + } + + @Override + public Either<Error, Traversal> traverse(TreeNode root, NodePath path) { + DefaultEvaluator e = new DefaultEvaluator(path); + return traverser.traverse(root, e); + } -public class DefaultTreeEditor implements TreeEditor -{ - private final Traverser traverser; - public DefaultTreeEditor(Traverser traverser) - { - this.traverser = traverser; - } - - @Override - public Either<Error,LoggingNode> edit(TreeNode root, NodePath path, NodeEditor editor) - { - DefaultEvaluator e = new DefaultEvaluator(path); - Either<Error, Traversal> either = traverser.traverse(root,e); - - if(either.isA()){ - return DefaultEither.newA(either.a()); - } - Traversal t = either.b(); - return clone(t,editor); - } - - private Either<Error,LoggingNode> clone(Traversal t,NodeEditor editor) - { - // copying nodes from bottom to root - - List<Direction<TreeNode>> path = new List<>(); - for(Direction<TreeNode> direction : t){ - path = path.addLast(direction); - } - - // target - Direction<TreeNode> targetDirection = path.head(); - TreeNode target = targetDirection.getTarget(); - Either<Error,LoggingNode> either = editor.edit(target); - if(either.isA()){ - return DefaultEither.newA(either.a()); - } - - LoggingNode newWrap = either.b(); - - // top - int pos = targetDirection.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()); - } + 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); + } + + 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(); - child = ret.b(); - pos = parentDirection.getPosition(); - } - - TreeNode newRoot = child; - LoggingNode logNode = editor.wrap(newRoot,newWrap.getOperationLog()); - return DefaultEither.newB(logNode); - } - + 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); + } + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/DifferenceTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,81 @@ +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.util.DefaultEither; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; + +/** + * Created by e115731 on 2016/12/11. + */ +public class DifferenceTreeEditor implements TreeEditor { + private Traverser traverser; + + public DifferenceTreeEditor(Traverser traverser) { + this.traverser = traverser; + } + + @Override + public Either<Error, Traversal> traverse(TreeNode root, NodePath path) { + Evaluator evalutor ; + if (path.get(0) == -2) { + evalutor = new LastNodeEvaluator(); + } + else { + evalutor = new DefaultEvaluator(path); + } + return traverser.traverse(root, evalutor); + } + + @Override + public Either<Error, LoggingNode> edit(TreeNode root, Traversal traversal, NodeEditor transformer) { + return null; + } + + private Either<Error, LoggingNode> clone(Traversal t, NodeEditor editor) { + // copying nodes from bottom to root + + List<Direction<TreeNode>> path = new List<>(); + for (Direction<TreeNode> direction : t) { + path = path.addLast(direction); + } + + // target + Direction<TreeNode> targetDirection = path.head(); + TreeNode target = targetDirection.getTarget(); + Either<Error, LoggingNode> either = editor.edit(target); + if (either.isA()) { + return DefaultEither.newA(either.a()); + } + + LoggingNode newWrap = either.b(); + + // top + int pos = targetDirection.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); + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/TreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/editor/treeEditor/TreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,13 +1,15 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; 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.store.trasnformer.NodeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface TreeEditor { - public Either<Error,LoggingNode> edit(TreeNode root, NodePath path, NodeEditor transformer); + public Either<Error,LoggingNode> edit(TreeNode root, Traversal traversal, NodeEditor transformer); + public Either<Error, Traversal> traverse(TreeNode root, NodePath path); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DefaultTransactionManager.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,97 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager; + + +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.logger.TreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.TreeOperation; +import jp.ac.u_ryukyu.ie.cr.jungle.persistent.ChangeList; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeContext; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +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.Error.DefaultError; +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; +import java.util.concurrent.atomic.AtomicReference; + +public class DefaultTransactionManager implements TransactionManager { + private final AtomicReference<TreeContext> repository; + private final TreeContext tip; + private final ChangeListWriter writer; + private final String uuid; + + public DefaultTransactionManager(ChangeListWriter _writer, TreeContext _tip, AtomicReference<TreeContext> _repository, String _uuid) { + repository = _repository; + tip = _tip; + writer = _writer; + 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) { + long currentRevision = tip.revision(); + long nextRevision = currentRevision + 1; + + final String _treeName = tip.getTreeName(); + ChangeList list = new ChangeList() { + @Override + public Iterator<TreeOperation> iterator() { + return _log.iterator(); + } + + @Override + public String getTreeName() { + return _treeName; + } + + @Override + public TreeOperationLog getLog() { + return _log; + } + + @Override + public String uuid() { + return uuid; + } + + }; + + InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); + traverser.createIndex(); + TreeContext newTreeContext = new DefaultTreeContext(newRoot, tip, list, uuid, _treeName, nextRevision, traverser); + + if (repository.compareAndSet(newTreeContext.prev(), newTreeContext)) { + TransactionManager txManager = new DefaultTransactionManager(writer, newTreeContext, repository, uuid); + return DefaultEither.newB(txManager); + } + + return DefaultEither.newA((Error) new DefaultError()); + } + + @Override + public Either<Error, TransactionManager> flashCommit(TreeNode _newRoot, TreeOperationLog _log) { + return commit(_newRoot, _log); + } + + @Override + public String getUUID() { + return uuid; + } + + @Override + public long getRevision() { + return tip.revision(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,106 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager; + +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.logger.TreeOperationLog; +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.TreeNode; +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.concurrent.atomic.AtomicReference; + +import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TransactionError.INVALID_ARGUMENT; + +/** + * Created by e115731 on 2016/12/13. + */ +public class DifferenceTransactionManager implements TransactionManager { + private final AtomicReference<TreeContext> repository; + private final TreeContext tip; + private final ChangeListWriter writer; + private final String uuid; + + public DifferenceTransactionManager(ChangeListWriter _writer, TreeContext _tip, AtomicReference<TreeContext> _repository, String _uuid) { + repository = _repository; + tip = _tip; + writer = _writer; + 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) { + long currentRevision = tip.revision(); + long nextRevision = currentRevision + 1; + + final String _treeName = tip.getTreeName(); + ChangeList list = new ChangeList() { + @Override + public Iterator<TreeOperation> iterator() { + return log.iterator(); + } + + @Override + public String getTreeName() { + return _treeName; + } + + @Override + public TreeOperationLog getLog() { + return log; + } + + @Override + public String uuid() { + return uuid; + } + + }; + + InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true); + traverser.createIndex(); + TreeContext newTreeContext = new DifferenceTreeContext(newRoot,newUnDefineNode, tip, list, uuid, _treeName, nextRevision, traverser); + + if (repository.compareAndSet(newTreeContext.prev(), newTreeContext)) { + TransactionManager txManager = new DefaultTransactionManager(writer, newTreeContext, repository, uuid); + return DefaultEither.newB(txManager); + } + + return DefaultEither.newA((Error) new DefaultError()); + } + + @Override + public Either<Error, TransactionManager> flashCommit(TreeNode _newRoot, TreeOperationLog _log) { + return commit(_newRoot, _log); + } + + @Override + public String getUUID() { + return uuid; + } + + @Override + public long getRevision() { + return tip.revision(); + } + +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/TransactionManager.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,16 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager; + + +import jp.ac.u_ryukyu.ie.cr.jungle.store.logger.TreeOperationLog; +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.util.Error.Error; + +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(); +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNode.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNode.java Tue Dec 13 16:48:23 2016 +0900 @@ -3,7 +3,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +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; @@ -37,7 +37,7 @@ @Override public boolean isDefine() { - return false; + return true; } @Override @@ -52,7 +52,7 @@ @Override public Either<Error, TreeNode> appendRootNode() { TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<>()); - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); + Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); return either; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeAttribute.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeAttribute.java Tue Dec 13 16:48:23 2016 +0900 @@ -4,7 +4,7 @@ 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; +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;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeChildren.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/DefaultTreeNodeChildren.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,13 +1,13 @@ 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.DefaultError; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; 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.data.treemap.TreeMap; +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; @@ -48,7 +48,7 @@ } @Override - public Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, TreeNode> deleteChildAt(int _pos) { + public Either<Error, TreeNode> deleteChildAt(int _pos) { if (!boundaryCheck(_pos) || _pos < 0 || size() == 0) { return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNode.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNode.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungle.transaction.node; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface TreeNode extends Comparable<TreeNode> {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeAttributes.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeAttributes.java Tue Dec 13 16:48:23 2016 +0900 @@ -2,7 +2,7 @@ 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; +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; @@ -11,7 +11,7 @@ public interface TreeNodeAttributes extends Attributes { public Either<Error,TreeNode> delete(String key); - public Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,TreeNode> put(String key,ByteBuffer value); + public Either<Error,TreeNode> put(String key, ByteBuffer value); public TreeMap<String,ByteBuffer> getAttributesAsRawMap(); public Iterator<String> getKeys(); public boolean contain(String key);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/TreeNodeChildren.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,14 +1,14 @@ 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.Error; +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 { public Either<Error,TreeNode> addNewChildAt(int pos); - public Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error,TreeNode> deleteChildAt(int pos); + public Either<Error,TreeNode> deleteChildAt(int pos); 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);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/UnDefineNode.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/UnDefineNode.java Tue Dec 13 16:48:23 2016 +0900 @@ -3,7 +3,7 @@ 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer; import java.rmi.dgc.VMID; @@ -54,7 +54,7 @@ @Override public Either<Error, TreeNode> appendRootNode() { TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<>()); - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); + Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); return either; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultTraverser.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultTraverser.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,7 +6,7 @@ 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.Iterator;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/LastNodeEvaluator.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/LastNodeEvaluator.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,9 +5,21 @@ public class LastNodeEvaluator implements Evaluator { + /* + *posはLastNodeEvaluatorでは使わない + * このEvaluatorは<-1,0,0,……>にある + * UNDEFINENODEを取得するEvaluatorである + */ @Override public Evaluation evaluate(TreeNode _current, int _pos) { - return null; + if (!_current.isDefine()) + 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/traverser/Traverser.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/Traverser.java Tue Dec 13 16:48:23 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface Traverser {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/TraverserError.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/TraverserError.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,10 +1,10 @@ package jp.ac.u_ryukyu.ie.cr.jungle.traverser; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; public class TraverserError { - public static final jp.ac.u_ryukyu.ie.cr.jungle.util.Error UNDEFINED_OPERATOR = new DefaultError(); + public static final Error UNDEFINED_OPERATOR = new DefaultError(); public static final Error PATH_NOT_FOUND = new DefaultError(); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DefaultJungleTree.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DefaultJungleTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -12,12 +12,12 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; import jp.ac.u_ryukyu.ie.cr.jungle.store.index.ParentIndex; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.DefaultJungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.DefaultTransactionManager; 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; -import jp.ac.u_ryukyu.ie.cr.jungle.util.GetOldTreeError; +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.Optional; import java.util.concurrent.atomic.AtomicReference;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DefferenceListJungleTree.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.tree; - - -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.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTransactionManager; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.DefaultDifferenceJungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; - -import java.util.concurrent.atomic.AtomicReference; - -public class DefferenceListJungleTree extends DefaultJungleTree { - public DefferenceListJungleTree(TreeContext tc, String uuid, ChangeListWriter writer, TreeEditor editor) { - super(tc, uuid, writer, editor); - } - - @Override - public JungleTreeEditor getJungleTreeEditor() { - AtomicReference<TreeContext> repository = super.getRepository(); - TreeContext tc = repository.get(); - ChangeListWriter writer = super.getWriter(); - String uuid = super.getUuid(); - TreeEditor treeEditor = super.getTreeEditor(); - DefaultTransactionManager txManager = new DefaultTransactionManager(writer, tc, repository, uuid); - TreeNode root = tc.getRoot(); - return new DefaultDifferenceJungleTreeEditor(root, txManager, treeEditor); - } - - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/DifferenceListJungleTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,32 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.tree; + + +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.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.DefaultTransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.DifferenceJungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.treeEditor.TreeEditor; + +import java.util.concurrent.atomic.AtomicReference; + +public class DifferenceListJungleTree extends DefaultJungleTree { + public DifferenceListJungleTree(TreeContext tc, String uuid, ChangeListWriter writer, TreeEditor editor) { + super(tc, uuid, writer, editor); + } + + @Override + public JungleTreeEditor getJungleTreeEditor() { + AtomicReference<TreeContext> repository = super.getRepository(); + TreeContext tc = repository.get(); + ChangeListWriter writer = super.getWriter(); + String uuid = super.getUuid(); + TreeEditor treeEditor = super.getTreeEditor(); + DefaultTransactionManager txManager = new DefaultTransactionManager(writer, tc, repository, uuid); + TreeNode root = tc.getRoot(); + return new DifferenceJungleTreeEditor(root, txManager, treeEditor); + } + + +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/JungleTree.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/tree/JungleTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; public interface JungleTree { public JungleTreeEditor getJungleTreeEditor();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/DefaultError.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.util; - -public class DefaultError implements Error -{ -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.util; - -public interface Error { - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/DefaultError.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,5 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +public class DefaultError implements Error +{ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/Error.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,5 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +public interface Error { + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/GetOldTreeError.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,7 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; + +public class GetOldTreeError implements Error { + public static final Error OLD_TREE_NOT_FOUND = new DefaultError(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TransactionError.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,8 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +/** + * Created by e115731 on 2016/12/13. + */ +public class TransactionError { + public static final Error INVALID_ARGUMENT = new DefaultError(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TreeEditorError.java Tue Dec 13 16:48:23 2016 +0900 @@ -0,0 +1,7 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.util.Error; + +public class TreeEditorError +{ + public static final Error NODEPATH_NOTFOUND = new DefaultError(); + public static final Error NOT_USE_METHOD = new DefaultError(); +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/GetOldTreeError.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.util; - -public class GetOldTreeError implements Error { - public static final Error OLD_TREE_NOT_FOUND = new DefaultError(); -}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/xml/reader/ReadXmlHandler.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/xml/reader/ReadXmlHandler.java Tue Dec 13 16:48:23 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkAppendChildAtOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkAppendChildAtOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import org.msgpack.annotation.Message; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteAttributeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteAttributeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -4,7 +4,7 @@ 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.store.operations.NodeOperation; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; import org.msgpack.annotation.Message;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteChildAtOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkDeleteChildAtOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -4,7 +4,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import org.msgpack.annotation.Message;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkNodeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkNodeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import org.msgpack.annotation.Message; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkPutAttributeOperation.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/operations/NetworkPutAttributeOperation.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,7 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; 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.store.operations.NodeOperation;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTree.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -18,8 +18,8 @@ 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; -import jp.ac.u_ryukyu.ie.cr.jungle.util.GetOldTreeError; +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.Optional; import java.util.concurrent.atomic.AtomicReference;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentJungleTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -13,10 +13,11 @@ 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.*; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.IterableConverter; import java.nio.ByteBuffer; @@ -40,13 +41,19 @@ this.log = _log; } - private Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, LoggingNode> either = editor.edit(root, _path, _e); - if (either.isA()) { - return DefaultEither.newA(either.a()); + private Either<Error, JungleTreeEditor> _edit(final NodePath _path, NodeEditor _e) { + Either<Error,Traversal> traverseEither = editor.traverse(root,_path); + if (traverseEither.isA()) { + return DefaultEither.newA(traverseEither.a()); + } + Traversal traversal = traverseEither.b(); + + Either<Error, LoggingNode> editEither = editor.edit(root, traversal, _e); + if (editEither.isA()) { + return DefaultEither.newA(editEither.a()); } - LoggingNode newLogging = either.b(); + LoggingNode newLogging = editEither.b(); OperationLog newLog = newLogging.getOperationLog(); TreeNode newNode = newLogging.getWrap();
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/persistent/PersistentTransactionManager.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,12 +6,12 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; 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.transaction.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; 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.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.concurrent.atomic.AtomicReference; @@ -23,8 +23,7 @@ private final String treeName; private final int bufferSize; - public PersistentTransactionManager(String _treeName, ChangeListWriter _writer, TreeContext _tip, - AtomicReference<TreeContext> _repository, String _uuid, int _bufferSize) { + public PersistentTransactionManager(String _treeName, ChangeListWriter _writer, TreeContext _tip, AtomicReference<TreeContext> _repository, String _uuid, int _bufferSize) { repository = _repository; tip = _tip; writer = _writer; @@ -33,6 +32,16 @@ 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/JungleUpdater.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/JungleUpdater.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.nio.ByteBuffer;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTree.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -17,8 +17,8 @@ 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; -import jp.ac.u_ryukyu.ie.cr.jungle.util.GetOldTreeError; +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.Optional; import java.util.concurrent.atomic.AtomicReference;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTreeEditor.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkDefaultJungleTreeEditor.java Tue Dec 13 16:48:23 2016 +0900 @@ -14,10 +14,11 @@ 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.*; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungle.util.IterableConverter; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.codesegment.LogPutCodeSegment; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkTreeOperationLog; @@ -63,14 +64,19 @@ private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { - //LoggingNodeHook hook = new LoggingNodeHook(_e); - Either<Error,LoggingNode> either = editor.edit(root,_path,_e); - if(either.isA()){ - return DefaultEither.newA(either.a()); + Either<Error,Traversal> traverseEither = editor.traverse(root,_path); + if (traverseEither.isA()) { + return DefaultEither.newA(traverseEither.a()); + } + Traversal traversal = traverseEither.b(); + + Either<Error, LoggingNode> editEither = editor.edit(root, traversal, _e); + if(editEither.isA()){ + return DefaultEither.newA(editEither.a()); } - TreeNode newNode = either.b().getWrap(); - OperationLog newLog = either.b().getOperationLog(); + TreeNode newNode = editEither.b().getWrap(); + OperationLog newLog = editEither.b().getOperationLog(); IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkTransactionManager.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transaction/NetworkTransactionManager.java Tue Dec 13 16:48:23 2016 +0900 @@ -8,12 +8,12 @@ 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.TransactionManager; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.manager.TransactionManager; 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.DefaultError; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.DefaultError; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import java.util.Iterator; import java.util.concurrent.atomic.AtomicReference; @@ -25,8 +25,7 @@ private final String uuid; private final String treeName; - public NetworkTransactionManager(String _treeName, ChangeListWriter _writer, TreeContext _tip, - AtomicReference<TreeContext> _repository, String _uuid) { + public NetworkTransactionManager(String _treeName, ChangeListWriter _writer, TreeContext _tip, AtomicReference<TreeContext> _repository, String _uuid) { repository = _repository; tip = _tip; writer = _writer; @@ -34,6 +33,16 @@ 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(); @@ -77,7 +86,7 @@ @Override public Either<Error, TransactionManager> flashCommit(TreeNode _newRoot, TreeOperationLog _log) { - return commit(_newRoot,_log); + return commit(_newRoot, _log); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transformer/NetworkAppendChildAt.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/transformer/NetworkAppendChildAt.java Tue Dec 13 16:48:23 2016 +0900 @@ -11,7 +11,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer.NodeEditor; 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import org.msgpack.annotation.Message; @Message
--- a/src/test/java/DefaultJungleTreeTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/DefaultJungleTreeTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,7 +6,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +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/AttributesContainerTest.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -//package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core; -// -//import org.junit.Assert; -//import org.junit.Ignore; -//import org.junit.Test; -// -//import junit.framework.TestCase; -// -//@Ignore -//public abstract class AttributesContainerTest extends TestCase -//{ -// public abstract AttributesContainer instance(); -// -// @Test -// public void testGetAttributes() -// { -// AttributesContainer instance = instance(); -// Attributes attrs = instance.getAttributes(); -// -// Assert.assertNotNull(attrs); -// } -//}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/GetOldTreeTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/GetOldTreeTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import org.junit.Test;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -12,7 +12,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.Traversal; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import junit.framework.TestCase; @@ -40,11 +40,15 @@ String str = part.toString(); ByteBuffer value = ByteBuffer.wrap(str.getBytes()); PutAttribute putAttribute = new PutAttribute(key, value); - Either<Error, LoggingNode> either = currentEditor.edit(currentRoot, part, putAttribute); - if (either.isA()) { + Either<Error, Traversal> traversalEither = currentEditor.traverse(currentRoot,part); + if (traversalEither.isA()) + Assert.fail(); + Traversal traversal = traversalEither.b(); + Either<Error, LoggingNode> editEither = currentEditor.edit(currentRoot, traversal, putAttribute); + if (editEither.isA()) { Assert.fail(); } - currentRoot = either.b().getWrap(); + currentRoot = editEither.b().getWrap(); } TreeNode newRoot = currentRoot; @@ -79,7 +83,11 @@ DefaultTreeNode node = new DefaultTreeNode(); DefaultNodePath path = new DefaultNodePath(); - Either<Error, LoggingNode> either = instance.edit(node, path, new AppendChildAt(0)); + Either<Error, Traversal> traversalEither = instance.traverse(node,path); + if (traversalEither.isA()) + Assert.fail(); + Traversal traversal = traversalEither.b(); + Either<Error, LoggingNode> either = instance.edit(node, traversal, new AppendChildAt(0)); if (either.isA()) { Assert.fail(); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/AppendChildAtTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/AppendChildAtTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -6,7 +6,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.transaction.node.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +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 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteAttributeAtTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +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/DeleteChildAtTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/DeleteChildAtTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -5,7 +5,7 @@ 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.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +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/EditableAttributesTest.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.nodeeditor; - -import java.nio.ByteBuffer; - -import org.junit.Assert; - -import fj.P; -import fj.P2; -import fj.data.List; -import TreeNode; -import TreeNodeAttributes; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableAttributes; -import NodeEditorError; -import Either; -import Error; -import junit.framework.TestCase; - -public abstract class EditableAttributesTest<T extends TreeNode<T>> extends TestCase -{ - public abstract TreeNodeAttributes<T> instance(); - - @SuppressWarnings("unchecked") - public static final List<P2<String,ByteBuffer>> ENTRIES = List.list( - P.p("KEY1",ByteBuffer.wrap("VALUE1".getBytes())), - P.p("KEY2",ByteBuffer.wrap("VALUE2".getBytes())), - P.p("KEY3",ByteBuffer.wrap("VALUE3".getBytes())) - ); - - public TreeNodeAttributes<T> createTestData() - { - TreeNodeAttributes<T> instance = instance(); - - T node; - TreeNodeAttributes<T> attr = instance; - for(P2<String,ByteBuffer> entry : ENTRIES){ - Either<Error,T> either = attr.put(entry._1(),entry._2()); - if(either.isA()){ - Assert.fail("error during creating the data."); - } - - node = either.b(); - attr = node.getAttributes(); - } - - return attr; - } - - public void testPutDoesNotAcceptNullValue() - { - TreeNodeAttributes<T> instance = instance(); - - Either<Error,T> either = instance.put("KEY",null); - if(!either.isA()){ - Assert.fail("put must returns NULL_VALUE_NOT_ALLOWED when the value was null."); - } - - Assert.assertEquals(NodeEditorError.NULL_VALUE_NOT_ALLOWED,either.a()); - - either = instance.put(null,ByteBuffer.wrap("VALUE".getBytes())); - - if(!either.isA()){ - Assert.fail("put must returns NULL_VALUE_NOT_ALLOWED when the key was null."); - } - - Assert.assertEquals(NodeEditorError.NULL_VALUE_NOT_ALLOWED,either.a()); - } - - public void testPut() - { - createTestData(); - } - - public void testDeleteIfKeyExsist() - { - TreeNodeAttributes<T> attr = createTestData(); - - for(P2<String,ByteBuffer> entry : ENTRIES){ - Either<Error,T> either = attr.delete(entry._1()); - if(either.isA()){ - Assert.fail("error during deleting exist key."); - } - - attr = either.b().getAttributes(); - } - } - - public static final String DUMMY_KEY = "dummy"; - - public void testDeleteIfKeyNotExist() - { - TreeNodeAttributes<T> attr = createTestData(); - - Either<Error,T> either = attr.delete(DUMMY_KEY); - if(!either.isA()){ - Assert.fail("delete must returns DELETE_KEY_NOT_FOUND when the deleting invalid key."); - } - } -} -*/ \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/EditableChildrenTest.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.core.nodeeditor; - -import java.nio.ByteBuffer; -/*import org.junit.Assert; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableChildren; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; -import NodeEditorError; -import Either; -import Error; -import junit.framework.TestCase; - -public abstract class EditableChildrenTest<T extends EditableNode<T>> extends TestCase -{ - public abstract EditableChildren<T> instance(); - - public static final String KEY = "KEY"; - public static final ByteBuffer VALUE = ByteBuffer.wrap("VALUE".getBytes()); - - public void testAddNewChildAtMuinusValue() - { - EditableChildren<T> children = instance(); - Either<Error,T> either = children.addNewChildAt(-1); - if(!either.isA()){ - Assert.fail("addNewChildAt(-1) must returns INDEX_OUT_OF_BOUNDS Error"); - } - - Error e = either.a(); - Assert.assertSame(e,NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - public void testAddNewChildAtOutOfBounds() - { - EditableChildren<T> children = instance(); - Either<Error,T> either = children.addNewChildAt(1); - if(!either.isA()){ - Assert.fail("addNewChildAt(1) must returns INDEX_OUT_OF_BOUNDS Error"); - } - - Error e = either.a(); - Assert.assertSame(e,NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - public void testAddNewChildAtMiddle() - { - EditableChildren<T> children = instance(); - - for(int i = 0;i < 3;i ++){ - Either<Error,T> either = children.addNewChildAt(0); - if(either.isA()){ - Assert.fail("fail when adding new child to head"); - } - children = either.b().getChildren(); - } - - Either<Error, T> either = children.addNewChildAt(1); - if(either.isA()){ - Assert.fail("fail when adding new child to middle (1)"); - } - // size must be 4 - children = either.b().getChildren(); - Assert.assertEquals(4,children.size()); - } - - public void testAddNewChildAtToHead() - { - EditableChildren<T> children = instance(); - - int size = children.size(); - - Either<Error,T> either = children.addNewChildAt(0); - if(either.isA()){ - Assert.fail("error during add new child to head"); - } - children = either.b().getChildren(); - Assert.assertEquals(size + 1,children.size()); - } - - public void testDeleteChildAtMuinusValue() - { - EditableChildren<T> children = instance(); - Either<Error,T> either = children.deleteChildAt(-1); - if(!either.isA()){ - Assert.fail("deleteChildAt(-1) must returns INDEX_OUT_OF_BOUNDS Error"); - } - - Error e = either.a(); - Assert.assertSame(e,NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - public void testDeleteChildAtOutOfBounds() - { - EditableChildren<T> children = instance(); - Either<Error,T> either = children.deleteChildAt(1); - if(!either.isA()){ - Assert.fail("deleteChildAt(1) must returns INDEX_OUT_OF_BOUNDS Error"); - } - - Error e = either.a(); - Assert.assertSame(e,NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - public void testDeleteChildAtFailsWhenTheSizeIsZero() - { - EditableChildren<T> children = instance(); - Either<Error,T> either = children.deleteChildAt(0); - if(!either.isA()){ - Assert.fail("deleteChildAt(1) must returns INDEX_OUT_OF_BOUNDS Error"); - } - - Error e = either.a(); - Assert.assertSame(e,NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - - public void testDeleteChildAt() - { - EditableChildren<T> children = instance(); - - int size = children.size(); - - Either<Error,T> either = children.addNewChildAt(0); - if(either.isA()){ - Assert.fail("error during add new child to head"); - } - children = either.b().getAttributes().put(KEY,VALUE).b().getChildren(); - Assert.assertEquals(size + 1,children.size()); - - either = children.deleteChildAt(0); - if(either.isA()){ - Assert.fail("error during deleting child"); - } - children = either.b().getChildren(); - - Assert.assertEquals(size,children.size()); - } -}*/
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/PutAttributeTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/PutAttributeTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -1,16 +1,15 @@ 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.PutAttribute; import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.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.TestCase; import org.junit.Assert; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; -import junit.framework.TestCase; +import java.nio.ByteBuffer; public class PutAttributeTest extends TestCase {
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/ReplaceRootNodeAt.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/nodeeditor/ReplaceRootNodeAt.java Tue Dec 13 16:48:23 2016 +0900 @@ -7,7 +7,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import org.junit.Test; @@ -28,7 +28,7 @@ TreeNode newRoot = tree.getRootNode(); Assert.assertFalse(oldRoot.equals(newRoot)); - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, TreeNode> childrenEither = newRoot.getChildren().at(0); + Either<Error, TreeNode> childrenEither = newRoot.getChildren().at(0); Assert.assertTrue(childrenEither.isB()); TreeNode newRootChildren = childrenEither.b(); Assert.assertEquals(oldRoot, newRootChildren);
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/tree/DefferenceTree.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/tree/DefferenceTree.java Tue Dec 13 16:48:23 2016 +0900 @@ -19,6 +19,6 @@ JungleTree tree = jungle.createNewDifferenceTree("df"); JungleTreeEditor editor = tree.getJungleTreeEditor(); NodePath path = new DefaultNodePath(-2); - editor = editor.addNewChildAt(path,0).b(); + // editor = editor.addNewChildAt(path,0).b(); } }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/treeeditor/TreeNodeChildrenTest.java Tue Dec 13 03:16:12 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.treeeditor; - -import java.nio.ByteBuffer; -import org.junit.Assert; -import fj.data.List; -import TreeNode; -import TreeNodeChildren; -import Either; -import Error; -import junit.framework.TestCase; - -public abstract class TreeNodeChildrenTest<T extends TreeNode<T>> extends TestCase -{ - public abstract TreeNode<T> instance(); - - public void testAddNewChildAtWithNode() - { - int count = 5; - for(Integer pos : List.range(0,5)){ - _testAddNewChildAtWithNode(count,pos); - } - } - - public void _testAddNewChildAtWithNode(int _count,int _pos) - { - TreeNode<T> instance = instance(); - - Either<Error, T> either; - for(int i = 0;i < _count;i ++){ - either = instance.getChildren().addNewChildAt(0); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - } - - TreeNode<T> newNode = instance.createNewNode(); - String key = "KEY"; - ByteBuffer value = ByteBuffer.wrap("VALUE".getBytes()); - - either = newNode.getAttributes().put(key,value); - if(either.isA()){ - Assert.fail(); - } - newNode = either.b(); - - either = instance.getChildren().addNewChildAt(_pos,newNode); - if(either.isA()){ - Assert.fail(); - } - instance = either.b(); - - // check - either = instance.getChildren().at(_pos); - if(either.isA()){ - Assert.fail(); - } - - T checkTarget = either.b(); - ByteBuffer actual = checkTarget.getAttributes().get(key); - Assert.assertEquals(0,value.compareTo(actual)); - } - - public void testReplaceAt() - { - int count = 5; - for(Integer pos : List.range(0,count)){ - _testReplaceAt(count,pos); - } - } - - public void _testReplaceAt(int _count,int _pos) - { - TreeNode<T> instance = instance(); - String key = "KEY"; - ByteBuffer value = ByteBuffer.wrap("VALUE".getBytes()); - - // prepare - - for(int i = 0;i < _count;i ++){ - TreeNode<T> newNode = instance.createNewNode(); - Either<Error,T> either = newNode.getAttributes().put(key,value); - if(either.isA()){ - Assert.fail("failed to put attributes to child"); - } - - newNode = either.b(); - either = instance.getChildren().addNewChildAt(0,newNode); - if(either.isA()){ - Assert.fail("failed to add child to instance"); - } - - instance = either.b(); - } - - int size = instance.getChildren().size(); - Assert.assertEquals(_count,size); - - // create node for replacement. - - ByteBuffer replaceNodeValue = ByteBuffer.wrap("EULAV".getBytes()); - TreeNode<T> replacement = instance.createNewNode(); - Either<Error,T> either = replacement.getAttributes().put(key,replaceNodeValue); - if(either.isA()){ - Assert.fail("failed to create replacement node"); - } - replacement = either.b(); - - // replace - - either = instance.getChildren().replaceNode(_pos,replacement); - if(either.isA()){ - Assert.fail("failed to replace node."); - } - instance = either.b(); - - TreeNodeChildren<T> children = instance.getChildren(); - for(Integer pos : List.range(0,_count)){ - either = children.at(pos.intValue()); - if(either.isA()){ - Assert.fail("failed to get node."); - } - - T ch = either.b(); - ByteBuffer expect = (_pos != pos) ? value : replaceNodeValue; - ByteBuffer actual = ch.getAttributes().get(key); - - Assert.assertEquals(0,expect.compareTo(actual)); - } - } -}*/
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/GetNodePath.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/GetNodePath.java Tue Dec 13 16:48:23 2016 +0900 @@ -12,6 +12,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; 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 org.junit.Test; @@ -58,7 +59,7 @@ } for (int i = 0; i < 3; i++) { - Either<jp.ac.u_ryukyu.ie.cr.jungle.util.Error, JungleTreeEditor> either = editor.addNewChildAt(path, i); + Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, i); if (either.isA()) Assert.fail(); editor = either.b();
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/index/parentIndexTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/index/parentIndexTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import org.junit.Test;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/tests/util/TestUtil.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/tests/util/TestUtil.java Tue Dec 13 16:48:23 2016 +0900 @@ -9,7 +9,7 @@ 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; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; @Ignore public class TestUtil
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/InterfaceTraverserTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/InterfaceTraverserTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -12,7 +12,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import junit.framework.Assert; import org.junit.Test; @@ -40,7 +40,7 @@ String value = node.getAttributes().getString(key); if (value == null) return false; - if (value.equals("<1,1,-1>")) + if (value.equals("<-1,1,1>")) return true; return false; }, null, null); @@ -48,7 +48,7 @@ Assert.assertTrue(iterator.hasNext()); TreeNode node = iterator.next(); String value = node.getAttributes().getString("KEY"); - Assert.assertEquals("<1,1,-1>", value); + Assert.assertEquals("<-1,1,1>", value); } { @@ -66,28 +66,18 @@ { Iterator<TreeNode> iterator = traverser.find((TreeNode node) -> { // use index find - String value = node.getAttributes().getString(key); - if (value == null) - return false; - if (value.equals("<1,1,-1>")) - return true; - return false; - }, indexKey, "<1,1,-1>+ index"); + return true; + }, indexKey, "<-1,1,1>"); Assert.assertTrue(iterator.hasNext()); TreeNode node = iterator.next(); String value = node.getAttributes().getString("KEY"); - Assert.assertEquals("<1,1,-1>", value); + Assert.assertEquals("<-1,1,1>", value); } { Iterator<TreeNode> iterator = traverser.find((TreeNode node) -> { // use index find - String value = node.getAttributes().getString(key); - if (value == null) - return false; - if (value.equals("<1,1,-1>")) - return true; - return false; + return true; }, indexKey, "no exist index value"); Assert.assertFalse(iterator.hasNext()); @@ -114,8 +104,7 @@ if (either.isA()) Assert.fail(); editor = either.b(); - String value2 = value + "+ index"; - either = editor.putAttribute(path.add(i), indexKey, ByteBuffer.wrap(value2.getBytes())); + either = editor.putAttribute(path.add(i), indexKey, ByteBuffer.wrap(value.getBytes())); if (either.isA()) Assert.fail(); editor = either.b();
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -8,7 +8,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.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; +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/junglenetwork/DataWriteBufferTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/junglenetwork/DataWriteBufferTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -11,7 +11,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkNodePath; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle;
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/junglenetwork/PersistentJournalTest.java Tue Dec 13 03:16:12 2016 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/junglenetwork/PersistentJournalTest.java Tue Dec 13 16:48:23 2016 +0900 @@ -11,7 +11,7 @@ import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.operations.NetworkNodePath; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJournal; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.PersistentJungle;