| 50 | } |
| 51 | |
| 52 | bool TBlocksSubsetLineDataReader::ReadLine(TString* line, ui64* lineIdx) { |
| 53 | while (true) { |
| 54 | if (CurrentSubsetBlock >= SubsetBlocks.size()) { |
| 55 | return false; |
| 56 | } |
| 57 | if (EnclosingLineIdx < SubsetBlocks[CurrentSubsetBlock].End) { |
| 58 | bool enclosingReadResult = LineDataReader->ReadLine(&LineBuffer); |
| 59 | Y_ASSERT(enclosingReadResult); |
| 60 | |
| 61 | if (EnclosingLineIdx >= SubsetBlocks[CurrentSubsetBlock].Begin) { |
| 62 | // in a subset |
| 63 | *line = std::move(LineBuffer); |
| 64 | if (lineIdx) { |
| 65 | *lineIdx = LineIdx; |
| 66 | } |
| 67 | ++LineIdx; |
| 68 | ++EnclosingLineIdx; |
| 69 | return true; |
| 70 | } else { |
| 71 | ++EnclosingLineIdx; |
| 72 | } |
| 73 | } else { |
| 74 | ++CurrentSubsetBlock; |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | TIndexedSubsetLineDataReader::TIndexedSubsetLineDataReader(THolder<ILineDataReader>&& lineDataReader, TVector<ui64>&& subsetIndices) |