Пример #1
0
  /**
   * Adds a buffer to the subpartition with the given index.
   *
   * <p>For PIPELINED results, this will trigger the deployment of consuming tasks after the first
   * buffer has been added.
   */
  public void add(Buffer buffer, int subpartitionIndex) throws IOException {
    boolean success = false;

    try {
      checkInProduceState();

      final ResultSubpartition subpartition = subpartitions[subpartitionIndex];

      synchronized (subpartition) {
        success = subpartition.add(buffer);

        // Update statistics
        totalNumberOfBuffers++;
        totalNumberOfBytes += buffer.getSize();
      }
    } finally {
      if (success) {
        notifyPipelinedConsumers();
      } else {
        buffer.recycle();
      }
    }
  }