Skip to content

Commit

Permalink
Be aware of starting line index for files (Bears-R-Us#3314)
Browse files Browse the repository at this point in the history
Some files have data meant to be distributed across multiple locales
therefore we have to be aware of the lower bound of the line indices to
be read in. In order to do this, we skip over the lines until this lower
bound is reached. Since the domains are continuous, we don't need to
worry about upper bounds.

Signed-off-by: Shreyas Khandekar <[email protected]>
  • Loading branch information
ShreyasKhandekar authored Jun 12, 2024
1 parent c900224 commit aed98ea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/CSVMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,22 @@ module CSVMsg {
moduleName=getModuleName(),
errorClass="DatasetNotFoundError");

// The same file might have data meant to be distributed across locales,
// Therefore the 0th line in the file may not correspond to the 0th index of the array
// So we skip over lines till we get the lower bound of the intersection
// But the filedom may not start at 0, so we need to substract that offset
for 0..<(intersection.low-filedom.low) {
try {fr.advanceThrough(b'\n');}
catch {
throw getErrorWithContext(
msg="This CSV file is missing lines.",
lineNumber=getLineNumber(),
routineName=getRoutineName(),
moduleName=getModuleName(),
errorClass="IOError");
}
}

var line = new csvLine(t, colIdx, colDelim);
for x in intersection {
try {
Expand Down

0 comments on commit aed98ea

Please sign in to comment.