Пример #1
0
  @Override
  public void finish() {
    if (finished) {
      return;
    }

    ChannelSet channelSet = channelSetBuilder.build();
    setSupplier.setChannelSet(channelSet);
    operatorContext.recordGeneratedOutput(channelSet.getEstimatedSize(), channelSet.size());
    finished = true;
  }
  @Override
  public void addInput(Page page) {
    requireNonNull(page, "page is null");
    checkState(!finishing, "Operator is finishing");
    checkState(channelSet != null, "Set has not been built yet");
    checkState(outputPage == null, "Operator still has pending output");

    // create the block builder for the new boolean column
    // we know the exact size required for the block
    BlockBuilder blockBuilder = BOOLEAN.createFixedSizeBlockBuilder(page.getPositionCount());

    Page probeJoinPage = new Page(page.getBlock(probeJoinChannel));

    // update hashing strategy to use probe cursor
    for (int position = 0; position < page.getPositionCount(); position++) {
      if (probeJoinPage.getBlock(0).isNull(position)) {
        throw new PrestoException(
            NOT_SUPPORTED,
            "NULL values are not allowed on the probe side of SemiJoin operator. See the query plan for details.");
      } else {
        boolean contains = channelSet.contains(position, probeJoinPage);
        if (!contains && channelSet.containsNull()) {
          blockBuilder.appendNull();
        } else {
          BOOLEAN.writeBoolean(blockBuilder, contains);
        }
      }
    }

    // add the new boolean column to the page
    Block[] sourceBlocks = page.getBlocks();
    Block[] outputBlocks =
        new Block[sourceBlocks.length + 1]; // +1 for the single boolean output channel

    System.arraycopy(sourceBlocks, 0, outputBlocks, 0, sourceBlocks.length);
    outputBlocks[sourceBlocks.length] = blockBuilder.build();

    outputPage = new Page(outputBlocks);
  }
Пример #3
0
 public static void saveChannelSet(Context context, ChannelSet set) {
   AppUtils.instance(context).saveChannelIds(set.getChannelIds());
 }