changeset 179:817febd9c69b

change transaction
author tatsuki
date Tue, 17 Mar 2015 11:19:04 +0900
parents 169c501fe3a9
children 2e6ca84686da
files .idea/uiDesigner.xml src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeContext.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.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/test/CompareNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapReadThread.java
diffstat 11 files changed, 375 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/uiDesigner.xml	Tue Mar 17 11:19:04 2015 +0900
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>
\ No newline at end of file
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java	Sun Mar 15 20:52:15 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungle.java	Tue Mar 17 11:19:04 2015 +0900
@@ -9,13 +9,12 @@
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.NullJournal;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
 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;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser;
@@ -78,12 +77,10 @@
 			}
 			
 		};
-		
 		DefaultTreeNode root = new DefaultTreeNode();
 	  TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> indexList = TreeMap.empty(Ord.stringOrd);
 		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);
+		TreeContext tc = new DefaultTreeContext(root,null,list,uuid,name,0,indexList,parentIndex);
 		JungleTree newTree = new DefaultJungleTree(tc,uuid,journal.getWriter(),editor);
 		if(trees.putIfAbsent(name,newTree) != null){
 			return null;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java	Sun Mar 15 20:52:15 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/DefaultJungleTree.java	Tue Mar 17 11:19:04 2015 +0900
@@ -2,32 +2,30 @@
 
 import fj.data.TreeMap;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.AtomicReservableReference;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultJungleTreeEditor;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTransactionManager;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.TreeContext;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.GetOldTreeError;
-import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.IndexManager;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex;
 
+import java.util.concurrent.atomic.AtomicReference;
+
 public class DefaultJungleTree implements JungleTree {
 
-  private final AtomicReservableReference<TreeContext> repository;
+  private final AtomicReference<TreeContext> repository;
   private final String uuid;
   private final ChangeListWriter writer;
   private final TreeEditor treeEditor;
 
   public DefaultJungleTree(TreeContext tc, String uuid, ChangeListWriter writer, TreeEditor editor) {
-    this.repository = new AtomicReservableReference<TreeContext>(tc);
+    this.repository = new AtomicReference<TreeContext>(tc);
     this.uuid = uuid;
     this.writer = writer;
     this.treeEditor = editor;
@@ -37,7 +35,7 @@
   public JungleTreeEditor getTreeEditor() {
     TreeContext tc = repository.get();
     DefaultTransactionManager txManager = new DefaultTransactionManager(writer, tc, repository, uuid);
-    TreeNode root = tc.getTreeNode();
+    TreeNode root = tc.getRoot();
     return new DefaultJungleTreeEditor(root, txManager, treeEditor);
   }
 
@@ -49,62 +47,53 @@
   @Override
   public TreeNode getRootNode() {
     TreeContext tc = repository.get();
-    ChangeSet cs = tc.getChangeSet();
-    return cs.getRoot();
+    return tc.getRoot();
   }
 
   @Override
   public InterfaceTraverser getTraverser(boolean useIndex) {
-    AtomicReservableReference<TreeContext>.Reservation reservation = repository.getReservation();
-    IndexManager indexManager = new IndexManager(reservation);
     TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index = getIndex();
     ParentIndex parentIndex = getParentIndex();
-    return new InterfaceTraverser(getRootNode(), index, parentIndex, indexManager, useIndex);
+    return new InterfaceTraverser(repository.get().getRoot(), index, parentIndex, useIndex);
   }
 
   @Override
   public ParentIndex getParentIndex() {
     TreeContext tc = repository.get();
-    ChangeSet cs = tc.getChangeSet();
-    return cs.getParentIndex();
+    return tc.getParentIndex();
   }
 
   @Override
   public TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> getIndex() {
     TreeContext tc = repository.get();
-    ChangeSet cs = tc.getChangeSet();
-    return cs.getIndex();
+    return tc.getIndex();
   }
 
   @Override
   public long revision() {
     TreeContext tc = repository.get();
-    ChangeSet cs = tc.getChangeSet();
-    return cs.revision();
+    return tc.revision();
   }
 
   @Override
   public Either<Error, JungleTree> getOldTree(long revision) {
     TreeContext tc = repository.get();
-    ChangeSet cs = tc.getChangeSet();
 
-    for (; cs.revision() != revision;) {
-      cs = cs.prev();
-      if (cs == null)
+    for (; tc.revision() != revision;) {
+      tc = tc.prev();
+      if (tc == null)
         return DefaultEither.newA(GetOldTreeError.OLD_TREE_NOT_FOUND);
     }
 
-    TreeNode root = cs.getRoot();
 
-    TreeContext oldTc = new DefaultTreeContext(root, cs);
     String oldTreeUuid = uuid + revision;
-    JungleTree oldTree = new DefaultJungleTree(oldTc, oldTreeUuid, writer, treeEditor);
+    JungleTree oldTree = new DefaultJungleTree(tc, oldTreeUuid, writer, treeEditor);
     return DefaultEither.newB(oldTree);
   }
 
   @Override
   public Either<Error, TreeNode> getNodeOfPath(NodePath path) {
-    TreeNode node = repository.get().getTreeNode();
+    TreeNode node = repository.get().getRoot();
     for (int num : path) {
       if (num == -1)
         continue;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/ChangeSet.java	Sun Mar 15 20:52:15 2015 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store;
-
-
-
-import fj.data.TreeMap;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
-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.tatsuki.jungle.store.index.ParentIndex;
-
-public interface ChangeSet
-{
-	public TreeNode getRoot();
-	public ChangeSet prev();
-	public ChangeList getChangeList();
-	
-	public String uuid();
-	public String getTreeName();
-	public long revision();
-	public TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> getIndex();
-	public Iterable<TreeOperation> getOperations();
-  public ParentIndex getParentIndex();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/TreeContext.java	Tue Mar 17 11:19:04 2015 +0900
@@ -0,0 +1,25 @@
+package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store;
+
+
+
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
+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.tatsuki.jungle.store.index.ParentIndex;
+
+public interface TreeContext
+{
+	public TreeNode getRoot();
+	public TreeContext prev();
+	public ChangeList getChangeList();
+	
+	public String uuid();
+	public String getTreeName();
+	public long revision();
+	public TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> getIndex();
+	public Iterable<TreeOperation> getOperations();
+    public ParentIndex getParentIndex();
+    public void setIndex(TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index);
+    public void setParentIndex(ParentIndex parentIndex);
+}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java	Sun Mar 15 20:52:15 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTransactionManager.java	Tue Mar 17 11:19:04 2015 +0900
@@ -2,32 +2,30 @@
 
 
 import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicReference;
 
 import fj.data.TreeMap;
 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;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.TreeOperationLog;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.AtomicReservableReference.Reservation;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultError;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
-import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.IndexManager;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex;
 
 public class DefaultTransactionManager implements TransactionManager {
-  private final AtomicReservableReference<TreeContext> repository;
+  private final AtomicReference<TreeContext> repository;
   private final TreeContext tip;
   private final ChangeListWriter writer;
   private final String uuid;
 
   public DefaultTransactionManager(ChangeListWriter _writer, TreeContext _tip,
-      AtomicReservableReference<TreeContext> _repository, String _uuid) {
+      AtomicReference<TreeContext> _repository, String _uuid) {
     repository = _repository;
     tip = _tip;
     writer = _writer;
@@ -35,12 +33,11 @@
   }
 
   @Override
-  public Either<Error, TransactionManager> commit(TreeNode _newRoot, final TreeOperationLog _log) {
-    ChangeSet cs = tip.getChangeSet();
-    long currentRevision = cs.revision();
+  public Either<Error, TransactionManager> commit(TreeNode newRoot, final TreeOperationLog _log) {
+    long currentRevision = tip.revision();
     long nextRevision = currentRevision + 1;
 
-    final String _treeName = cs.getTreeName();
+    final String _treeName = tip.getTreeName();
     ChangeList list = new ChangeList() {
       @Override
       public Iterator<TreeOperation> iterator() {
@@ -58,26 +55,19 @@
       }
 
     };
-    IndexManager indexManager = new IndexManager(repository.getReservation());
-    InterfaceTraverser traverser = new InterfaceTraverser(_newRoot, indexManager, true);
-    traverser.createIndex();
-    TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index = traverser.getIndex();
-    ParentIndex parentIndex = traverser.getParentIndex();
-    DefaultChangeSet newCs = new DefaultChangeSet(_newRoot, cs, list, uuid, _treeName, nextRevision, index, parentIndex.getParentIndex());
-    DefaultTreeContext newContext = new DefaultTreeContext(_newRoot, newCs);
+    System.out.println("transaction");
+      InterfaceTraverser traverser = new InterfaceTraverser(newRoot, true);
+      traverser.createIndex();
+      TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index = traverser.getIndex();
+      ParentIndex parentIndex = traverser.getParentIndex();
+      TreeContext newTreeContext = new DefaultTreeContext(newRoot , tip, list, uuid, _treeName, nextRevision,index,parentIndex.getParentIndex());
 
-    @SuppressWarnings("rawtypes")
-    Reservation reservation = repository.makeReservation(tip, newContext);
-    if (reservation == null) {
-      return DefaultEither.newA((Error) new DefaultError());
+    if  (repository.compareAndSet(newTreeContext.prev(),newTreeContext)) {
+        TransactionManager txManager = new DefaultTransactionManager(writer, newTreeContext, repository, uuid);
+        return DefaultEither.newB(txManager);
     }
-    Result r = writer.write(list);
-    if (r == Result.SUCCESS) {
-      reservation.confirm();
-      TransactionManager txManager = new DefaultTransactionManager(writer, newContext, repository, uuid);
-      return DefaultEither.newB(txManager);
-    }
-    return DefaultEither.newA((Error) new DefaultError());
+
+      return DefaultEither.newA((Error) new DefaultError());
   }
 
   @Override
@@ -87,7 +77,6 @@
 
   @Override
   public long getRevision() {
-    ChangeSet cs = tip.getChangeSet();
-    return cs.revision();
+    return tip.revision();
   }
 }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java	Sun Mar 15 20:52:15 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultTreeContext.java	Tue Mar 17 11:19:04 2015 +0900
@@ -1,28 +1,98 @@
 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction;
 
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet;
+import fj.data.TreeMap;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
 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.tatsuki.jungle.store.index.ParentIndex;
 
 public class DefaultTreeContext implements TreeContext
 {
 	private final TreeNode root;
-	private final ChangeSet cs;
-	
-	public DefaultTreeContext(TreeNode _newRoot,ChangeSet _cs)
+	private final TreeContext previous;
+	private final ChangeList changeList;
+	private final String uuid;
+	private final String treeName;
+	private final long revision;
+	private TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> indexList;
+	private TreeMap<TreeNode, TreeNode> parentIndex;
+
+  public DefaultTreeContext(TreeNode _node,TreeContext _prev,ChangeList _log,String _uuid, String _treeName, long _revision,  TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> indexList,
+            TreeMap<TreeNode, TreeNode> parentIndex)
 	{
-		root = _newRoot;
-		cs = _cs;
+		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 TreeNode getRoot()
+	{
+		return root;
+	}
+
+	@Override
+	public TreeContext prev()
+	{
+		return previous;
+	}
+
+	@Override
+	public ChangeList getChangeList()
+	{
+		return changeList;
 	}
 
 	@Override
-	public ChangeSet getChangeSet()
+	public String uuid()
+	{
+		return  uuid;
+	}
+
+	@Override
+	public String getTreeName()
 	{
-		return cs;
+		return treeName;
+	}
+
+	@Override
+	public long revision()
+	{
+		return revision;
 	}
 
 	@Override
-	public TreeNode getTreeNode()
+	public Iterable<TreeOperation> getOperations()
 	{
-		return root;
+		return changeList;
+	}
+
+	@Override
+	public TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> getIndex() {
+		return indexList;
 	}
+
+
+  @Override
+  public ParentIndex getParentIndex() {
+    return new ParentIndex(parentIndex);
+  }
+
+    @Override
+    public void setIndex(TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> indexList) {
+        this.indexList = indexList;
+    }
+
+    @Override
+    public void setParentIndex(ParentIndex parentIndex) {
+        this.parentIndex = parentIndex.getParentIndex();
+    }
+
 }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java	Sun Mar 15 20:52:15 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/traverser/InterfaceTraverser.java	Tue Mar 17 11:19:04 2015 +0900
@@ -4,35 +4,32 @@
 
 import fj.Ord;
 import fj.P2;
-import fj.data.List;
 import fj.data.Option;
 import fj.data.TreeMap;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NulIterator;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeContext;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.PathNodeIterator;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.query.Query;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.IndexCreater;
-import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.IndexManager;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex;
 
 public class InterfaceTraverser {
 
-  TreeNode node;
+  TreeNode root;
   TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> indexList;
   ParentIndex parentIndex;
   boolean parentUpdateFlag;
-  IndexManager indexManager;
   boolean useIndex;
 
-  public InterfaceTraverser(TreeNode root, IndexManager indexManager, boolean indexFlag) {
-    this(root, TreeMap.empty(Ord.stringOrd), new ParentIndex(), indexManager, indexFlag);
+  public InterfaceTraverser(TreeNode root, boolean indexFlag) {
+    this(root, TreeMap.empty(Ord.stringOrd), new ParentIndex(), indexFlag);
   }
 
   public InterfaceTraverser(TreeNode root, TreeMap<String, TreeMap<String, TreeMap<TreeNode, TreeNode>>> index,
-      ParentIndex parentIndex, IndexManager indexManager, boolean useIndex) {
-    this.node = root;
+      ParentIndex parentIndex, boolean useIndex) {
+    this.root = root;
     this.indexList = index;
-    this.indexManager = indexManager;
     this.parentIndex = parentIndex;
     if (parentIndex.isEmpty())
       parentUpdateFlag = true;
@@ -47,7 +44,6 @@
 
   public void commit() {
     parentUpdateFlag = false;
-    indexManager.commit(indexList, parentIndex);
   }
 
   public ParentIndex getParentIndex() {
@@ -60,7 +56,7 @@
 
   public void createIndex() {
     // long t1 = System.currentTimeMillis();
-    IndexCreater creater = new IndexCreater(node);
+    IndexCreater creater = new IndexCreater(root);
     // long t2 = System.currentTimeMillis();
     // System.out.println("createIndex time = " + (t2 - t1));
     indexList = creater.getIndex();
@@ -141,12 +137,6 @@
 
   /**
    * subTree以下のNodeに対してKeyに対応する値をindexを使って探索する
-   * 
-   * @param query
-   * @param subTree
-   * @param key
-   * @param searchValue
-   * @return
    */
   // public Iterator<TreeNode> findInSubTreeAllValue(final Query query, TreeNode
   // subTree, String key) {
@@ -217,7 +207,7 @@
       return nodeIterator;
     } else {
 
-      final PathNodeIterator itNode = new PathNodeIterator(node);
+      final PathNodeIterator itNode = new PathNodeIterator(root);
       return new Iterator<TreeNode>() {
 
         private TreeNode matchNode = nextmatch(itNode);
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/CompareNode.java	Sun Mar 15 20:52:15 2015 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test;
-
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree;
-import fj.data.HashMap;
-import fj.data.List;
-
-public class CompareNode {
-	public List<MuchNode> compare(JungleTree tree1, JungleTree tree2){
-		List<PathNode> pNodes1 = traverser.traverse(tree1);
-		List<PathNode> pNodes2 = traverser.traverse(tree2);
-		HashMap<ByteBuffer,PathNode> map = new HashMap<ByteBuffer,PathNode>(null, null);
-		List<MuchNode> muchNodes = new List<MuchNode>(null);
-		for(PathNode pathNode : pNodes1){
-			Either<Error,ByteBuffer> either = get(pathNode.getNode());
-			if(either.isA())
-				continue;
-			map.put(either.B(),pathNode);
-		}
-		for(PathNode pathNode : pNodes2){
-			Either<Error,ByteBuffer> either = get(pathNode.getNode());
-			if(either.isA())
-				continue;
-			if(!map.containskey(either.B()))
-				continue;
-			muchNodes.add(tree1,pathNode.getPath(),pathNode.getNode(),tree2,map.get(either.B().getPath()),map.get(either.B().getNode()));
-		}
-		return muchNodes;
-	}
-}*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapBenchMark.java	Tue Mar 17 11:19:04 2015 +0900
@@ -0,0 +1,56 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test;
+
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor;
+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.traverser.DefaultTraverser;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.*;
+import java.nio.ByteBuffer;
+
+/**
+ * Created by e115731 on 15/03/17.
+ */
+public class TreeMapBenchMark {
+    public static void main(String[] args) throws InterruptedException, IOException, ParserConfigurationException, SAXException {
+        System.out.println("startReadTree");
+
+        System.out.println("util");
+        Runtime rt = Runtime.getRuntime();
+        int cpuNum = rt.availableProcessors();
+
+        File file = new File("./readTreeMapTime");
+        PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
+        for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) {
+            TreeMapReadThread readThread[] = new TreeMapReadThread[THREAD_COUNT];
+            ;
+            for (int count = 0; THREAD_COUNT > count; count++) {
+                readThread[count] = new TreeMapReadThread();
+            }
+
+            for (int count = 0; THREAD_COUNT > count; count++) {
+                readThread[count].start();
+            }
+
+            System.out.println("StartThread");
+
+            Thread.sleep(1000);
+            long readCount = 0;
+
+            for (int count = 0; THREAD_COUNT > count; count++) {
+                readCount = readCount + readThread[count].getFindCount();
+                readThread[count].set(false);
+            }
+
+            pw.println(THREAD_COUNT + " " + readCount);
+            System.out.println(THREAD_COUNT + "readCount = " + readCount);
+        }
+
+        pw.close();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/test/TreeMapReadThread.java	Tue Mar 17 11:19:04 2015 +0900
@@ -0,0 +1,45 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.test;
+
+import fj.Ord;
+import fj.data.Option;
+import fj.data.TreeMap;
+
+/**
+ * Created by e115731 on 15/03/17.
+ */
+public class TreeMapReadThread extends Thread {
+
+    //TreeMap<String,String> map = TreeMap.empty(Ord.stringOrd);
+    java.util.TreeMap map = new java.util.TreeMap();
+    private long findCount;
+
+    boolean loop = true;
+
+    public TreeMapReadThread() {
+
+        //map = map.set("test","test");
+        map.put("test","test");
+    }
+
+    public long getFindCount() {
+        System.out.println("thread count = " + findCount);
+        return findCount;
+    }
+
+    public void set(boolean loop) {
+        this.loop = loop;
+    }
+
+    @Override
+    public void run() {
+        while (loop) {
+           // Option<String> op = map.get("test");
+           // if (op.isSome())
+           //     findCount++;
+            if (map.get("test").equals("test"))
+                findCount++;
+                  else
+                     System.out.println("faild");
+        }
+    }
+}