Mercurial > hg > Database > jungle-network
diff src/jungle/test/codesegment/practice/StartCodeSegment.java @ 9:49c0eaa4dce2
add StartCodeSegment.java
author | one |
---|---|
date | Tue, 11 Jun 2013 14:09:42 +0900 |
parents | 20498c88a70d |
children | 5376ac62ac08 |
line wrap: on
line diff
--- a/src/jungle/test/codesegment/practice/StartCodeSegment.java Tue Jun 11 05:41:07 2013 +0900 +++ b/src/jungle/test/codesegment/practice/StartCodeSegment.java Tue Jun 11 14:09:42 2013 +0900 @@ -1,5 +1,19 @@ package jungle.test.codesegment.practice; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.LinkedList; +import java.util.List; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; +import jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer; import alice.codesegment.CodeSegment; public class StartCodeSegment extends CodeSegment { @@ -9,12 +23,33 @@ System.out.println("run StartCodeSegment"); TestCodeSegment cs = new TestCodeSegment(); - cs.arg1.setKey("key1"); // unbound datasegment key1 is created and connect to cs. - // cs is waiting for local.key1 + cs.arg1.setKey("log"); System.out.println("create TestCodeSegment"); + + String key = "hoge"; + ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes()); + DefaultNodePath nodePath1 = new DefaultNodePath(); + nodePath1 = nodePath1.add(1); + DefaultNodePath nodePath2 = nodePath1.add(2); + AppendChildAtOperation appendChildOp = new AppendChildAtOperation(1); + PutAttributeOperation putOp = new PutAttributeOperation(key, b); + DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge"); + DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2); + List<TreeOperation> list = new LinkedList<TreeOperation>(); + list.add(new DefaultTreeOperation(nodePath1, appendChildOp)); + list.add(new DefaultTreeOperation(nodePath2, appendChildOp)); + list.add(new DefaultTreeOperation(nodePath2, putOp)); + list.add(new DefaultTreeOperation(nodePath2, deleteOp)); + list.add(new DefaultTreeOperation(nodePath1, deleteChild)); + DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size()); - ods.update("local", "key1", "String data"); // bind string data to datasegment local.key1 - // this startup TestCodeSegment. + DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer(); + try { + logContainer.unconvert(log); + ods.update("local", "log", logContainer); + } catch (IOException e) { + e.printStackTrace(); + } } }