Hi Anastasiia, this is difficult because the input is usually read in parallel, i.e., an input file is split into several blogs which are independently read and processed by different threads (possibly on different machines). So it is difficult to have a sequential row number.
If all rows have the same length (number of bytes), you could compute the row number from the byte offset. If this is not given, you can only read the input sequentially. Flink does not provide InputFormats for this. So you would need to implement a custom InputFormat. You can also keep track of the number of elements that you processed in a Mapper, but this is probably not what you are looking for. Best, Fabian 2016-02-04 0:37 GMT+01:00 Анастасія Баша <nastja.ba...@mail.ru>: > Is there a way to get the current line number (or generally the number of > element currently being processed) inside a mapper? > The example is a matrix you read line-line by line from the file and need > both the row and the column numbers. Column number is easy to get, but how > to know the row number? > > Thanks a lot in advance, > Anastasiia >