Mercurial > hg > Members > tatsuki > Alice
changeset 213:3f20b6401823 working
remove error form bitonic
author | one |
---|---|
date | Wed, 27 Mar 2013 17:56:08 +0900 |
parents | b5daccf36104 |
children | fec0726bb126 |
files | src/alice/codesegment/OutputDataSegment.java src/alice/codesegment/ReceiveLocalData.java src/alice/datasegment/ReceiveRemoteData.java src/alice/datasegment/Receiver.java src/alice/datasegment/ReceiverData.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/codesegment/local/bitonicsort/MakeData.java src/alice/test/codesegment/local/bitonicsort/OddPhase.java src/alice/test/codesegment/local/bitonicsort/SetTask.java src/alice/test/codesegment/local/bitonicsort/ShowData.java |
diffstat | 10 files changed, 56 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Wed Mar 27 17:56:08 2013 +0900 @@ -35,9 +35,7 @@ } public void flip(Receiver receiver) { - //DataSegment.getLocal().put(receiver.key, receiver.val,receiver.obj); - DataSegmentKey key = DataSegment.getLocal().getDataSegmentKey(receiver.data.key); - key.runCommand(new Command(CommandType.PUT,null,null, receiver.data.val,receiver.data.obj, 0,0,null,null, "local")); + DataSegment.getLocal().put(receiver.key, receiver.data.getObject()); } public void put(String key, Value val) {
--- a/src/alice/codesegment/ReceiveLocalData.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/codesegment/ReceiveLocalData.java Wed Mar 27 17:56:08 2013 +0900 @@ -32,4 +32,9 @@ return (T) obj; } + + @Override + public Object getVal() { + return obj; + } }
--- a/src/alice/datasegment/ReceiveRemoteData.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/datasegment/ReceiveRemoteData.java Wed Mar 27 17:56:08 2013 +0900 @@ -55,6 +55,10 @@ return null; } - + + @Override + public Object getVal() { + return val; + } } \ No newline at end of file
--- a/src/alice/datasegment/Receiver.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/datasegment/Receiver.java Wed Mar 27 17:56:08 2013 +0900 @@ -1,7 +1,11 @@ package alice.datasegment; +import java.io.IOException; + import alice.codesegment.InputDataSegment; +import alice.codesegment.SingletonMessage; +import alice.test.codesegment.local.bitonicsort.SortConfig; /** * MessagePack implementation and DataSegment Receiver @@ -67,5 +71,17 @@ data = r; } + + public Object getVal() { + return data.getVal(); + } + + public <T> T asClass(Receiver receiver, Class<T> clazz) { + return data.asClass(receiver, clazz); + } + + public int asInteger(Receiver receiver) { + return data.asInteger(receiver); + } }
--- a/src/alice/datasegment/ReceiverData.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/datasegment/ReceiverData.java Wed Mar 27 17:56:08 2013 +0900 @@ -1,5 +1,14 @@ package alice.datasegment; +import org.msgpack.type.ArrayValue; + public interface ReceiverData { + public String asString(Receiver receiver); + public int asInteger(Receiver receiver); + public Float asFloat(Receiver receiver) ; + public ArrayValue asArray(Receiver receiver); + public <T> T asClass(Receiver receiver, Class<T> clazz); + public Object getVal(); + } \ No newline at end of file
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Wed Mar 27 17:56:08 2013 +0900 @@ -3,6 +3,7 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; +import org.msgpack.type.Value; public class TestCodeSegment extends CodeSegment { @@ -11,17 +12,17 @@ @Override public void run() { - System.out.println("index = " + arg1.data.index); - System.out.println("data = " + arg1.data.val); - System.out.println(arg1.data.val.getType()); + System.out.println("index = " + arg1.index); + System.out.println("data = " + arg1.getVal()); + System.out.println(((Value)arg1.getVal()).getType()); - if (arg1.data.index == 10) { + if (arg1.index == 10) { System.exit(0); return; } TestCodeSegment cs = new TestCodeSegment(); - cs.arg1.setKey("key1", arg1.data.index); + cs.arg1.setKey("key1", arg1.index); // DataSegment.get("local").update ods.update("local", "key1", "String data");
--- a/src/alice/test/codesegment/local/bitonicsort/MakeData.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/MakeData.java Wed Mar 27 17:56:08 2013 +0900 @@ -19,8 +19,8 @@ @Override public void run() { // This conversion over head should be remove. - SortConfig conf = info1.data.asClass(info1, SortConfig.class); - DataList list = (DataList)info2.data.obj; + SortConfig conf = info1.asClass(info1, SortConfig.class); + DataList list = info2.asClass(info2, DataList.class); int size = conf.getLength(); Random rnd = new Random(); for (int i = 0; i < size; i++){
--- a/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/OddPhase.java Wed Mar 27 17:56:08 2013 +0900 @@ -27,16 +27,15 @@ @Override public void run() { - RangeInfo info = info0.data.asClass(info0, RangeInfo.class); - int sort_count = info5.data.asInteger(info5); - int count = info6.data.asInteger(info6); + RangeInfo info = info0.asClass(info0, RangeInfo.class); + int sort_count = info5.asInteger(info5); + int count = info6.asInteger(info6); //System.out.println("count is " +count); int i = info.range; if (count<sort_count){ - DataList list3 = info1.data.asClass(info1, DataList.class); - DataList list1 = (DataList)info1.data.obj; - DataList list2 = (DataList)info2.data.obj; + DataList list1 = info1.asClass(info1, DataList.class); + DataList list2 = info2.asClass(info1, DataList.class); Sort.quickSort(list1,0,list1.table.length-1); Sort.quickSort(list2,0,list2.table.length-1); @@ -50,13 +49,13 @@ if (i+2 < SetInfo.array.length){ String f = (count%2==1) ? SetInfo.array[i] : SetInfo.array[i+1]; String b = (count%2==1) ? SetInfo.array[i+1] : SetInfo.array[i+2]; - new OddPhase(info0.data.key, f, b,count,info6.data.key); + new OddPhase(info0.key, f, b,count,info6.key); } } else { ods.put(SetInfo.result[i*2], info1); ods.put(SetInfo.result[i*2+1], info2); } - ods.update(info6.data.key, count+1); + ods.update(info6.key, count+1); }
--- a/src/alice/test/codesegment/local/bitonicsort/SetTask.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/SetTask.java Wed Mar 27 17:56:08 2013 +0900 @@ -16,8 +16,8 @@ @Override public void run() { - SortConfig conf = info1.data.asClass(info1, SortConfig.class); - DataList list = (DataList)info2.data.obj; + SortConfig conf = info1.asClass(info1, SortConfig.class); + DataList list = info2.asClass(info1, DataList.class); int sort_count = conf.getSplitNum()*2; ods.put("sort_count", sort_count*2);
--- a/src/alice/test/codesegment/local/bitonicsort/ShowData.java Wed Mar 27 17:30:52 2013 +0900 +++ b/src/alice/test/codesegment/local/bitonicsort/ShowData.java Wed Mar 27 17:56:08 2013 +0900 @@ -22,11 +22,11 @@ @Override public void run() { System.out.println(System.currentTimeMillis() -SetTask.t +" ms"); - int cnt = info0.data.asInteger(info0); + int cnt = info0.asInteger(info0); int size = 0; for (int i= 0;i < cnt; i++){ - DataList dlist = (DataList)info[i].data.obj; + DataList dlist = info[i].asClass(info[i], DataList.class); size += dlist.table.length; } @@ -34,7 +34,7 @@ int start = 0; for (int i= 0;i < cnt; i++){ - DataList dlist = (DataList)info[i].data.obj; + DataList dlist = info[i].asClass(info[i], DataList.class); System.arraycopy(dlist.table, 0, list.table, start, dlist.table.length); start += dlist.table.length; }