Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 67:7aa195d5bdab
remove DefaultNode (error)
author | one |
---|---|
date | Fri, 18 Jul 2014 20:51:23 +0900 |
parents | 0c4a0a1c2f7f |
children | e0270d3640f8 d8e7f6e13169 |
files | memo.txt src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultChildren.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java |
diffstat | 4 files changed, 36 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/memo.txt Mon Jun 16 16:47:12 2014 +0900 +++ b/memo.txt Fri Jul 18 20:51:23 2014 +0900 @@ -1,3 +1,16 @@ +Fri Jul 18 19:59:20 JST 2014 + + servletから最初にBoardNameをKeyにTreeを持ってくる + ここでConcarentHashMapを使っているが、Jungleそのものを使うことが可能である + 名前とTreeRootの組からなるNodeを持つTreeを作る + この木は名前でバランスさせる + 変更したらそのRootを伝播させる + Rootはatomicな変数で持つ + + 問題は、この名前と木の対応を誰が持つか + 1Nodeで1つにするかThread毎に別に持つ、全体に1つでも問題ない? + + 2012/06/11 ・誰が Editor を提供する API を保持するべきか? ・Editor の役割
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultChildren.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultChildren.java Fri Jul 18 20:51:23 2014 +0900 @@ -13,9 +13,9 @@ public class DefaultChildren implements Children<Node> { - private final List<DefaultNode> children; + private final List<Node> children; - public DefaultChildren(List<DefaultNode> _children) + public DefaultChildren(List<Node> _children) { children = _children; } @@ -77,7 +77,7 @@ @Override public Either<Error,Node> at(int _pos) { - DefaultNode target = children.index(_pos); + Node target = children.index(_pos); if(target == null){ return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); // TODO } @@ -86,7 +86,7 @@ return DefaultEither.newB(ret); } - public List<DefaultNode> getChildrenAsRawList() + public List<Node> getChildrenAsRawList() { return children; } @@ -94,6 +94,6 @@ @Override public Iterator<Node> iterator() { - return (new IterableWrapper<Node>(children)).iterator(); + return children.iterator(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultNode.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultNode.java Fri Jul 18 20:51:23 2014 +0900 @@ -8,10 +8,10 @@ public class DefaultNode implements Node { - public List<DefaultNode> children; + public List<Node> children; public TreeMap<String,ByteBuffer> attrs; - private static final List<DefaultNode> NIL_LIST = List.nil(); + private static final List<Node> NIL_LIST = List.nil(); private static final TreeMap<String,ByteBuffer> NIL_MAP = TreeMap.empty(Ord.stringOrd); public DefaultNode() @@ -19,7 +19,7 @@ this(NIL_LIST,NIL_MAP); } - public DefaultNode(List<DefaultNode> _children,TreeMap<String,ByteBuffer> _attrs) + public DefaultNode(List<Node> _children,TreeMap<String,ByteBuffer> _attrs) { attrs = _attrs; children = _children;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Mon Jun 16 16:47:12 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeChildren.java Fri Jul 18 20:51:23 2014 +0900 @@ -2,9 +2,11 @@ import java.nio.ByteBuffer; import java.util.Iterator; + import fj.P2; import fj.data.List; import fj.data.TreeMap; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultAttributes; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultChildren; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNode; @@ -53,11 +55,11 @@ DefaultChildren children = node.getChildren(); DefaultAttributes attrs = node.getAttributes(); - List<DefaultNode> raw = children.getChildrenAsRawList(); + List<Node> raw = children.getChildrenAsRawList(); - P2<List<DefaultNode>,List<DefaultNode>> split = raw.splitAt(_pos); - List<DefaultNode> newChildren = split._1().snoc(new DefaultNode()).append(split._2()); - DefaultNode newNode = new DefaultNode(newChildren,attrs.getAttributesAsRawMap()); + P2<List<Node>,List<Node>> split = raw.splitAt(_pos); + List<Node> newChildren = split._1().snoc(new DefaultNode()).append(split._2()); + Node newNode = new DefaultNode(newChildren,attrs.getAttributesAsRawMap()); return DefaultEither.newB(new DefaultTreeNode(newNode)); } @@ -70,10 +72,10 @@ } DefaultChildren chs = node.getChildren(); - List<DefaultNode> raw = chs.getChildrenAsRawList(); + List<Node> raw = chs.getChildrenAsRawList(); - P2<List<DefaultNode>,List<DefaultNode>> split = raw.splitAt(_pos); - List<DefaultNode> newChildren = split._1().append(split._2().tail()); + P2<List<Node>,List<Node>> split = raw.splitAt(_pos); + List<Node> newChildren = split._1().append(split._2().tail()); DefaultAttributes attrs = node.getAttributes(); TreeMap<String, ByteBuffer> map = attrs.getAttributesAsRawMap(); @@ -100,7 +102,7 @@ } }; - List<DefaultNode> raw = node.getChildren().getChildrenAsRawList(); + List<Node> raw = node.getChildren().getChildrenAsRawList(); return new IterableConverter<DefaultTreeNode,DefaultNode>(raw,converter).iterator(); } @@ -141,14 +143,14 @@ if(!boundaryCheck(_pos) || _pos < 0){ return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); } - DefaultNode newChild = _newChild.getWrap(); + Node newChild = _newChild.getWrap(); - List<DefaultNode> raw = node.getChildren().getChildrenAsRawList(); + List<Node> raw = node.getChildren().getChildrenAsRawList(); TreeMap<String, ByteBuffer> rawMap = node.getAttributes().getAttributesAsRawMap(); - P2<List<DefaultNode>,List<DefaultNode>> split = raw.splitAt(_pos); - List<DefaultNode> newChildren = split._1().snoc(newChild).append(split._2()); - DefaultNode newNode = new DefaultNode(newChildren,rawMap); + P2<List<Node>,List<DefaultNode>> split = raw.splitAt(_pos); + List<Node> newChildren = split._1().snoc(newChild).append(split._2()); + Node newNode = new DefaultNode(newChildren,rawMap); return DefaultEither.newB(new DefaultTreeNode(newNode)); }