Mercurial > hg > Members > tatsuki > bench > jungle-core
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 |
rev | line source |
---|---|
92 | 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 | 4 |
144
0854f9a9e81d
change attrs form TreeMap<String , ByteBuffer> → TreeMap<String,List<ByteBuffer>>
one
parents:
117
diff
changeset
|
5 import fj.data.List; |
92 | 6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; |
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 | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; | |
23 | 11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
25 | 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 | 15 public class LoggingAttributes //implements EditableAttributes |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
16 { |
92 | 17 private final TreeNode wrap; |
51 | 18 private final OperationLog log; |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
19 |
92 | 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 | 28 TreeNodeAttributes attributes = wrap.getAttributes(); |
51 | 29 return attributes.get(_key); |
30 } | |
31 | |
117
74723b26ad96
add IndexJungleTreeEditr and remove DefaultJungleIndexTreeEditor
one
parents:
103
diff
changeset
|
32 private Either<Error,LoggingNode> edit(NodeOperation _op) |
51 | 33 { |
92 | 34 Either<Error,TreeNode> either = _op.invoke(wrap); |
51 | 35 if(either.isA()){ |
36 return DefaultEither.newA(either.a()); | |
37 } | |
38 | |
92 | 39 TreeNode newNode = either.b(); |
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 | 42 |
103 | 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 | 48 |
51 | 49 DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key); |
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 | 55 PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value); |
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 } |