protected int buildTabletInsertionBuffer(TabletInsertionEvent event) throws WALPipeException {
    final ByteBuffer buffer;
    final TCommitId commitId;

    // event instanceof PipeInsertNodeTabletInsertionEvent)
    final PipeInsertNodeTabletInsertionEvent pipeInsertNodeTabletInsertionEvent =
        (PipeInsertNodeTabletInsertionEvent) event;
    commitId =
        new TCommitId(
            pipeInsertNodeTabletInsertionEvent.getReplicateIndexForIoTV2(),
            pipeInsertNodeTabletInsertionEvent.getCommitterKey().getRestartTimes(),
            pipeInsertNodeTabletInsertionEvent.getRebootTimes());

    // Read the bytebuffer from the wal file and transfer it directly without serializing or
    // deserializing if possible
    final InsertNode insertNode =
        pipeInsertNodeTabletInsertionEvent.getInsertNodeViaCacheIfPossible();
    // PipeConsensus will transfer binary data to TPipeConsensusTransferReq
    final ProgressIndex progressIndex = pipeInsertNodeTabletInsertionEvent.getProgressIndex();
    if (Objects.isNull(insertNode)) {
      buffer = pipeInsertNodeTabletInsertionEvent.getByteBuffer();
      batchReqs.add(
          PipeConsensusTabletBinaryReq.toTPipeConsensusTransferReq(
              buffer, commitId, consensusGroupId, progressIndex, thisDataNodeId));
    } else {
      buffer = insertNode.serializeToByteBuffer();
      batchReqs.add(
          PipeConsensusTabletInsertNodeReq.toTPipeConsensusTransferReq(
              insertNode, commitId, consensusGroupId, progressIndex, thisDataNodeId));
    }

    return buffer.limit();
  }
Try offer {@link Event} into cache if the given {@link Event} is not duplicated.

@param event the given {@link Event}
@return {@link true} if the batch can be transferred
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/protocol/pipeconsensus/payload/builder/PipeConsensusTransferBatchReqBuilder.java