public static boolean testMask(@Nullable Block masks, int index) { if (masks != null) { return BOOLEAN.getBoolean(masks, index); } return true; } }
@Override Object extractValue(Block block, int position) { return BOOLEAN.getBoolean(block, position); }
@Override public void deserialize(Block block, int index, TriStateBooleanState state) { state.setByte(BOOLEAN.getBoolean(block, index) ? TRUE_VALUE : FALSE_VALUE); } }
@Override public void writeJsonValue(JsonGenerator jsonGenerator, Block block, int position, ConnectorSession session) throws IOException { if (block.isNull(position)) { jsonGenerator.writeNull(); } else { boolean value = BOOLEAN.getBoolean(block, position); jsonGenerator.writeBoolean(value); } } }
@Override public void deserialize(Block block, int index, NullableBooleanState state) { state.setNull(false); state.setBoolean(BOOLEAN.getBoolean(block, index)); } }
@Override public void setField(Block block, int position) { value.set(BooleanType.BOOLEAN.getBoolean(block, position)); rowInspector.setStructFieldData(row, field, value); } }
private static Page filter(Page page, Block mask) { int[] ids = new int[mask.getPositionCount()]; int next = 0; for (int i = 0; i < page.getPositionCount(); ++i) { if (BOOLEAN.getBoolean(mask, i)) { ids[next++] = i; } } return page.getPositions(ids, 0, next); }
@Override public void deserialize(Block block, int index, T state) { checkArgument(block instanceof AbstractRowBlock); ColumnarRow columnarRow = toColumnarRow(block); state.setFirstNull(BOOLEAN.getBoolean(columnarRow.getField(0), index)); state.setSecondNull(BOOLEAN.getBoolean(columnarRow.getField(1), index)); if (!state.isFirstNull()) { readFirstField(columnarRow.getField(2), index, state); } if (!state.isSecondNull()) { state.setSecondPosition(index); state.setSecondBlock(columnarRow.getField(3)); } } }
private static boolean executeFilter(Operator operator) { Page page = getAtMostOnePage(operator, SOURCE_PAGE); boolean value; if (page != null) { assertEquals(page.getPositionCount(), 1); assertEquals(page.getChannelCount(), 1); assertTrue(BOOLEAN.getBoolean(page.getBlock(0), 0)); value = true; } else { value = false; } return value; }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.BOOLEAN, nativeContainerType = boolean.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.BOOLEAN, nativeContainerType = boolean.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } return notEqual(BOOLEAN.getBoolean(left, leftPosition), BOOLEAN.getBoolean(right, rightPosition)); } }
public static PrestoThriftBlock fromBlock(Block block) { int positions = block.getPositionCount(); if (positions == 0) { return booleanData(new PrestoThriftBoolean(null, null)); } boolean[] nulls = null; boolean[] booleans = null; for (int position = 0; position < positions; position++) { if (block.isNull(position)) { if (nulls == null) { nulls = new boolean[positions]; } nulls[position] = true; } else { if (booleans == null) { booleans = new boolean[positions]; } booleans[position] = BOOLEAN.getBoolean(block, position); } } return booleanData(new PrestoThriftBoolean(nulls, booleans)); }
public static boolean testMask(@Nullable Block masks, int index) { if (masks != null) { return BOOLEAN.getBoolean(masks, index); } return true; } }
@Override Object extractValue(Block block, int position) { return BOOLEAN.getBoolean(block, position); }
public static long computeSampleWeight(@Nullable Block masks, @Nullable Block sampleWeights, int index) { if (masks != null) { // TODO: support for DISTINCT should be removed from sampled aggregations, // since it doesn't make sense to try to process distinct rows when the data is sampled. // DISTINCT is enabled, so ignore the sample weight return BOOLEAN.getBoolean(masks, index) ? 1 : 0; } else { return sampleWeights != null ? BIGINT.getLong(sampleWeights, index) : 1; } } }
@Override public void setField(Block block, int position) { value.set(BooleanType.BOOLEAN.getBoolean(block, position)); rowInspector.setStructFieldData(row, field, value); } }
@Override public void deserialize(Block block, int index, TriStateBooleanState state) { if (block.isNull(index)) { state.setByte(NULL_VALUE); } else { state.setByte(BOOLEAN.getBoolean(block, index) ? TRUE_VALUE : FALSE_VALUE); } } }
@Override public void deserialize(Block block, int index, NullableBooleanState state) { state.setNull(block.isNull(index)); if (!state.isNull()) { state.setBoolean(BOOLEAN.getBoolean(block, index)); } } }
@Override public void addPage(Page page) { int positionCount = page.getPositionCount(); Block maskBlock = null; if (maskChannel >= 0) { maskBlock = page.getBlock(maskChannel); } // get the group id for each position Block block = page.getBlock(hashChannel); for (int position = 0; position < positionCount; position++) { // skip masked rows if (maskBlock != null && !BOOLEAN.getBoolean(maskBlock, position)) { continue; } // get the group for the current row putIfAbsent(position, block); } }
@Override public void addPage(Page page) { Block maskBlock = null; if (maskChannel >= 0) { maskBlock = page.getBlock(maskChannel); } if (canProcessDictionary(page)) { addDictionaryPage(page); return; } // get the group id for each position int positionCount = page.getPositionCount(); for (int position = 0; position < positionCount; position++) { // skip masked rows if (maskBlock != null && !BOOLEAN.getBoolean(maskBlock, position)) { continue; } // get the group for the current row putIfAbsent(position, page); } }
@Override public GroupByIdBlock getGroupIds(Page page) { int positionCount = page.getPositionCount(); // we know the exact size required for the block BlockBuilder blockBuilder = BIGINT.createFixedSizeBlockBuilder(positionCount); Block maskBlock = null; if (maskChannel >= 0) { maskBlock = page.getBlock(maskChannel); } if (canProcessDictionary(page)) { Block groupIds = processDictionary(page); return new GroupByIdBlock(nextGroupId, groupIds); } // get the group id for each position for (int position = 0; position < positionCount; position++) { // skip masked rows if (maskBlock != null && !BOOLEAN.getBoolean(maskBlock, position)) { blockBuilder.appendNull(); continue; } // get the group for the current row int groupId = putIfAbsent(position, page); // output the group id for this row BIGINT.writeLong(blockBuilder, groupId); } return new GroupByIdBlock(nextGroupId, blockBuilder.build()); }