changeset 192:a8b0d44bbe68 working

not use value object in bitonic
author e095732
date Thu, 07 Mar 2013 22:20:54 +0900
parents 60051454e443
children 7c695190fa2b
files src/alice/codesegment/OutputDataSegment.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/codesegment/local/bitonicsort/EvenPhase.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 7 files changed, 33 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/codesegment/OutputDataSegment.java	Thu Mar 07 22:20:54 2013 +0900
@@ -51,11 +51,7 @@
 	}
 	
 	public <T> void update(String key, T val) {
-		try {
-			DataSegment.getLocal().update(key, SingletonMessage.getInstance().unconvert(val));
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
+		DataSegment.getLocal().update(key, val);
 	}
 	
 	
--- a/src/alice/test/codesegment/local/TestCodeSegment.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/TestCodeSegment.java	Thu Mar 07 22:20:54 2013 +0900
@@ -3,6 +3,7 @@
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
+import alice.test.codesegment.local.bitonicsort.DataList;
 
 public class TestCodeSegment extends CodeSegment {
 	
@@ -19,11 +20,12 @@
 	
 	@Override
 	public void run() {
-		if(count > 1){
+		if(count > 0){
 			System.out.println(System.currentTimeMillis() - StartCodeSegment.t);
 			System.exit(1);
 		}
-		//System.out.println(arg1.obj);
+		DataList list = (DataList)arg1.obj;
+		System.out.println("ssss"+list.table);
 		//System.out.println(arg1.val);
 		
 		//ods.update("key1",arg1.asInteger()+1);
--- a/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/EvenPhase.java	Thu Mar 07 22:20:54 2013 +0900
@@ -42,42 +42,38 @@
 		int count = info6.asInteger();
 		
 		if (info2==null){
-			DataList list = info1.asClass(DataList.class);
+			DataList list = (DataList)info1.obj;
 			if (count > sort_count){
-				ods.update("local", "array"+info.range, list);
+				ods.update("array"+info.range, list);
 				return;
 			}
-			ods.put("local", info.range+"f", "dummy");
-			ods.put("local", info.range+"b", list);
+			ods.put(info.range+"f", "dummy");
+			ods.put(info.range+"b", list);
 			//System.out.println("next Odd "+info.range+" "+info.range+"b"+" "+(info.range+1)+"f");
 			new OddPhase(info0.key,info.range+"b",(info.range+1)+"f",count,info6.key);
 		} else {
-			DataList list1 = info1.asClass(DataList.class);
-			DataList list2 = info2.asClass(DataList.class);
+			DataList list1 = (DataList)info1.obj;
+			DataList list2 = (DataList)info2.obj;
 
 			DataList list3 = new DataList();
 			list3.table.addAll(list1.table);
 			list3.table.addAll(list2.table);
 			
 			if (count > sort_count){
-				ods.update("local", "array"+info.range, list3);
+				ods.update("array"+info.range, list3);
 				return;
 			}
 			int block_num = info3.asInteger();
 			Sort.quickSort(list3.table, 0, list3.table.size()-1);
 			if (!info.lastFlag){
-				ods.put("local", info.range+"f",
-						list3.createDataList(0, block_num/2));
-				ods.put("local", info.range+"b",
-						list3.createDataList(block_num/2, block_num/2));
+				ods.put(info.range+"f",	list3.createDataList(0, block_num/2));
+				ods.put(info.range+"b",	list3.createDataList(block_num/2, block_num/2));
 				//System.out.println("next Odd "+info.range+" "+ info.range+"b"+" "+(info.range+1)+"f");
 				new OddPhase(info0.key,info.range+"b",(info.range+1)+"f",count,info6.key);
 			} else {
 				int last_block_num = info4.asInteger();
-				ods.put("local", info.range+"f", 
-						list3.createDataList(0, block_num/2));
-				ods.put("local", info.range+"b", 
-						list3.createDataList(block_num/2, last_block_num));
+				ods.put(info.range+"f", list3.createDataList(0, block_num/2));
+				ods.put(info.range+"b", list3.createDataList(block_num/2, last_block_num));
 				//System.out.println("next Odd "+info.range+" "+ info.range+"b");
 				new OddPhase(info0.key ,info.range+"b",count,info6.key);
 			}
--- a/src/alice/test/codesegment/local/bitonicsort/MakeData.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/MakeData.java	Thu Mar 07 22:20:54 2013 +0900
@@ -26,6 +26,6 @@
 			list.table.add(rnd.nextInt(100000));
 		}
 		
-		ods.update("local", "list", list);
+		ods.update("list", list);
 	}
 }
--- a/src/alice/test/codesegment/local/bitonicsort/OddPhase.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/OddPhase.java	Thu Mar 07 22:20:54 2013 +0900
@@ -41,15 +41,15 @@
 		int count = info6.asInteger();
 		//System.out.println("count is " +count);
 		if (info2==null){
-			DataList list = info1.asClass(DataList.class);
+			DataList list = (DataList)info1.obj;
 			if (count > sort_count){
-				ods.update("local", "array"+info.range, list);
+				ods.update("array"+info.range, list);
 				return;
 			}
 			Sort.quickSort(list.table,0,list.table.size()-1);
 			if (!info.lastFlag){ 
-				ods.put("local", info.range+"f", list.createDataList(0, block_num/2));
-				ods.put("local", info.range+"b", list.createDataList(block_num/2, block_num/2));
+				ods.put(info.range+"f", list.createDataList(0, block_num/2));
+				ods.put(info.range+"b", list.createDataList(block_num/2, block_num/2));
 				
 				if (info.range==0){
 					//System.out.println("next Even "+info.range+" "+info.range+"f");	
@@ -59,27 +59,27 @@
 					new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f",count,info6.key);
 				}
 			} else {
-				ods.put("local", info.range+"f",list);
-				ods.put("local", info.range+"b","dummy");
+				ods.put(info.range+"f",list);
+				ods.put(info.range+"b","dummy");
 				//System.out.println("next Even "+info.range+" "+ (info.range-1)+"b"+" "+(info.range)+"f");
 				new EvenPhase(info0.key,(info.range-1)+"b",info.range+"f",count,info6.key);
 			}
 			
 		} else {
-			DataList list1 = info1.asClass(DataList.class);
-			DataList list2 = info2.asClass(DataList.class);
+			DataList list1 = (DataList)info1.obj;
+			DataList list2 = (DataList)info2.obj;
 			
 			DataList list3 = new DataList();
 			list3.table.addAll(list1.table);
 			list3.table.addAll(list2.table);
 			if (count > sort_count){
-				ods.update("local", "array"+info.range, list3);
+				ods.update("array"+info.range, list3);
 				return;
 			}
 
 			Sort.quickSort(list3.table,0,list3.table.size()-1);
-			ods.put("local", info.range+"f", list3.createDataList(0, block_num/2));
-			ods.put("local", info.range+"b", list3.createDataList(block_num/2, block_num/2));
+			ods.put(info.range+"f", list3.createDataList(0, block_num/2));
+			ods.put(info.range+"b", list3.createDataList(block_num/2, block_num/2));
 
 			if (info.range==0){
 				//System.out.println("next Even2b "+info.range+" "+ info.range+"f");
--- a/src/alice/test/codesegment/local/bitonicsort/SetTask.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/SetTask.java	Thu Mar 07 22:20:54 2013 +0900
@@ -17,7 +17,7 @@
 	@Override
 	public void run() {
 		SortConfig conf = info1.asClass(SortConfig.class);
-		DataList list = info2.asClass(DataList.class);
+		DataList list = (DataList)info2.obj;
 		//System.out.println(list.table);
 		
 		int sort_count = conf.getSplitNum();
@@ -36,13 +36,13 @@
 			int i = 0;
 			for (i = 0;i< conf.getSplitNum()-1; i++){
 				ods.put("local", "range"+i, new RangeInfo(i,false));
-				ods.update("local", key+i, list.createDataList(i*block_num, block_num));
+				ods.update(key+i, list.createDataList(i*block_num, block_num));
 				ods.update("local", "count"+i, 0);
 				new OddPhase("range"+i,key+i,0,"count"+i);
 			}
 			
 			ods.put("local", "range"+i, new RangeInfo(i,true));
-			ods.update("local", key+i, list.createDataList(i*block_num, last_block_num));
+			ods.update(key+i, list.createDataList(i*block_num, last_block_num));
 			ods.update("local", "count"+i, 0);
 			ods.put("local","arraynum",i+1);
 			new OddPhase("range"+i,key+i,0,"count"+i);
--- a/src/alice/test/codesegment/local/bitonicsort/ShowData.java	Thu Mar 07 21:43:51 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/ShowData.java	Thu Mar 07 22:20:54 2013 +0900
@@ -28,7 +28,8 @@
 		int cnt = info0.asInteger();
 		List<Integer> list = new ArrayList<Integer>();
 		for (int i= 0;i < cnt; i++){
-			list.addAll(info[i].asClass(DataList.class).table);
+			DataList dlist = (DataList)info[i].obj;
+			list.addAll(dlist.table);
 		}
 		System.out.println("size check :"+ list.size());
 		Sort.check(list);