annotate src/main/java/alice/jungle/persistent/AliceJournal.java @ 105:f9e29a52efd3

Move some files
author one
date Tue, 26 Nov 2013 06:43:10 +0900
parents src/alice/jungle/persistence/AliceJournal.java@87ec5dd0dc27
children 895ab2907db3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
105
f9e29a52efd3 Move some files
one
parents: 75
diff changeset
1 package alice.jungle.persistent;
31
190f6a3bdab2 rename some packages
one
parents: 30
diff changeset
2
17
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
8
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
9 public class AliceJournal implements Journal {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
10
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
11 private static final AliceChangeListWriter ALICE_WRITER = new AliceChangeListWriter();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
12 private static final AliceChangeListReader ALICE_READER = new AliceChangeListReader();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
13 @Override
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
14 public ChangeListReader getReader() {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
15 return ALICE_READER;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
16 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
17 @Override
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
18 public ChangeListWriter getWriter() {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
19 return ALICE_WRITER;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
20 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
21
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
22 private static class AliceChangeListWriter implements ChangeListWriter
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
23 {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
24 @Override
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
25 public Result write(ChangeList _operations)
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
26 {
63
3b0091c91e61 non print operation info
one
parents: 58
diff changeset
27 /*
17
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
28 for(TreeOperation op : _operations){
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
29 NodePath p = op.getNodePath();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
30 NodeOperation nodeOp = op.getNodeOperation();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
31 Command c = nodeOp.getCommand();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
32 String args = "";
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
33 switch(c){
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
34 case PUT_ATTRIBUTE:
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
35 String key = nodeOp.getKey();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
36 ByteBuffer value = nodeOp.getValue();
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
37 if(value.limit() < 100){
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
38 args = String.format("key:%s,value:%s",key,new String(value.array()));
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
39 }else{
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
40 args = String.format("key:%s,value:%d",key,value.limit());
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
41 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
42 break;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
43 case DELETE_ATTRIBUTE:
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
44 args = String.format("key:%s",nodeOp.getKey());
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
45 break;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
46 case APPEND_CHILD:
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
47 args = String.format("pos:%d",nodeOp.getPosition());
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
48 break;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
49 case DELETE_CHILD:
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
50 args = String.format("pos:%d",nodeOp.getPosition());
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
51 break;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
52 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
53 System.out.println(String.format("[%s:%s:%s]",c,p,args));
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
54 }
63
3b0091c91e61 non print operation info
one
parents: 58
diff changeset
55 */
17
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
56 return Result.SUCCESS;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
57 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
58 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
59
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
60 private static class AliceChangeListReader implements ChangeListReader
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
61 {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
62 @Override
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
63 public ChangeListReader newReader()
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
64 {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
65 return this;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
66 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
67
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
68 @Override
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
69 public ChangeList read()
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
70 {
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
71 return null;
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
72 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
73 }
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
74
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
75
c767e7af4d88 add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
one
parents:
diff changeset
76 }