Mercurial > hg > Members > tatsuki > bench > jungle-core
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java @ 103:bed3afd5c2e2
add Index but Not use
author | one |
---|---|
date | Fri, 12 Sep 2014 14:37:09 +0900 |
parents | c297f0015d9e |
children | 98e256d9fd57 |
comparison
equal
deleted
inserted
replaced
101:c297f0015d9e | 103:bed3afd5c2e2 |
---|---|
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; | 1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction; |
2 | 2 |
3 import java.nio.ByteBuffer; | 3 import java.nio.ByteBuffer; |
4 | 4 |
5 import fj.data.List; | |
5 import fj.data.TreeMap; | 6 import fj.data.TreeMap; |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | 8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; | 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; |
22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; | 23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; |
23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | 24 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; |
24 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | 25 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
25 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; | 26 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; |
26 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; | 27 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Pair; |
28 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging; | |
27 | 29 |
28 public class DefaultJungleTreeEditor implements JungleTreeEditor | 30 public class DefaultJungleTreeEditor implements JungleTreeEditor |
29 { | 31 { |
30 private final TransactionManager txManager; | 32 private final TransactionManager txManager; |
31 private final TreeNode root; | 33 private final TreeNode root; |
32 private final TreeEditor editor; | 34 private final TreeEditor editor; |
33 private final TreeOperationLog log; | 35 private final TreeOperationLog log; |
34 private Pair<TreeMap<String,TreeNode>,TreeMap<String,String>> index; | |
35 | 36 |
36 public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor, Pair<TreeMap<String,TreeNode>,TreeMap<String,String>> index) | 37 public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor) |
37 { | 38 { |
38 this(_root,_txManager,_editor,new DefaultTreeOperationLog(), index); | 39 this(_root,_txManager,_editor,new DefaultTreeOperationLog()); |
39 } | 40 } |
40 | 41 |
41 public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager _txManager,TreeEditor _editor,TreeOperationLog _log, Pair<TreeMap<String,TreeNode>,TreeMap<String,String>> index) | 42 public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager _txManager,TreeEditor _editor,TreeOperationLog _log) |
42 { | 43 { |
43 this.root = newNode; | 44 this.root = newNode; |
44 this.txManager = _txManager; | 45 this.txManager = _txManager; |
45 this.editor = _editor; | 46 this.editor = _editor; |
46 this.log = _log; | 47 this.log = _log; |
47 this.index = index; | |
48 } | 48 } |
49 | 49 |
50 private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) | 50 private Either<Error,JungleTreeEditor> _edit(final NodePath _path,NodeEditor _e) |
51 { | 51 { |
52 //LoggingNodeHook hook = new LoggingNodeHook(_e); | 52 //LoggingNodeHook hook = new LoggingNodeHook(_e); |
53 Either<Error,LoggingNode> either = editor.edit(root,_path,_e); | 53 Either<Error,Logging> either = editor.edit(root,_path,_e); |
54 if(either.isA()){ | 54 if(either.isA()){ |
55 return DefaultEither.newA(either.a()); | 55 return DefaultEither.newA(either.a()); |
56 } | 56 } |
57 | 57 |
58 LoggingNode newLogging = either.b(); | 58 Logging newLogging = either.b(); |
59 OperationLog newLog = newLogging.getOperationLog(); | 59 OperationLog newLog = newLogging.getOperationLog(); |
60 TreeNode newNode = newLogging.getWrap(); | 60 TreeNode newNode = newLogging.getWrap(); |
61 | 61 |
62 IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ | 62 IterableConverter.Converter<TreeOperation,NodeOperation> converter = new IterableConverter.Converter<TreeOperation,NodeOperation>(){ |
63 @Override | 63 @Override |
68 | 68 |
69 Iterable<TreeOperation> iterable = new IterableConverter<TreeOperation,NodeOperation>(newLog,converter); | 69 Iterable<TreeOperation> iterable = new IterableConverter<TreeOperation,NodeOperation>(newLog,converter); |
70 DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); | 70 DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); |
71 TreeOperationLog newTreeOpLog = log.append(treeOperationLog); | 71 TreeOperationLog newTreeOpLog = log.append(treeOperationLog); |
72 | 72 |
73 JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog, index); | 73 JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog); |
74 return DefaultEither.newB(newEditor); | 74 return DefaultEither.newB(newEditor); |
75 } | 75 } |
76 | 76 |
77 @Override | 77 @Override |
78 public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) | 78 public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) |
109 } | 109 } |
110 | 110 |
111 @Override | 111 @Override |
112 public Either<Error,JungleTreeEditor> success() | 112 public Either<Error,JungleTreeEditor> success() |
113 { | 113 { |
114 Either<Error,TransactionManager> either = txManager.commit(root,log); | 114 Either<Error,TransactionManager> either = txManager.commit(root,log,null); |
115 if(either.isA()){ | 115 if(either.isA()){ |
116 return DefaultEither.newA(either.a()); | 116 return DefaultEither.newA(either.a()); |
117 } | 117 } |
118 | 118 |
119 TransactionManager newTxManager = either.b(); | 119 TransactionManager newTxManager = either.b(); |
120 JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor(root,newTxManager,editor, index); | 120 JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor(root,newTxManager,editor); |
121 | 121 |
122 return DefaultEither.newB(newTreeEditor); | 122 return DefaultEither.newB(newTreeEditor); |
123 } | 123 } |
124 | 124 |
125 @Override | 125 @Override |