Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 188:868a746996ad
minner change
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeNodeAttribute.java Fri Apr 17 22:12:44 2015 +0900 @@ -12,61 +12,56 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; -public class DefaultTreeNodeAttribute implements TreeNodeAttributes -{ - public List<TreeNode> children; - public TreeMap<String,ByteBuffer> attrs; - - - public DefaultTreeNodeAttribute(List<TreeNode> _children,TreeMap<String,ByteBuffer> _attrs) - { - children = _children; - attrs = _attrs; - } +public class DefaultTreeNodeAttribute implements TreeNodeAttributes { + public List<TreeNode> children; + public TreeMap<String, ByteBuffer> attrs; + + + public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<String, ByteBuffer> _attrs) { + children = _children; + attrs = _attrs; + } + + @Override + public TreeMap<String, ByteBuffer> getAttributesAsRawMap() { + return attrs; + } + + @Override + public Either<Error, TreeNode> delete(String _key) { + if (_key == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } + + if (null != attrs.getLoop(_key)) { + return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); + } - @Override - public TreeMap<String,ByteBuffer> getAttributesAsRawMap(){ - return attrs; - } - - @Override - public Either<Error,TreeNode> delete(String _key) - { - if (_key == null) { - return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); - } - - if (!attrs.contains(_key)) { - return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); - } - - TreeMap<String,ByteBuffer> newMap = attrs.delete(_key); - TreeNode newNode = new DefaultTreeNode(children,newMap); - return DefaultEither.newB(newNode); - } + TreeMap<String, ByteBuffer> newMap = attrs.delete(_key); + TreeNode newNode = new DefaultTreeNode(children, newMap); + return DefaultEither.newB(newNode); + } + + @Override + public Either<Error, TreeNode> put(String _key, ByteBuffer _value) { + if (_key == null || _value == null) { + return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); + } - @Override - public Either<Error,TreeNode> put(String _key, ByteBuffer _value) - { - if (_key == null || _value == null) { - return DefaultEither.newA(NodeEditorError.NULL_VALUE_NOT_ALLOWED); - } - - TreeMap<String,ByteBuffer> newMap = attrs.set(_key,_value); - TreeNode newNode = new DefaultTreeNode(children,newMap); - return DefaultEither.newB(newNode); - } + TreeMap<String, ByteBuffer> newMap = attrs.set(_key, _value); + TreeNode newNode = new DefaultTreeNode(children, newMap); + return DefaultEither.newB(newNode); + } - @Override - public ByteBuffer get(String _key) - { - if (_key == null) { - return null; - } - - ByteBuffer result = attrs.getLoop(_key); - return result; - } + @Override + public ByteBuffer get(String _key) { + if (_key == null) { + return null; + } + + ByteBuffer result = attrs.getLoop(_key); + return result; + } @Override public String getString(String key) { @@ -78,6 +73,6 @@ @Override public List<String> getKeys() { - return attrs.keys(); + return attrs.keys(); } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java Fri Apr 17 22:12:44 2015 +0900 @@ -3,7 +3,6 @@ import java.util.Iterator; import java.util.Optional; -import fj.Ord; import fj.data.List; import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NulIterator;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexCreater.java Fri Apr 17 22:12:44 2015 +0900 @@ -3,7 +3,6 @@ import java.util.Optional; import java.util.Stack; -import fj.Ord; import fj.data.List; import jp.ac.u_ryukyu.ie.cr.tatsuki.TreeMap.TreeMap; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Fri Apr 17 22:12:44 2015 +0900 @@ -5,7 +5,6 @@ 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.util.TreeMapOrd; -import fj.data.Option; import fj.data.TreeMap; public class ParentIndex { @@ -16,21 +15,9 @@ parentIndex = TreeMap.empty(TreeMapOrd.treeNodeOrd); } - public ParentIndex(TreeMap<TreeNode, TreeNode> parentIndex) { - this.parentIndex = parentIndex; - } - public boolean isEmpty(){ return parentIndex.isEmpty(); } - - public ParentIndex(ParentIndex parentIndex) { - this.parentIndex = parentIndex.getParentIndex(); - } - - public TreeMap<TreeNode, TreeNode> getParentIndex() { - return parentIndex; - } public TreeNode get(TreeNode child) { TreeNode parent = parentIndex.getLoop(child);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/JungleBenchMark.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/JungleBenchMark.java Fri Apr 17 22:12:44 2015 +0900 @@ -1,7 +1,6 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test; -import fj.Ord; -import fj.data.TreeMap; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; @@ -60,14 +59,13 @@ } File file = new File("./time/" + args[1] + "JungleTree" + args[0] + "Time"); - PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); - JungleBenchMarkThread readThread[] = null; for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { readThread = new JungleBenchMarkThread[THREAD_COUNT]; - JungleTree tree = null; + JungleTree tree; + if (args[0].equals("read")) { for (int count = 0; THREAD_COUNT > count; count++) { if (args[1].equals("separate"))
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java Fri Apr 17 22:12:44 2015 +0900 @@ -30,13 +30,6 @@ AbstractTreeMapThread readThread[] = null; - List<String> list = List.nil(); - if (args[0].equals("list")) { - for (int count = 0 ;count < 100 ; count++) { - list = list.cons(String.valueOf(count)); - } - } - for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) { readThread = new AbstractTreeMapThread[THREAD_COUNT]; @@ -58,10 +51,6 @@ for (int count = 0; THREAD_COUNT > count; count++) { readThread[count] = new FJTreeMapGetIteratorThread(map); } - } else if (args[0].equals("list")) { - for (int count = 0; THREAD_COUNT > count; count++) { - readThread[count] = new FJListAccessThread(Option.<List<String>>some(list)); - } } else{ System.out.println("not allow args"); System.exit(0);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findTreeAttributeThread.java Mon Mar 30 12:14:35 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/findTreeAttributeThread.java Fri Apr 17 22:12:44 2015 +0900 @@ -3,7 +3,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; - import java.util.Iterator; /** @@ -12,14 +11,12 @@ public class findTreeAttributeThread extends JungleBenchMarkThread { JungleTree tree; - //InterfaceTraverser traverser; private long findCount; boolean loop = true; public findTreeAttributeThread(JungleTree tree) { this.tree = tree; - // this.traverser = tree.getTraverser(true); this.findCount = 0; } @@ -36,9 +33,8 @@ @Override public void run() { while (loop) { - InterfaceTraverser traverser = tree.getTraverser(false); + InterfaceTraverser traverser = tree.getTraverser(true); Iterator<TreeNode> it = traverser.find(null, "key", "0"); - if (it.hasNext()) { findCount++; }