Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 164:b81df9373a31 untilIndex
miner change
author | one |
---|---|
date | Mon, 08 Dec 2014 12:21:51 +0900 |
parents | 7c4fc8732eb4 |
children | a8d6ce27fc36 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexManager.java |
diffstat | 4 files changed, 137 insertions(+), 140 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Mon Dec 08 03:37:34 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java Mon Dec 08 12:21:51 2014 +0900 @@ -1,6 +1,7 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle; import java.util.Iterator; +import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import fj.data.List; @@ -11,6 +12,7 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +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.transaction.DefaultChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; @@ -21,71 +23,71 @@ import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Index; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex; -public class DefaultJungle implements Jungle -{ - private Journal journal; - private ConcurrentHashMap<String,JungleTree> trees; - private String uuid; - private TreeEditor editor; - public static void main(String args[]) - { - DefaultJungle j = new DefaultJungle(null,"hoge",new DefaultTreeEditor(new DefaultTraverser())); - JungleTree t = j.createNewTree("fuga"); - - JungleTreeEditor e1 = t.getTreeEditor(); - - DefaultNodePath root = new DefaultNodePath(); - - Either<Error,JungleTreeEditor> either = e1.addNewChildAt(root,0); - e1 = either.b(); - either = e1.addNewChildAt(root.add(0),0); - e1 = either.b(); - e1.success(); - } - - public DefaultJungle(Journal journal,String uuid,TreeEditor editor) - { - this.journal = new NullJournal(); - this.trees = new ConcurrentHashMap<String,JungleTree>(); - this.uuid = uuid; - this.editor = editor; - } +public class DefaultJungle implements Jungle { + private Journal journal; + private ConcurrentHashMap<String, JungleTree> trees; + private String uuid; + private TreeEditor editor; + + public static void main(String args[]) { + DefaultJungle j = new DefaultJungle(null, "hoge", + new DefaultTreeEditor(new DefaultTraverser())); + JungleTree t = j.createNewTree("fuga"); + + JungleTreeEditor e1 = t.getTreeEditor(); + + DefaultNodePath root = new DefaultNodePath(); + + Either<Error, JungleTreeEditor> either = e1.addNewChildAt(root, 0); + e1 = either.b(); + either = e1.addNewChildAt(root.add(0), 0); + e1 = either.b(); + e1.success(); + } + + public DefaultJungle(Journal journal, String uuid, TreeEditor editor) { + this.journal = new NullJournal(); + this.trees = new ConcurrentHashMap<String, JungleTree>(); + this.uuid = uuid; + this.editor = editor; + } + + @Override + public JungleTree getTreeByName(String name) { + return trees.get(name); + } - @Override - public JungleTree getTreeByName(String name) - { - return trees.get(name); - } + @Override + public JungleTree createNewTree(final String name) { + ChangeList list = new ChangeList() { + @Override + public Iterator<TreeOperation> iterator() { + List<TreeOperation> nil = List.nil(); + return nil.iterator(); + } + + @Override + public String uuid() { + return uuid; + } - @Override - public JungleTree createNewTree(final String name) - { - ChangeList list = new ChangeList(){ - @Override - public Iterator<TreeOperation> iterator() { - List<TreeOperation> nil = List.nil(); - return nil.iterator(); - } - @Override - public String uuid() { - return uuid; - } - @Override - public String getTreeName() { - return name; - } - - }; - - DefaultTreeNode root = new DefaultTreeNode(); - Index index = new Index(); - ParentIndex parentIndex = new ParentIndex(); - ChangeSet set = new DefaultChangeSet(root,null,list,uuid,name,0,index,parentIndex); - DefaultTreeContext tc = new DefaultTreeContext(root,set); - JungleTree newTree = new DefaultJungleTree(tc,uuid,journal.getWriter(),editor); - if(trees.putIfAbsent(name,newTree) != null){ - return null; - } - return newTree; - } + @Override + public String getTreeName() { + return name; + } + + }; + + DefaultTreeNode root = new DefaultTreeNode(); + TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = new Index().getIndex(); + TreeMap<TreeNode, TreeNode> parentIndex = new ParentIndex().getParentIndex(); + ChangeSet set = new DefaultChangeSet(root, null, list, uuid, name, 0,indexList, parentIndex); + DefaultTreeContext tc = new DefaultTreeContext(root, set); + JungleTree newTree = new DefaultJungleTree(tc, uuid, + journal.getWriter(), editor); + if (trees.putIfAbsent(name, newTree) != null) { + return null; + } + return newTree; + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Mon Dec 08 03:37:34 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultChangeSet.java Mon Dec 08 12:21:51 2014 +0900 @@ -1,5 +1,8 @@ package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; +import java.util.TreeMap; + +import fj.data.List; 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; @@ -7,81 +10,73 @@ import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Index; import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex; -public class DefaultChangeSet implements ChangeSet -{ - private final TreeNode root; - private final ChangeSet previous; - private final ChangeList changeList; - private final String uuid; - private final String treeName; - private final long revision; - private final Index index; - private final ParentIndex parentIndex; - - public DefaultChangeSet(TreeNode _node,ChangeSet _prev,ChangeList _log,String _uuid, String _treeName, long _revision, Index index,ParentIndex parentIndex) - { - this.root = _node; - this.previous = _prev; - this.changeList = _log; - this.uuid = _uuid; - this.treeName = _treeName; - this.revision = _revision; - this.index = index; - this.parentIndex = parentIndex; - } - +public class DefaultChangeSet implements ChangeSet { + private final TreeNode root; + private final ChangeSet previous; + private final ChangeList changeList; + private final String uuid; + private final String treeName; + private final long revision; + private final TreeMap<String, TreeMap<String, List<TreeNode>>> indexList; + private final TreeMap<TreeNode, TreeNode> parentIndex; - @Override - public TreeNode getRoot() - { - return root; - } + public DefaultChangeSet(TreeNode _node, ChangeSet _prev, ChangeList _log, + String _uuid, String _treeName, long _revision, + TreeMap<String, TreeMap<String, List<TreeNode>>> indexList, + TreeMap<TreeNode, TreeNode> parentIndex) { + this.root = _node; + this.previous = _prev; + this.changeList = _log; + this.uuid = _uuid; + this.treeName = _treeName; + this.revision = _revision; + this.indexList = indexList; + this.parentIndex = parentIndex; + } - @Override - public ChangeSet prev() - { - return previous; - } + @Override + public TreeNode getRoot() { + return root; + } + + @Override + public ChangeSet prev() { + return previous; + } - @Override - public ChangeList getChangeList() - { - return changeList; - } + @Override + public ChangeList getChangeList() { + return changeList; + } - @Override - public String uuid() - { - return uuid; - } - - @Override - public String getTreeName() - { - return treeName; - } + @Override + public String uuid() { + return uuid; + } + + @Override + public String getTreeName() { + return treeName; + } - @Override - public long revision() - { - return revision; - } + @Override + public long revision() { + return revision; + } + + @Override + public Iterable<TreeOperation> getOperations() { + return changeList; + } - @Override - public Iterable<TreeOperation> getOperations() - { - return changeList; - } + @Override + public Index getIndex() { + return new Index(indexList); + } - @Override - public Index getIndex() { - return index; - } - - - @Override - public ParentIndex getParentIndex() { - return parentIndex; - } + @Override + public ParentIndex getParentIndex() { + return new ParentIndex(parentIndex); + } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Mon Dec 08 03:37:34 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java Mon Dec 08 12:21:51 2014 +0900 @@ -6,7 +6,9 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Iterator; +import java.util.TreeMap; +import fj.data.List; 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; @@ -81,10 +83,9 @@ e.printStackTrace(); } - Index index = traverser.getIndex(); - ParentIndex nulParentIndex = traverser.getParentIndex(); - DefaultChangeSet newCs = new DefaultChangeSet(_newRoot, cs, list, uuid, _treeName, nextRevision, index, - nulParentIndex); + TreeMap<String, TreeMap<String, List<TreeNode>>> indexList = traverser.getIndex().getIndex(); + TreeMap<TreeNode, TreeNode> parentIndex = traverser.getParentIndex().getParentIndex(); + DefaultChangeSet newCs = new DefaultChangeSet(_newRoot, cs, list, uuid, _treeName, nextRevision, indexList,parentIndex); DefaultTreeContext newContext = new DefaultTreeContext(_newRoot, newCs); @SuppressWarnings("rawtypes")
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexManager.java Mon Dec 08 03:37:34 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/IndexManager.java Mon Dec 08 12:21:51 2014 +0900 @@ -27,8 +27,7 @@ String uuid = cs.uuid(); String treeName = cs.getTreeName(); long revision = cs.revision(); - index.get("KER", "value"); - DefaultChangeSet newCs = new DefaultChangeSet(root, prev, cl, uuid, treeName, revision, index, parentIndex); + DefaultChangeSet newCs = new DefaultChangeSet(root, prev, cl, uuid, treeName, revision, index.getIndex(), parentIndex.getParentIndex()); DefaultTreeContext newTs = new DefaultTreeContext(root, newCs); reservation.set(newTs); }