Test RLE masks on distinct aggregations
@@ -18,6 +18,7 @@ import com.facebook.presto.common.Page;
import com.facebook.presto.common.block.Block;
import com.facebook.presto.common.block.BlockBuilder;
import com.facebook.presto.common.block.RunLengthEncodedBlock;
+import com.facebook.presto.common.type.BooleanType;
import com.facebook.presto.operator.GroupByIdBlock;
import com.facebook.presto.operator.UpdateMemory;
import com.google.common.primitives.Ints;
@@ -148,9 +149,27 @@ public final class AggregationTestUtils
assertEquals(aggregationWithDupes, aggregation, "Inconsistent results with mask");
+ // Re-run the duplicated inputs with RLE masks
+ System.arraycopy(maskPagesWithRle(true, pages), 0, dupedPages, 0, pages.length);
+ System.arraycopy(maskPagesWithRle(false, pages), 0, dupedPages, pages.length, pages.length);
+ Object aggregationWithRleMasks = aggregation(function, createArgs(function), maskChannel, dupedPages);
+
+ assertEquals(aggregationWithRleMasks, aggregation, "Inconsistent results with RLE mask");
+
return aggregation;
}
+ // Adds the mask as the last channel
+ private static Page[] maskPagesWithRle(boolean maskValue, Page... pages)
+ {
+ Page[] maskedPages = new Page[pages.length];
+ for (int i = 0; i < pages.length; i++) {
+ Page page = pages[i];
+ maskedPages[i] = page.appendColumn(new RunLengthEncodedBlock(BooleanType.createBlockForSingleNonNullValue(maskValue), page.getPositionCount()));
+ }
+ return maskedPages;
+ }
+
// Adds the mask as the last channel
private static Page[] maskPages(boolean maskValue, Page... pages)
{
