Skip to content

Commit

Permalink
fix number of segments
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsoft committed Jan 31, 2024
1 parent faee937 commit 15d8420
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/dev/morling/onebrc/CalculateAverage_dpsoft.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ private static List<FileSegment> getMemorySegments(int numberOfSegments) throws
return segments;
}

while (segmentSize >= Integer.MAX_VALUE) {
numberOfSegments += 1;
segmentSize = fileSize / numberOfSegments;
}

try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r")) {
for (int i = 0; i < numberOfSegments; i++) {
long segStart = i * segmentSize;
Expand Down

0 comments on commit 15d8420

Please sign in to comment.