Code review comment: ```suggestion        * After computing the number of lines before each range, we can find the line number in original file as numLinesBeforeOffset + lineNumInCurrentOffset ```

Code before review:
public PCollection<Row> expand(PCollection<Row> records) {
/*
* At this point the line number in RecordWithMetadata contains the relative line offset from the beginning of the read range.
*
* To compute the absolute position from the beginning of the input we group the lines within the same ranges, and evaluate the size of each range.
*/
Trigger currentTrigger = records.getWindowingStrategy().getTrigger();
Set<Trigger> allowedTriggers =
ImmutableSet.of(
Repeatedly.forever(AfterWatermark.pastEndOfWindow()), DefaultTrigger.of());
Preconditions.checkArgument(
allowedTriggers.contains(currentTrigger),
String.format(
"getWithRecordNumMetadata only support the default trigger not. %s", currentTrigger));
PCollection<KV<KV<String, Long>, Row>> recordsGroupedByFileAndRange =
records
.apply("AddFileNameAndRange", ParDo.of(new AddFileNameAndRange()))
.setCoder(
KvCoder.of(
KvCoder.of(StringUtf8Coder.of(), BigEndianLongCoder.of()),
RowCoder.of(RecordWithMetadata.getSchema())));
PCollectionView<Map<KV<String, Long>, Long>> rangeSizes =
recordsGroupedByFileAndRange
.apply("CountRecordsForEachFileRange", Count.perKey())
.apply("SizesAsView", View.asMap());
PCollection<Integer> singletonPcoll =
records.getPipeline().apply("CreateSingletonPcoll", Create.of(Arrays.asList(1)));
/*
* For each (File, Offset) pair, calculate the number of lines occurring before the Range for each file
*
* After computing the number of lines before each range, we can find the line number in original file as numLiesBeforeOffset + lineNumInCurrentOffset
*/
PCollectionView<Map<KV<String, Long>, Long>> numRecordsBeforeEachRange =
singletonPcoll
.apply(
"ComputeNumRecordsBeforeRange",
ParDo.of(new ComputeRecordsBeforeEachRange(rangeSizes))
.withSideInputs(rangeSizes))
.apply("NumRecordsBeforeEachRangeAsView", View.asMap());
return recordsGroupedByFileAndRange
.apply(
"AssignLineNums",
ParDo.of(new AssignRecordNums(numRecordsBeforeEachRange))
.withSideInputs(numRecordsBeforeEachRange))
.setRowSchema(RecordWithMetadata.getSchema());
}

Line under review: * After computing the number of lines before each range, we can find the line number in original file as numLiesBeforeOffset + lineNumInCurrentOffset

Code after addressing the review:
public PCollection<Row> expand(PCollection<Row> records) {
/*
* At this point the line number in RecordWithMetadata contains the relative line offset from the beginning of the read range.
*
* To compute the absolute position from the beginning of the input we group the lines within the same ranges, and evaluate the size of each range.
*/
Trigger currentTrigger = records.getWindowingStrategy().getTrigger();
Set<Trigger> allowedTriggers =
ImmutableSet.of(
Repeatedly.forever(AfterWatermark.pastEndOfWindow()), DefaultTrigger.of());
Preconditions.checkArgument(
allowedTriggers.contains(currentTrigger),
String.format(
"getWithRecordNumMetadata(true) only supports the default trigger not: %s",
currentTrigger));
PCollection<KV<KV<String, Long>, Row>> recordsGroupedByFileAndRange =
records
.apply("AddFileNameAndRange", ParDo.of(new AddFileNameAndRange()))
.setCoder(
KvCoder.of(
KvCoder.of(StringUtf8Coder.of(), BigEndianLongCoder.of()),
RowCoder.of(RecordWithMetadata.getSchema())));
PCollectionView<Map<String, Iterable<KV<Long, Long>>>> rangeSizes =
recordsGroupedByFileAndRange
.apply("CountRecordsForEachFileRange", Count.perKey())
.apply(
MapElements.into(
TypeDescriptors.kvs(
TypeDescriptors.strings(),
TypeDescriptors.kvs(
TypeDescriptors.longs(), TypeDescriptors.longs())))
.<KV<KV<String, Long>, Long>>via(
x ->
KV.of(
x.getKey().getKey(), KV.of(x.getKey().getValue(), x.getValue()))))
.apply("SizesAsView", View.asMultimap());
PCollection<Integer> singletonPcoll =
records.getPipeline().apply("CreateSingletonPcoll", Create.of(Arrays.asList(1)));
/*
* For each (File, Offset) pair, calculate the number of lines occurring before the Range for each file
*
* After computing the number of lines before each range, we can find the line number in original file as numLinesBeforeOffset + lineNumInCurrentOffset
*/
PCollectionView<Map<KV<String, Long>, Long>> numRecordsBeforeEachRange =
singletonPcoll
.apply(
"ComputeNumRecordsBeforeRange",
ParDo.of(new ComputeRecordsBeforeEachRange(rangeSizes))
.withSideInputs(rangeSizes))
.apply("NumRecordsBeforeEachRangeAsView", View.asMap());
return recordsGroupedByFileAndRange
.apply(
"AssignLineNums",
ParDo.of(new AssignRecordNums(numRecordsBeforeEachRange))
.withSideInputs(numRecordsBeforeEachRange))
.setRowSchema(RecordWithMetadata.getSchema());
}