private Stream<AcidInputFormat.DeltaMetaData> filterDeltasByBucketId(AcidInputFormat.DeltaMetaData dmd, int bucketId) {
      Map<Integer, AcidInputFormat.DeltaFileMetaData> bucketFilesbyStmtId =
          dmd.getDeltaFiles().stream().filter(deltaFileMetaData -> deltaFileMetaData.getBucketId() == bucketId)
              .collect(Collectors.toMap(AcidInputFormat.DeltaFileMetaData::getStmtId, Function.identity()));
      if (bucketFilesbyStmtId.isEmpty()) {
        return Stream.empty();
      }
      // Keep only the relevant stmtIds
      List<Integer> stmtIds = dmd.getStmtIds().stream()
          .filter(stmtId -> bucketFilesbyStmtId.containsKey(stmtId))
          .collect(Collectors.toList());
      // For a small optimization clear the stmtIds from the files, if the delta is single statement delta
      List<AcidInputFormat.DeltaFileMetaData> bucketFiles = bucketFilesbyStmtId.values().stream()
          .map(file -> new AcidInputFormat.DeltaFileMetaData(file.getModTime(), file.getLength(), file.getAttemptId(),
              file.getFileId(), stmtIds.size() > 1 ? file.getStmtId() : null, bucketId))
          .collect(Collectors.toList());

      return Stream.of(new AcidInputFormat.DeltaMetaData(dmd.getMinWriteId(), dmd.getMaxWriteId(), stmtIds,
          dmd.getVisibilityTxnId(), bucketFiles));
  }
For every split we only want to keep the delete deltas, that contains files for that bucket.
If we filter out files, we might need to filter out statementIds from multistatement transactions.
@param dmd
@param bucketId
@return
ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcSplit.java