# HG changeset patch
# User one
# Date 1410500229 -32400
# Node ID bed3afd5c2e28502cc6b6f51be32c0ce421abb37
# Parent c297f0015d9e548cbe611fd4140456d891b34980
add Index but Not use
diff -r c297f0015d9e -r bed3afd5c2e2 document/JungleMindmap.mm
--- a/document/JungleMindmap.mm Thu Sep 11 16:38:26 2014 +0900
+++ b/document/JungleMindmap.mm Fri Sep 12 14:37:09 2014 +0900
@@ -91,7 +91,7 @@
-
+
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java Fri Sep 12 14:37:09 2014 +0900
@@ -21,6 +21,7 @@
private final ChangeListWriter writer;
private final TreeEditor editor;
Pair,TreeMap> index;
+
public DefaultJungleTree(TreeContext _tc,String _uuid,ChangeListWriter _writer,TreeEditor _editor, Pair,TreeMap> index)
{
this.repository = new AtomicReservableReference(_tc);
@@ -36,7 +37,7 @@
TreeContext tc = repository.get();
DefaultTransactionManager txManager = new DefaultTransactionManager(writer,tc,repository,uuid);
TreeNode root = tc.getTreeNode();
- return new DefaultJungleTreeEditor(root,txManager,editor, index);
+ return new DefaultJungleTreeEditor(root,txManager,editor);
}
@Override
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,6 +1,7 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store;
+import fj.data.List;
import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
@@ -17,6 +18,6 @@
public String getTreeName();
public long revision();
- public Pair,TreeMap> getIndex();
+ public TreeMap> getIndex();
public Iterable getOperations();
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeEditor.java Fri Sep 12 14:37:09 2014 +0900
@@ -7,8 +7,9 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public interface TreeEditor
{
- public Either edit(TreeNode _root,NodePath _path,NodeEditor _transformer);
+ public Either edit(TreeNode _root,NodePath _path,NodeEditor _transformer);
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Fri Sep 12 14:37:09 2014 +0900
@@ -12,6 +12,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class DefaultTreeEditor implements TreeEditor
{
@@ -23,7 +24,7 @@
}
@Override
- public Either edit(TreeNode _root,NodePath _path,NodeEditor _editor)
+ public Either edit(TreeNode _root,NodePath _path,NodeEditor _editor)
{
DefaultEvaluator e = new DefaultEvaluator(_path);
//TraversableNodeWrapper wrap = new TraversableNodeWrapper(_root);
@@ -34,12 +35,12 @@
}
Traversal t = either.b();
- Either ret = clone(t,_editor);
+ Either ret = clone(t,_editor);
return ret;
}
- private Either clone(Traversal _t,NodeEditor _editor)
+ private Either clone(Traversal _t,NodeEditor _editor)
{
// copying nodes from bottom to root
@@ -52,13 +53,12 @@
Direction targetDirection = path.head();
TreeNode target = targetDirection.getTarget();
//EditableNodeWrapper wrapper = new EditableNodeWrapper(target);
- LoggingNode Logging = new LoggingNode(target);
- Either either = _editor.edit(Logging);
+ Either either = _editor.edit(target);
if(either.isA()){
return DefaultEither.newA(either.a());
}
- LoggingNode newWrap = either.b();
+ Logging newWrap = either.b();
// top
int pos = targetDirection.getPosition();
@@ -77,6 +77,7 @@
}
TreeNode newRoot = child;
- return DefaultEither.newB(new LoggingNode(newRoot,newWrap.getOperationLog()));
+ Logging logNode = _editor.wrap(newRoot,newWrap.getOperationLog());
+ return DefaultEither.newB(logNode);
}
}
\ No newline at end of file
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java Fri Sep 12 14:37:09 2014 +0900
@@ -10,6 +10,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class LoggingAttributes //implements EditableAttributes
{
@@ -28,7 +29,7 @@
return attributes.get(_key);
}
- private Either edit(NodeOperation _op)
+ private Either edit(NodeOperation _op)
{
Either either = _op.invoke(wrap);
if(either.isA()){
@@ -37,19 +38,19 @@
TreeNode newNode = either.b();
OperationLog newLog = log.add(_op);
- LoggingNode newLoggingNode = new LoggingNode(newNode,newLog);
+ Logging newLogNode = new LoggingNode(newNode,newLog);
- return DefaultEither.newB(newLoggingNode);
+ return DefaultEither.newB(newLogNode);
}
- public Either delete(final String _key)
+ public Either delete(final String _key)
{
DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key);
return edit(deleteAttribute);
}
- public Either put(final String _key,final ByteBuffer _value)
+ public Either put(final String _key,final ByteBuffer _value)
{
PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value);
return edit(putAttribute);
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java Fri Sep 12 14:37:09 2014 +0900
@@ -10,6 +10,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class LoggingChildren //implements EditableChildren
{
@@ -36,7 +37,7 @@
return children.iterator();
}*/
- public Either edit(NodeOperation _op)
+ public Either edit(NodeOperation _op)
{
Either either = _op.invoke(wrap);
if(either.isA()){
@@ -45,23 +46,23 @@
TreeNode newWrap = either.b();
OperationLog newLog = log.add(_op);
- LoggingNode newLoggingNode = new LoggingNode(newWrap,newLog);
+ Logging newLoggingNode = new LoggingNode(newWrap,newLog);
return DefaultEither.newB(newLoggingNode);
}
- public Either addNewChildAt(final int _pos)
+ public Either addNewChildAt(final int _pos)
{
NodeOperation addNewChildAt = new AppendChildAtOperation(_pos);
return edit(addNewChildAt);
}
- public Either deleteChildAt(final int _pos)
+ public Either deleteChildAt(final int _pos)
{
NodeOperation deleteChildAt = new DeleteChildAtOperation(_pos);
return edit(deleteChildAt);
}
- public Either at(int _pos)
+ public Either at(int _pos)
{
Children children = wrap.getChildren();
Either either = children.at(_pos);
@@ -70,6 +71,7 @@
}
TreeNode node = either.b();
- return DefaultEither.newB(new LoggingNode(node));
+ Logging logNode = new LoggingNode(node);
+ return DefaultEither.newB(logNode);
}
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingNode.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingNode.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingNode.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,9 +1,12 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
-public class LoggingNode
+public class LoggingNode implements Logging
{
public LoggingNode(TreeNode _wrap)
{
@@ -19,23 +22,32 @@
private final TreeNode wrap;
private final OperationLog log;
+ @Override
public LoggingAttributes getAttributes()
{
return new LoggingAttributes(wrap,log);
}
+ @Override
public LoggingChildren getChildren()
{
return new LoggingChildren(wrap,log);
}
+ @Override
public OperationLog getOperationLog()
{
return log;
}
+ @Override
public TreeNode getWrap()
{
return wrap;
}
+
+ @Override
+ public TreeMap> getIndex() {
+ return null;
+ }
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/AppendChildAt.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/AppendChildAt.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/AppendChildAt.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,5 +1,7 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
@@ -9,26 +11,46 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class AppendChildAt implements NodeEditor
{
private final int pos;
- private OperationLog log;
public AppendChildAt(int _pos)
{
pos = _pos;
- log = new DefaultOperationLog();
}
- @Override
- public Either edit(LoggingNode _e)
+ public Either _edit(Logging _e)
{
- Either either = _e.getChildren().addNewChildAt(pos);
+ Either either = _e.getChildren().addNewChildAt(pos);
if(either.isA()){
// error
return either;
}
return DefaultEither.newB(either.b());
}
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ public Logging wrap(TreeNode node) {
+ return new LoggingNode(node);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingNode(node, op);
+ }
+
+ @Override
+ public TreeMap> getIndex() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteAttribute.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteAttribute.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteAttribute.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,33 +1,51 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class DeleteAttribute implements NodeEditor
{
private final String key;
- private OperationLog log;
public DeleteAttribute(String _key)
{
key = _key;
- log = new DefaultOperationLog();
}
- @Override
- public Either edit(LoggingNode _e)
+ public Either _edit(Logging logNode)
{
- Either either = _e.getAttributes().delete(key);
+ Either either = logNode.getAttributes().delete(key);
if(either.isA()){
// error
return either;
}
return DefaultEither.newB(either.b());
}
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+ public Logging wrap(TreeNode node) {
+ return new LoggingNode(node);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingNode(node, op);
+ }
+
+ @Override
+ public TreeMap> getIndex() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteChildAt.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteChildAt.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/DeleteChildAt.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,5 +1,7 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
@@ -9,6 +11,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class DeleteChildAt implements NodeEditor
{
@@ -18,14 +21,34 @@
pos = _pos;
}
- @Override
- public Either edit(LoggingNode _e)
+ public Either _edit(Logging logNode)
{
- Either either = _e.getChildren().deleteChildAt(pos);
+ Either either = logNode.getChildren().deleteChildAt(pos);
if(either.isA()){
// error
return either;
}
return DefaultEither.newB(either.b());
}
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ public Logging wrap(TreeNode node) {
+ return new LoggingNode(node);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingNode(node, op);
+ }
+
+ @Override
+ public TreeMap> getIndex() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/NodeEditor.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/NodeEditor.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/NodeEditor.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,13 +1,19 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer;
+import fj.data.List;
import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public interface NodeEditor
{
- public Either edit(LoggingNode _e);
+ public Either edit(TreeNode _e);
+ public Logging wrap(TreeNode node, OperationLog op);
+ public TreeMap> getIndex();
}
\ No newline at end of file
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/PutAttribute.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/PutAttribute.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/trasnformer/PutAttribute.java Fri Sep 12 14:37:09 2014 +0900
@@ -2,6 +2,8 @@
import java.nio.ByteBuffer;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
@@ -13,6 +15,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class PutAttribute implements NodeEditor
{
@@ -25,14 +28,34 @@
value = _value;
}
- @Override
- public Either edit(LoggingNode _e)
+ public Either _edit(Logging _e)
{
- Either either = _e.getAttributes().put(key,value);
+ Either either = _e.getAttributes().put(key,value);
if(either.isA()){
// error
return either;
}
return DefaultEither.newB(either.b());
}
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ public Logging wrap(TreeNode node) {
+ return new LoggingNode(node);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingNode(node, op);
+ }
+
+ @Override
+ public TreeMap> getIndex() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,11 +1,11 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction;
+import fj.data.List;
import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
public class DefaultChangeSet implements ChangeSet
{
@@ -15,9 +15,9 @@
private final String uuid;
private final String treeName;
private final long revision;
- private final Pair,TreeMap> index;
+ private final TreeMap> index;
- public DefaultChangeSet(TreeNode _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision, Pair,TreeMap> index)
+ public DefaultChangeSet(TreeNode _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision, TreeMap> index)
{
this.root = _node;
this.previous = _prev;
@@ -71,7 +71,7 @@
}
@Override
- public Pair, TreeMap> getIndex() {
+ public TreeMap> getIndex() {
return index;
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Fri Sep 12 14:37:09 2014 +0900
@@ -2,6 +2,7 @@
import java.nio.ByteBuffer;
+import fj.data.List;
import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
@@ -24,6 +25,7 @@
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
public class DefaultJungleTreeEditor implements JungleTreeEditor
{
@@ -31,31 +33,29 @@
private final TreeNode root;
private final TreeEditor editor;
private final TreeOperationLog log;
- private Pair,TreeMap> index;
- public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor, Pair,TreeMap> index)
+ public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor)
{
- this(_root,_txManager,_editor,new DefaultTreeOperationLog(), index);
+ this(_root,_txManager,_editor,new DefaultTreeOperationLog());
}
- public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager _txManager,TreeEditor _editor,TreeOperationLog _log, Pair,TreeMap> index)
+ public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager _txManager,TreeEditor _editor,TreeOperationLog _log)
{
this.root = newNode;
this.txManager = _txManager;
this.editor = _editor;
this.log = _log;
- this.index = index;
}
private Either _edit(final NodePath _path,NodeEditor _e)
{
//LoggingNodeHook hook = new LoggingNodeHook(_e);
- Either either = editor.edit(root,_path,_e);
+ Either either = editor.edit(root,_path,_e);
if(either.isA()){
return DefaultEither.newA(either.a());
}
- LoggingNode newLogging = either.b();
+ Logging newLogging = either.b();
OperationLog newLog = newLogging.getOperationLog();
TreeNode newNode = newLogging.getWrap();
@@ -70,7 +70,7 @@
DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length());
TreeOperationLog newTreeOpLog = log.append(treeOperationLog);
- JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog, index);
+ JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog);
return DefaultEither.newB(newEditor);
}
@@ -111,13 +111,13 @@
@Override
public Either success()
{
- Either either = txManager.commit(root,log);
+ Either either = txManager.commit(root,log,null);
if(either.isA()){
return DefaultEither.newA(either.a());
}
TransactionManager newTxManager = either.b();
- JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor(root,newTxManager,editor, index);
+ JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor(root,newTxManager,editor);
return DefaultEither.newB(newTreeEditor);
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,6 +1,9 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction;
import java.util.Iterator;
+
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result;
@@ -31,7 +34,7 @@
}
@Override
- public Either commit(TreeNode _newRoot,final TreeOperationLog _log)
+ public Either commit(TreeNode _newRoot,final TreeOperationLog _log, TreeMap> index)
{
ChangeSet cs = tip.getChangeSet();
long currentRevision = cs.revision();
@@ -53,7 +56,7 @@
}
};
- DefaultChangeSet newCs = new DefaultChangeSet(_newRoot,cs,list,uuid, _treeName, nextRevision,null);
+ DefaultChangeSet newCs = new DefaultChangeSet(_newRoot,cs,list,uuid, _treeName, nextRevision,index);
DefaultTreeContext newContext = new DefaultTreeContext(_newRoot,newCs);
@SuppressWarnings("rawtypes")
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/TransactionManager.java Fri Sep 12 14:37:09 2014 +0900
@@ -1,5 +1,7 @@
package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction;
+import fj.data.List;
+import fj.data.TreeMap;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.TreeOperationLog;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
@@ -7,7 +9,7 @@
public interface TransactionManager
{
- public Either commit(TreeNode _newRoot,TreeOperationLog _log);
+ public Either commit(TreeNode _newRoot,TreeOperationLog _log, TreeMap> index);
public String getUUID();
public long getRevision();
}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Thu Sep 11 16:38:26 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Fri Sep 12 14:37:09 2014 +0900
@@ -60,6 +60,7 @@
* public List> distinct(String _key ,String...
* _attribute){ return null; }
*/
+
public JungleTreeEditor update(final UpdateQuery query) {
Iterator> findNode = find(query);
//do {
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/AppendChildAtIndex.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/AppendChildAtIndex.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,38 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.AppendChildAt;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+
+public class AppendChildAtIndex extends AppendChildAt {
+
+ private TreeMap> index;
+
+ public AppendChildAtIndex(int _pos, TreeMap> index) {
+ super(_pos);
+ this.index = index;
+
+ }
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node) {
+ return new LoggingIndexNode(node, index);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingIndexNode(node, op, index);
+ }
+
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/DeleteAttributeIndex.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/DeleteAttributeIndex.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,37 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+
+public class DeleteAttributeIndex extends DeleteAttribute {
+
+ TreeMap> index;
+ private String key;
+ public DeleteAttributeIndex(String _key ,TreeMap> index) {
+ super(_key);
+ this.key = key;
+ this.index = index;
+ }
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node) {
+ return new LoggingIndexNode(node, index);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingIndexNode(node, op, index);
+ }
+
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/DeleteChildAtIndex.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/DeleteChildAtIndex.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,35 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteChildAt;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+
+public class DeleteChildAtIndex extends DeleteChildAt{
+
+ private TreeMap> index;
+ public DeleteChildAtIndex(int _pos, TreeMap> index) {
+ super(_pos);
+ this.index = index;
+ }
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node) {
+ return new LoggingIndexNode(node, index);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingIndexNode(node, op, index);
+ }
+
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/Logging.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/Logging.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,17 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingAttributes;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingChildren;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+
+public interface Logging {
+
+ public LoggingAttributes getAttributes();
+ public LoggingChildren getChildren();
+ public OperationLog getOperationLog();
+ public TreeNode getWrap();
+ public TreeMap> getIndex();
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/LoggingIndexAttributes.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/LoggingIndexAttributes.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,79 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import java.nio.ByteBuffer;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingAttributes;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+
+public class LoggingIndexAttributes extends LoggingAttributes {
+
+ private final TreeNode wrap;
+ private final OperationLog log;
+ private TreeMap> index;
+
+ public LoggingIndexAttributes(TreeNode _wrap, OperationLog _log, TreeMap> index) {
+ super(_wrap, _log);
+ this.wrap = _wrap;
+ this.log = _log;
+ this.index = index;
+ }
+
+ private Either edit(NodeOperation _op)
+ {
+ Either either = _op.invoke(wrap);
+ if(either.isA()){
+ return DefaultEither.newA(either.a());
+ }
+
+ TreeNode newNode = either.b();
+ OperationLog newLog = log.add(_op);
+ Logging newLogNode = new LoggingNode(newNode,newLog);
+
+ return DefaultEither.newB(newLogNode);
+ }
+
+ public Either delete(final String key)
+ {
+ DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(key);
+ Either either = edit(deleteAttribute);
+
+ if(either.isA())
+ return either;
+
+ Logging logNode = either.b();
+ TreeNode node = logNode.getWrap();
+ OperationLog log = logNode.getOperationLog();
+ index = index.delete(key);
+ Logging logIndexNode = new LoggingIndexNode(node, log, index);
+ return DefaultEither.newB(logIndexNode);
+ }
+
+ public Either put(final String key,final ByteBuffer value)
+ {
+ PutAttributeOperation putAttribute = new PutAttributeOperation(key,value);
+ Either either = edit(putAttribute);
+ if(either.isA())
+ return either;
+
+ Logging logNode = either.b();
+ TreeNode newNode = logNode.getWrap();
+ OperationLog newLog = logNode.getOperationLog();
+ String indexKey = new String(value.array());
+ List list = index.get(indexKey).some();
+ list = list.cons(newNode);
+ index.set(indexKey, list);
+ Logging logIndexNode = new LoggingIndexNode(newNode, newLog, index);
+ return DefaultEither.newB(logIndexNode);
+ }
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/LoggingIndexNode.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/LoggingIndexNode.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,50 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import fj.data.List;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingAttributes;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingChildren;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair;
+
+public class LoggingIndexNode extends LoggingNode {
+
+
+ private final TreeNode wrap;
+ private final OperationLog log;
+ private TreeMap> index;
+
+ public LoggingIndexNode(TreeNode wrap ,TreeMap> index)
+ {
+ this(wrap,new DefaultOperationLog(),index);
+ }
+
+ public LoggingIndexNode(TreeNode wrap,OperationLog log, TreeMap> index)
+ {
+ super(wrap, log);
+ this.wrap = wrap;
+ this.log = log;
+ }
+
+ @Override
+ public TreeMap> getIndex(){
+ return index;
+ }
+
+ @Override
+ public LoggingAttributes getAttributes()
+ {
+ return new LoggingAttributes(wrap,log);
+ }
+
+ @Override
+ public LoggingChildren getChildren()
+ {
+ return new LoggingChildren(wrap,log);
+ }
+
+
+}
diff -r c297f0015d9e -r bed3afd5c2e2 src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/PutAttributeIndex.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/PutAttributeIndex.java Fri Sep 12 14:37:09 2014 +0900
@@ -0,0 +1,49 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index;
+
+import java.nio.ByteBuffer;
+
+import fj.data.List;
+import fj.data.Option;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.LoggingNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+
+public class PutAttributeIndex extends PutAttribute {
+
+ private final String key;
+ private final ByteBuffer value;
+ private TreeMap> index;
+ public PutAttributeIndex(String _key,ByteBuffer _value, TreeMap>index)
+ {
+ super(_key, _value);
+ key = _key;
+ value = _value;
+ this.index = index;
+ }
+
+ @Override
+ public Either edit(TreeNode _e) {
+ Logging logNode = wrap(_e);
+ return _edit(logNode);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node) {
+ return new LoggingIndexNode(node, index);
+ }
+
+ @Override
+ public Logging wrap(TreeNode node, OperationLog op) {
+ return new LoggingIndexNode(node, op, index);
+ }
+
+ @Override
+ public TreeMap> getIndex(){
+ return index;
+ }
+}