Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 93:ef68358ed0e8
Merge with 7058e85875a59d1951cc5eeaa049e4788ea96deb
line wrap: on
line diff
--- a/document/JungleMindmap.mm Sat Sep 06 05:03:10 2014 +0900 +++ b/document/JungleMindmap.mm Sat Sep 06 10:18:47 2014 +0900 @@ -1,6 +1,17 @@ <map version="1.0.1"> <!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net --> -<node CREATED="1409726078288" ID="ID_647478089" MODIFIED="1409726241496" TEXT="New Mindmap"> +<node CREATED="1409726078288" ID="ID_647478089" MODIFIED="1409912802514"> +<richcontent TYPE="NODE"><html> + <head> + + </head> + <body> + <p> + Jungle + </p> + </body> +</html> +</richcontent> <node CREATED="1409726154557" ID="ID_751550789" MODIFIED="1409726198467" POSITION="right" TEXT="スケジュール"> <node CREATED="1409726169906" HGAP="21" ID="ID_1745036704" MODIFIED="1409726235708" TEXT="9/15永山さん来沖" VSHIFT="-5"/> <node CREATED="1409726198468" HGAP="21" ID="ID_41465836" MODIFIED="1409726228823" TEXT="9/18PCIプレゼンテーョン" VSHIFT="6"/> @@ -18,20 +29,80 @@ <node CREATED="1409726480115" ID="ID_1560015410" MODIFIED="1409726505822" TEXT="なのでJungleをAVLに"/> <node CREATED="1409726517683" ID="ID_1128117081" MODIFIED="1409726532614" TEXT="更新をatomicにしなくて大丈夫か?"/> </node> +<node CREATED="1409906422242" ID="ID_92678336" MODIFIED="1409907291863" TEXT="Logを取るノードと取らないNodeを分ける" VSHIFT="81"> +<node CREATED="1409907299090" ID="ID_156102389" MODIFIED="1409907325388" TEXT="LoggingをするEditor"/> +<node CREATED="1409907325760" ID="ID_1693431989" MODIFIED="1409907338580" TEXT="Indexを更新するEditor"/> +<node CREATED="1409907339120" ID="ID_1167306471" MODIFIED="1409907353179" TEXT="Nodeを更新するだけのEditor"/> </node> -<node CREATED="1409726560355" HGAP="80" ID="ID_1680643421" MODIFIED="1409727171007" TEXT="Aliceの部分でIOとは別にして優先度を上げる" VSHIFT="8"> -<node CREATED="1409726580851" ID="ID_70332820" MODIFIED="1409726587062" TEXT="ログの書き出しも"/> +</node> +<node CREATED="1409726560355" HGAP="32" ID="ID_1680643421" MODIFIED="1409906495696" TEXT="Aliceの部分でIOとは別にして優先度を上げる" VSHIFT="13"> +<node CREATED="1409726580851" ID="ID_70332820" MODIFIED="1409906498998" TEXT="ログの書き出しも" VSHIFT="2"/> </node> <node CREATED="1409726600088" ID="ID_142965815" MODIFIED="1409727174343" TEXT="API" VSHIFT="18"> <node CREATED="1409726606857" ID="ID_405344625" MODIFIED="1409726622494" TEXT="基本的にパスでしかアクセスできないので"/> <node CREATED="1409726624219" ID="ID_1368915826" MODIFIED="1409726642662" TEXT="indexでアクセスできるようにしたい"> -<node CREATED="1409726651188" ID="ID_763950066" MODIFIED="1409726663822" TEXT="Indexの再構成が欲しい"/> +<node CREATED="1409726651188" ID="ID_763950066" MODIFIED="1409906505790" TEXT="Indexの再構成が欲しい" VSHIFT="2"/> </node> <node CREATED="1409726637570" ID="ID_1840769401" MODIFIED="1409726854710" TEXT="WEBからアクセスするAPIが欲しい"/> <node CREATED="1409726842808" ID="ID_823399931" MODIFIED="1409726997548" TEXT="KeyをForgetするAPI"> <node CREATED="1409726998097" ID="ID_1404724140" MODIFIED="1409727013630" TEXT=" mergeする可能性があるKeyだけ残す"/> </node> <node CREATED="1409726799739" ID="ID_1771872050" MODIFIED="1409727205486" TEXT="アクセスしたときに部分的に取ってくるAPIと部分的に取ってくるAPIが欲しい"/> +<node CREATED="1409908104921" ID="ID_515208912" MODIFIED="1409912737202" TEXT="検索のAPI"> +<node CREATED="1409908119601" ID="ID_308661535" MODIFIED="1409908142364" TEXT="getTraversaer"/> +<node CREATED="1409908143057" ID="ID_767737454" MODIFIED="1409912827805" TEXT="interface traverser"> +<node CREATED="1409912059464" ID="ID_1786348845" MODIFIED="1409912122574" TEXT="Attribute,nameの値が"kanagawa"であるものを探す"/> +<node CREATED="1409912127515" ID="ID_1936001294" MODIFIED="1409912138492" TEXT="count"> +<node CREATED="1409912143369" ID="ID_1101250261" MODIFIED="1409912287350" TEXT="Listがiteratorが返ってくる" VSHIFT="2"/> +</node> +<node CREATED="1409912195387" ID="ID_1677264420" MODIFIED="1409912237384"> +<richcontent TYPE="NODE"><html> + <head> + + </head> + <body> + <p> + oderBy + </p> + </body> +</html> +</richcontent> +<node CREATED="1409912215937" ID="ID_591908705" MODIFIED="1409912282134" TEXT="" VSHIFT="2"/> +</node> +<node CREATED="1409912254809" ID="ID_1535341119" MODIFIED="1409912270524" TEXT="distinct"/> +<node CREATED="1409912297489" ID="ID_185517541" MODIFIED="1409912300012" TEXT="sum"/> +<node CREATED="1409912303321" ID="ID_1425057782" MODIFIED="1409912312172" TEXT="複数のTreeのTraverse"> +<node CREATED="1409912382240" ID="ID_1596998457" MODIFIED="1409912894126" TEXT="複数のTreeからAttribute,"name"の値が等しいもののリストを持ってくるプログラムを作ってくる(宿題)" VSHIFT="1"/> +</node> +</node> +<node CREATED="1409912823732" ID="ID_68210354" MODIFIED="1409912881846" TEXT="interfaceTraverserからIndexが必要なAttributeを取り出す(宿題)"/> +<node CREATED="1409908160464" ID="ID_541009496" MODIFIED="1409908289626"> +<richcontent TYPE="NODE"><html> + <head> + + </head> + <body> + <p> + output + </p> + </body> +</html> +</richcontent> +<node CREATED="1409908164657" ID="ID_994155079" MODIFIED="1409910871356" TEXT="NodeとPathのリストのiterater" VSHIFT="2"/> +</node> +<node CREATED="1409912737817" ID="ID_1598031941" MODIFIED="1409912768605" TEXT="indexを削除するAPI" VSHIFT="26"/> +</node> +<node CREATED="1409913383955" ID="ID_653968339" MODIFIED="1409913399484" TEXT="誰が検索したかを保存するAPI"/> +</node> +<node CREATED="1409906099431" HGAP="22" ID="ID_1697852268" MODIFIED="1409906130605" TEXT="indexをつける" VSHIFT="50"> +<node CREATED="1409906161185" HGAP="18" ID="ID_37822884" MODIFIED="1409912675141" TEXT="KeyとNodeのHashMapとAttribute"name"のHashMapを登録する" VSHIFT="-10"/> +<node CREATED="1409906200281" HGAP="21" ID="ID_957989771" MODIFIED="1409906786182" TEXT="各version毎にindeがある" VSHIFT="-14"/> +<node CREATED="1409906235377" HGAP="18" ID="ID_1286646129" MODIFIED="1409906798789" TEXT="indexはfjのTreeHashMapを使う" VSHIFT="-3"> +<node CREATED="1409912676387" ID="ID_1944162611" MODIFIED="1409912716086" TEXT="非破壊のindexを使いたい"/> +</node> +<node CREATED="1409906326546" HGAP="22" ID="ID_1269584258" MODIFIED="1409906815222" TEXT="indexはattributeとNodeの二つを用意する" VSHIFT="-5"/> +<node CREATED="1409906387306" HGAP="22" ID="ID_63715775" MODIFIED="1409906810134" TEXT="indexを共有するといい" VSHIFT="-6"/> +<node CREATED="1409906610393" HGAP="19" ID="ID_29204462" MODIFIED="1409906820222" TEXT="indexがAVLTreeなのでJungleはAVLTreeにしなくていい"/> </node> </node> <node CREATED="1409726668370" ID="ID_204371770" MODIFIED="1409726690172" POSITION="right" TEXT="Matrix"> @@ -42,7 +113,7 @@ <node CREATED="1409726724451" ID="ID_744658833" MODIFIED="1409726734998" TEXT="オペレーションをJungleがちゃんとサポートしているか"/> </node> </node> -<node CREATED="1409726752851" ID="ID_1096797544" MODIFIED="1409726764446" POSITION="left" TEXT="アシュアノート"> +<node CREATED="1409726752851" HGAP="28" ID="ID_1096797544" MODIFIED="1409907420179" POSITION="left" TEXT="AssureNode" VSHIFT="43"> <node CREATED="1409726765475" ID="ID_1507920801" MODIFIED="1409726773734" TEXT="Jungleとつなげる"/> <node CREATED="1409726774355" ID="ID_105345677" MODIFIED="1409726796814" TEXT="編集コマンドをjungleに翻訳する"/> </node>
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultAttributes.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultAttributes.java Sat Sep 06 10:18:47 2014 +0900 @@ -1,4 +1,4 @@ -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; +/*package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; import java.nio.ByteBuffer; @@ -26,7 +26,6 @@ return DefaultEither.newB(newNode); } - */ public TreeMap<String,ByteBuffer> getAttributesAsRawMap() { @@ -50,5 +49,5 @@ { return null; } - */ } +*/ \ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNode.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeNode.java Sat Sep 06 10:18:47 2014 +0900 @@ -1,6 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesContainer; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog; public interface TreeNode extends AttributesContainer { @@ -10,6 +11,9 @@ public TreeNodeAttributes getAttributes(); public TreeNode createNewNode(); - //public Node getAsNode(); + + public OperationLog getLog(); + + public void putLog(OperationLog _log); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNode.java Sat Sep 06 10:18:47 2014 +0900 @@ -6,25 +6,40 @@ 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.OperationLog; public class DefaultTreeNode implements TreeNode { //private final DefaultNode wrap; - public List<TreeNode> children; - public TreeMap<String,ByteBuffer> attrs; + private List<TreeNode> children; + private TreeMap<String,ByteBuffer> attrs; + private OperationLog log; private static final List<TreeNode> NIL_LIST = List.nil(); private static final TreeMap<String,ByteBuffer> NIL_MAP = TreeMap.empty(Ord.stringOrd); public DefaultTreeNode() { - this(NIL_LIST,NIL_MAP); + this(NIL_LIST,NIL_MAP,new DefaultOperationLog()); } public DefaultTreeNode(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs) { + this(_children, _attrs, new DefaultOperationLog()); + } + + public DefaultTreeNode(TreeNode _node, OperationLog _log) + { + this(_node.getChildren().getChildrenAsRawList(), _node.getAttributes().getAttributesAsRawMap(), _log); + } + + + + public DefaultTreeNode(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs, OperationLog _log){ attrs = _attrs; children = _children; + log = _log; } @Override @@ -36,7 +51,7 @@ @Override public DefaultTreeNodeAttribute getAttributes() { - return new DefaultTreeNodeAttribute(children, attrs); + return new DefaultTreeNodeAttribute(children, attrs,log); } @Override @@ -59,6 +74,17 @@ { return new DefaultTreeNode(children,attrs); } + + @Override + public OperationLog getLog() { + OperationLog _log = log; + log = new DefaultOperationLog(); + return _log; + } + @Override + public void putLog(OperationLog _log){ + log = _log; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Sat Sep 06 10:18:47 2014 +0900 @@ -7,6 +7,10 @@ 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; +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.PutAttributeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; @@ -16,11 +20,20 @@ { public List<TreeNode> children; public TreeMap<String,ByteBuffer> attrs; + OperationLog log ; public DefaultTreeNodeAttribute(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs) { children = _children; attrs = _attrs; + log = new DefaultOperationLog(); + } + + public DefaultTreeNodeAttribute(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs,OperationLog _log) + { + children = _children; + attrs = _attrs; + log = _log; } @Override @@ -41,8 +54,8 @@ TreeMap<String,ByteBuffer> newMap = attrs.delete(_key); - TreeNode newNode = new DefaultTreeNode(children,newMap); - + OperationLog op = new DefaultOperationLog();; + TreeNode newNode = new DefaultTreeNode(children,newMap,op.add(new DeleteAttributeOperation(_key))); return DefaultEither.newB(newNode); } @@ -58,8 +71,7 @@ //TreeMap<String,ByteBuffer> raw = attrs.getAttributesAsRawMap(); TreeMap<String,ByteBuffer> newMap = attrs.set(_key,_value); - - TreeNode newNode = new DefaultTreeNode(children,newMap); + TreeNode newNode = new DefaultTreeNode(children,newMap,log.add(new PutAttributeOperation(_key,_value))); return DefaultEither.newB(newNode); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Sat Sep 06 10:18:47 2014 +0900 @@ -8,6 +8,11 @@ import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeChildren; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditorError; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; @@ -26,7 +31,7 @@ public List<TreeNode> children; public TreeMap<String,ByteBuffer> attrs; - + public DefaultTreeNodeChildren(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs) { children = _children; @@ -54,12 +59,11 @@ return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); } - - P2<List<TreeNode>,List<TreeNode>> split = children.splitAt(_pos); List<TreeNode> newChildren = split._1().snoc(new DefaultTreeNode()).append(split._2()); - TreeNode newNode = new DefaultTreeNode(newChildren,attrs); - + OperationLog op = new DefaultOperationLog(); + TreeNode newNode = new DefaultTreeNode(newChildren,attrs,op.add(new AppendChildAtOperation(_pos))); + return DefaultEither.newB(newNode); } @@ -73,8 +77,8 @@ P2<List<TreeNode>,List<TreeNode>> split = children.splitAt(_pos); List<TreeNode> newChildren = split._1().append(split._2().tail()); - - TreeNode newNode = new DefaultTreeNode(newChildren,attrs); + OperationLog op = new DefaultOperationLog(); + TreeNode newNode = new DefaultTreeNode(newChildren,attrs,op.add(new DeleteChildAtOperation(_pos))); return DefaultEither.newB(newNode); }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java Sat Sep 06 05:03:10 2014 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/impl/node/DefaultAttributesTest.java Sat Sep 06 10:18:47 2014 +0900 @@ -10,11 +10,9 @@ import fj.data.Option; import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.AttributesTest; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNodeAttribute; public class DefaultAttributesTest extends AttributesTest {