diff --git a/src/main/java/com/yahoo/sketches/quantiles/Util.java b/src/main/java/com/yahoo/sketches/quantiles/Util.java index 4bdcb6e6e..353f66f2f 100644 --- a/src/main/java/com/yahoo/sketches/quantiles/Util.java +++ b/src/main/java/com/yahoo/sketches/quantiles/Util.java @@ -231,11 +231,6 @@ static void blockyTandemMergeSort(double[] keyArr, long[] valArr, int arrLen, in keyArr, valArr, 0, numblks, blkSize, arrLen); - - /* verify sorted order */ - for (int i = 0; i < arrLen-1; i++) { - assert keyArr[i] <= keyArr[i+1]; - } } /** diff --git a/src/test/java/com/yahoo/sketches/quantiles/UtilTest.java b/src/test/java/com/yahoo/sketches/quantiles/UtilTest.java index c400a95c3..193fa665d 100644 --- a/src/test/java/com/yahoo/sketches/quantiles/UtilTest.java +++ b/src/test/java/com/yahoo/sketches/quantiles/UtilTest.java @@ -186,8 +186,8 @@ private static void assertMergeTestPostcondition (double [] arr, long [] brr, i } - private static double [] makeMergeTestInput (int arrLen, int blkSize) { - double [] arr = new double [arrLen]; + private static double[] makeMergeTestInput(int arrLen, int blkSize) { + double[] arr = new double[arrLen]; double pick = Math.random (); @@ -236,18 +236,25 @@ public void checkBlockyTandemMergeSort() { * @param numTries number of tries * @param maxArrLen maximum length of array size */ - private static void testBlockyTandemMergeSort (int numTries, int maxArrLen) { - for (int arrLen = 0; arrLen <= maxArrLen; arrLen++) { + private static void testBlockyTandemMergeSort(int numTries, int maxArrLen) { + int arrLen = 0; + double[] arr = null; + for (arrLen = 0; arrLen <= maxArrLen; arrLen++) { for (int blkSize = 1; blkSize <= arrLen + 100; blkSize++) { for (int tryno = 1; tryno <= numTries; tryno++) { - double [] arr = makeMergeTestInput (arrLen, blkSize); - long [] brr = makeTheTandemArray (arr); - assertMergeTestPrecondition (arr, brr, arrLen, blkSize); - Util.blockyTandemMergeSort (arr, brr, arrLen, blkSize); - assertMergeTestPostcondition (arr, brr, arrLen); + arr = makeMergeTestInput(arrLen, blkSize); + long [] brr = makeTheTandemArray(arr); + assertMergeTestPrecondition(arr, brr, arrLen, blkSize); + Util.blockyTandemMergeSort(arr, brr, arrLen, blkSize); + /* verify sorted order */ + for (int i = 0; i < arrLen-1; i++) { + assert arr[i] <= arr[i+1]; + } + assertMergeTestPostcondition(arr, brr, arrLen); } } } + //System.out.printf ("Passed: testBlockyTandemMergeSort\n"); }