public static List<KafkaInputSplit> slice(long sliceSize, final KafkaInputSplit split) {
    if (split.getEndOffset() - split.getStartOffset() > sliceSize) {
      ImmutableList.Builder<KafkaInputSplit> builder = ImmutableList.builder();
      long start = split.getStartOffset();
      while (start < split.getEndOffset() - sliceSize) {
        builder.add(new KafkaInputSplit(split.topic,
            split.partition,
            start,
            start + sliceSize + 1,
            split.getPath()));
        start += sliceSize + 1;
      }
      // last split
      if (start < split.getEndOffset()) {
        builder.add(new KafkaInputSplit(split.topic,
            split.partition,
            start,
            split.getEndOffset(),
            split.getPath()));
      }
      return builder.build();
    }

    return Collections.singletonList(copyOf(split));
  }
Compute union of ranges between splits. Splits must share the same topic and partition

@param split1 left split
@param split2 right split

@return new split with a range including both splits.
kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaInputSplit.java