public CalcResult merge(CalcResult resultsToAdd) { if (!isCompatible(resultsToAdd)) { throw new IllegalArgumentException("Parameter is not a compatible type"); MedianResult moreResults = (MedianResult) resultsToAdd; if (isOptimized() || moreResults.isOptimized()) { throw new IllegalArgumentException( "Optimized median results cannot be merged."); List toAdd = (ArrayList) moreResults.getList(); List newList = new ArrayList(); newList.add((Comparable) values[k]); return new MedianResult(newList); } else { throw new IllegalArgumentException(
public CalcResult merge(CalcResult resultsToAdd) { if (!isCompatible(resultsToAdd)) { throw new IllegalArgumentException( "Parameter is not a compatible type"); MedianResult moreResults = (MedianResult) resultsToAdd; if (isOptimized() || moreResults.isOptimized()) { throw new IllegalArgumentException("Optimized median results cannot be merged."); List toAdd = (ArrayList) moreResults.getList(); List newList = new ArrayList(); newList.add((Comparable) values[k]); return new MedianResult(newList); } else { throw new IllegalArgumentException(
public CalcResult merge(CalcResult resultsToAdd) { if (!isCompatible(resultsToAdd)) { throw new IllegalArgumentException( "Parameter is not a compatible type"); MedianResult moreResults = (MedianResult) resultsToAdd; if (isOptimized() || moreResults.isOptimized()) { throw new IllegalArgumentException("Optimized median results cannot be merged."); List toAdd = (ArrayList) moreResults.getList(); List newList = new ArrayList(); newList.add((Comparable) values[k]); return new MedianResult(newList); } else { throw new IllegalArgumentException(
public CalcResult getResult() { if (median != null) { // median was overwritten by an optimization return new MedianResult(median); } else if (list.size() < 1) { // no items in the list return CalcResult.NULL_RESULT; } else { // we have a list; create a CalcResult containing the list return new MedianResult(list); } }
public CalcResult getResult() { if (median != null) { // median was overwritten by an optimization return new MedianResult(median); } else if (list.size() < 1) { // no items in the list return null; } else { // we have a list; create a CalcResult containing the list return new MedianResult(list); } }
vals.add(new Double(3.5)); vals.add(new Double(4.5)); CalcResult medianResult4 = new MedianResult(vals); CalcResult medianResult5 = medianResult4.merge(medianResult1); assertEquals(2.75, medianResult5.toDouble(), 0);
@Override public CalcResult wrap(Expression aggregateAttribute, Object value) { return new MedianVisitor.MedianResult(value); } },
public CalcResult getResult() { if (median != null) { // median was overwritten by an optimization return new MedianResult(median); } else if (list.size() < 1) { // no items in the list return CalcResult.NULL_RESULT; } else { // we have a list; create a CalcResult containing the list return new MedianResult(list); } }