Mercurial > hg > Database > jungle-network
annotate src/jungle/test/codesegment/log/practice/StartCodeSegment.java @ 75:87ec5dd0dc27
Rename from alice.jungle.datasegment.store.operation to alice.jungle.datasegment.store.container
author | one |
---|---|
date | Tue, 15 Oct 2013 14:43:29 +0900 |
parents | 190f6a3bdab2 |
children |
rev | line source |
---|---|
14 | 1 package jungle.test.codesegment.log.practice; |
2 | 2 |
9 | 3 import java.io.IOException; |
4 import java.nio.ByteBuffer; | |
5 import java.util.LinkedList; | |
6 import java.util.List; | |
7 | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation; | |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation; | |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation; | |
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; | |
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; | |
2 | 16 import alice.codesegment.CodeSegment; |
75
87ec5dd0dc27
Rename from alice.jungle.datasegment.store.operation to alice.jungle.datasegment.store.container
one
parents:
31
diff
changeset
|
17 import alice.jungle.datasegment.store.container.DefaultTreeOperationLogContainer; |
2 | 18 |
19 public class StartCodeSegment extends CodeSegment { | |
20 | |
21 @Override | |
22 public void run() { | |
23 System.out.println("run StartCodeSegment"); | |
24 | |
25 TestCodeSegment cs = new TestCodeSegment(); | |
9 | 26 cs.arg1.setKey("log"); |
2 | 27 System.out.println("create TestCodeSegment"); |
9 | 28 |
13 | 29 DefaultTreeOperationLog log = getSampleOperationLog(); |
30 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer(); | |
31 try { | |
32 logContainer.unconvert(log); | |
33 ods.update("local", "log", logContainer); | |
34 } catch (IOException e) { | |
35 e.printStackTrace(); | |
36 } | |
37 } | |
38 | |
39 public DefaultTreeOperationLog getSampleOperationLog() { | |
9 | 40 String key = "hoge"; |
41 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes()); | |
42 DefaultNodePath nodePath1 = new DefaultNodePath(); | |
43 nodePath1 = nodePath1.add(1); | |
44 DefaultNodePath nodePath2 = nodePath1.add(2); | |
10 | 45 AppendChildAtOperation appendChildOp1 = new AppendChildAtOperation(1); |
46 AppendChildAtOperation appendChildOp2 = new AppendChildAtOperation(2); | |
9 | 47 PutAttributeOperation putOp = new PutAttributeOperation(key, b); |
48 DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge"); | |
49 DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2); | |
50 List<TreeOperation> list = new LinkedList<TreeOperation>(); | |
10 | 51 list.add(new DefaultTreeOperation(new DefaultNodePath(), appendChildOp1)); |
52 list.add(new DefaultTreeOperation(nodePath1, appendChildOp2)); | |
9 | 53 list.add(new DefaultTreeOperation(nodePath2, putOp)); |
54 list.add(new DefaultTreeOperation(nodePath2, deleteOp)); | |
55 list.add(new DefaultTreeOperation(nodePath1, deleteChild)); | |
56 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size()); | |
13 | 57 return log; |
58 } | |
2 | 59 |
60 } |