# HG changeset patch # User sugi # Date 1354174116 -32400 # Node ID 98a1292ae8ef73bba5eee405d4220d19a450b2e2 # Parent 206c7dd9cb484812a9d93c1fbc4b1e66e99dcccc add merge sort diff -r 206c7dd9cb48 -r 98a1292ae8ef src/alice/test/topology/mergesort/LocalMergeSort.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/mergesort/LocalMergeSort.java Thu Nov 29 16:28:36 2012 +0900 @@ -0,0 +1,8 @@ +package alice.test.topology.mergesort; + +public class LocalMergeSort { + public static void main(String[] args){ + SortConfig conf = new SortConfig(args); + new StartSort(conf).execute(); + } +} diff -r 206c7dd9cb48 -r 98a1292ae8ef src/alice/test/topology/mergesort/MergeArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/mergesort/MergeArray.java Thu Nov 29 16:28:36 2012 +0900 @@ -0,0 +1,74 @@ +package alice.test.topology.mergesort; + +import java.util.List; + +import org.msgpack.type.Value; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class MergeArray extends CodeSegment{ + + private Receiver info1 = ids.create(CommandType.TAKE); + private Receiver info2 = ids.create(CommandType.TAKE); + + int keyNum1; + int keyNum2; + + public MergeArray(int num1, int num2) { + keyNum1 = num1; + keyNum2 = num2; + String key1 = Integer.toString(num1); + String key2 = Integer.toString(num2); + info1.setKey("local", key1, 1); + info2.setKey("local", key2, 1); + + } + + @Override + public void run() { + List list1 = info1.asArray(); + List list2 = info2.asArray(); + + //System.out.println(list1); + //System.out.println(list2); + + int length = list1.size() + list2.size(); + int[] array = new int[length]; + + for (int i=0,k=0,j=0;iarray2){ + array[i]=array2; + k++; + if (k == list2.size()){ + for (i=i+1;i list = info.asArray(); + //System.out.println(list); + if (list.size() > 2){ + int num = 2*keyNum + 1; + int length = list.size()/2; + int[] array1 = new int[length]; + int[] array2 = new int[length]; + for (int i = 0;i list = info.asArray(); + for (int i =0; i+1< list.size();i++){ + if (list.get(i).asIntegerValue().getInt()>list.get(i+1).asIntegerValue().getInt()){ + System.out.println("MISS"); + System.exit(0); + } + //System.out.println(list.get(i).asIntegerValue().getInt()+","); + } + //System.out.println(list); + System.exit(0); + } + +} diff -r 206c7dd9cb48 -r 98a1292ae8ef src/alice/test/topology/mergesort/SortConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/mergesort/SortConfig.java Thu Nov 29 16:28:36 2012 +0900 @@ -0,0 +1,18 @@ +package alice.test.topology.mergesort; + + + +public class SortConfig { + int size; + boolean flag; + public SortConfig(String[] args){ + for (int i=0;i