public int size() {
    try {
      return defaultBatch.events.size()
          + endPointToBatch.values().stream()
              .map(batch -> batch.events.size())
              .reduce(0, Integer::sum);
    } catch (final Exception e) {
      LOGGER.warn(
          "Failed to get the size of PipeTransferBatchReqBuilder, return 0. Exception: {}",
          e.getMessage(),
          e);
      return 0;
    }
  }
Get all batches that have at least 1 event.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/payload/evolvable/batch/PipeTransferBatchReqBuilder.java