Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 112:98e256d9fd57
treeAttribute add get String but has error
author | one |
---|---|
date | Mon, 15 Sep 2014 16:31:53 +0900 |
parents | 5df5505e1c1e |
children | 6a35bd6e5887 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Attributes.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/Query.java |
diffstat | 6 files changed, 26 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Attributes.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/core/Attributes.java Mon Sep 15 16:31:53 2014 +0900 @@ -5,4 +5,5 @@ public interface Attributes { public ByteBuffer get(String key); + public String getString(String key); }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/DefaultTreeEditor.java Mon Sep 15 16:31:53 2014 +0900 @@ -26,7 +26,6 @@ public Either<Error,Logging> edit(TreeNode root,NodePath path,NodeEditor editor) { DefaultEvaluator e = new DefaultEvaluator(path); - //TraversableNodeWrapper<T> wrap = new TraversableNodeWrapper<T>(_root); Either<Error, Traversal> either = traverser.traverse(root,e); if(either.isA()){
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java Mon Sep 15 16:31:53 2014 +0900 @@ -34,6 +34,11 @@ private final TreeEditor editor; private final TreeOperationLog log; + public DefaultJungleTreeEditor(TreeNode root) + { + this(root,txManager,_editor,new DefaultTreeOperationLog()); + } + public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor) { this(_root,_txManager,_editor,new DefaultTreeOperationLog()); @@ -49,7 +54,6 @@ private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) { - //LoggingNodeHook hook = new LoggingNodeHook(_e); Either<Error,Logging> either = editor.edit(root,_path,_e); if(either.isA()){ return DefaultEither.newA(either.a());
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Mon Sep 15 16:31:53 2014 +0900 @@ -44,11 +44,11 @@ @Override public Either<Error,TreeNode> delete(String _key) { - if(_key == null){ + if (_key == null) { return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - if(!attrs.contains(_key)){ + if (!attrs.contains(_key)) { return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } @@ -60,14 +60,10 @@ @Override public Either<Error,TreeNode> put(String _key, ByteBuffer _value) { - if(_key == null || _value == null){ + if (_key == null || _value == null) { return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - //DefaultAttributes attrs = wrap.getAttributes(); - //DefaultChildren children = wrap.getChildren(); - - //TreeMap<String,ByteBuffer> raw = attrs.getAttributesAsRawMap(); TreeMap<String,ByteBuffer> newMap = attrs.set(_key,_value); TreeNode newNode = new DefaultTreeNode(children,newMap); return DefaultEither.newB(newNode); @@ -76,11 +72,19 @@ @Override public ByteBuffer get(String _key) { - if(_key == null){ + if (_key == null) { return null; } Option<ByteBuffer> result = attrs.get(_key); return result.isSome() ? result.some() : null; } + + @Override + public String getString(String key) { + ByteBuffer attribute = get(key); + if (attribute != null) + return new String(attribute.array()); + return null; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Mon Sep 15 16:31:53 2014 +0900 @@ -2,6 +2,7 @@ import java.util.Iterator; +import fj.Ord; import fj.data.List; import fj.data.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; @@ -17,12 +18,18 @@ import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.UpdateQuery; public class InterfaceTraverser { + InterfaceTraverser traverser; - TreeNode node; TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index; JungleTreeEditor editor; + public InterfaceTraverser(TreeNode _root, JungleTreeEditor editor) { + this.node = _root; + this.index = TreeMap.empty(Ord.stringOrd); + this.editor = editor; + } + public InterfaceTraverser(TreeNode _root, TreeMap<String, TreeMap<String, List<Pair<TreeNode, NodePath>>>> index, JungleTreeEditor editor) { this.node = _root; this.index = index;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/Query.java Mon Sep 15 14:07:06 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/query/Query.java Mon Sep 15 16:31:53 2014 +0900 @@ -6,7 +6,6 @@ public interface Query { boolean condition(TreeNode _node); - List<Pair<String,String>> indexCondition(); //attribute name ,attribute value }