annotate src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java @ 144:0854f9a9e81d

change attrs form TreeMap<String , ByteBuffer> → TreeMap<String,List<ByteBuffer>>
author one
date Sun, 16 Nov 2014 06:40:48 +0900
parents 74723b26ad96
children 8a0aa8fc137c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
2
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
3 import java.nio.ByteBuffer;
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
4
144
0854f9a9e81d change attrs form TreeMap<String , ByteBuffer> → TreeMap<String,List<ByteBuffer>>
one
parents: 117
diff changeset
5 import fj.data.List;
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
23
Shoshi TAMAKI
parents: 21
diff changeset
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
Shoshi TAMAKI
parents: 21
diff changeset
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
25
Shoshi TAMAKI
parents: 23
diff changeset
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
14
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
15 public class LoggingAttributes //implements EditableAttributes
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
16 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
17 private final TreeNode wrap;
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
18 private final OperationLog log;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
19
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
20 public LoggingAttributes(TreeNode _wrap,OperationLog _log)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
21 {
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
22 wrap = _wrap;
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
23 log = _log;
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
24 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
25
144
0854f9a9e81d change attrs form TreeMap<String , ByteBuffer> → TreeMap<String,List<ByteBuffer>>
one
parents: 117
diff changeset
26 public List<ByteBuffer> get(String _key)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
27 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
28 TreeNodeAttributes attributes = wrap.getAttributes();
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
29 return attributes.get(_key);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
30 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
31
117
74723b26ad96 add IndexJungleTreeEditr and remove DefaultJungleIndexTreeEditor
one
parents: 103
diff changeset
32 private Either<Error,LoggingNode> edit(NodeOperation _op)
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
33 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
34 Either<Error,TreeNode> either = _op.invoke(wrap);
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
35 if(either.isA()){
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
36 return DefaultEither.newA(either.a());
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
37 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
38
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
39 TreeNode newNode = either.b();
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
40 OperationLog newLog = log.add(_op);
117
74723b26ad96 add IndexJungleTreeEditr and remove DefaultJungleIndexTreeEditor
one
parents: 103
diff changeset
41 LoggingNode newLogNode = new LoggingNode(newNode,newLog);
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
42
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
43 return DefaultEither.newB(newLogNode);
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
44 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
45
117
74723b26ad96 add IndexJungleTreeEditr and remove DefaultJungleIndexTreeEditor
one
parents: 103
diff changeset
46 public Either<Error,LoggingNode> delete(final String _key)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
47 {
23
Shoshi TAMAKI
parents: 21
diff changeset
48
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
49 DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
50 return edit(deleteAttribute);
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
51 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
52
117
74723b26ad96 add IndexJungleTreeEditr and remove DefaultJungleIndexTreeEditor
one
parents: 103
diff changeset
53 public Either<Error,LoggingNode> put(final String _key,final ByteBuffer _value)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
54 {
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
55 PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
56 return edit(putAttribute);
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
57 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
58 }