You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In case the serialization format (lang) is not provided we have to iterate all supported formats to find the best suitable.
This peace of code can be optimized using file rewinding or parallel running.
To compare:
Standard sequence reading
privatestaticvoidloadStd(Pathp, intn, longlines) throwsIOException {
intstep = n / 100;
for (inti = 0; i < n; i++) {
if (i % step == 0) {
System.out.print("#");
}
try (BufferedReaderr = Files.newBufferedReader(p)) {
if (lines != r.lines().count()) {
thrownewIllegalStateException();
}
}
}
System.out.println();
}
vs SeekableByteChannel reading
privatestaticvoidloadNio(Pathp, intn, longlines) throwsIOException {
intstep = n / 100;
try (SeekableByteChannelchanel = Files.newByteChannel(p, StandardOpenOption.READ)) {
for (inti = 0; i < n; i++) {
if (i % step == 0) {
System.out.print("#");
}
BufferedReaderr = newBufferedReader(Channels.newReader(chanel, StandardCharsets.UTF_8));
if (lines != r.lines().count()) {
thrownewIllegalStateException();
}
chanel.position(0);
}
}
System.out.println();
}
sszuev
changed the title
load optimization: use SeekableInputStream if possible
load optimization: use Seekable/Parallel reading if possible
Apr 9, 2022
sszuev
changed the title
load optimization: use Seekable/Parallel reading if possible
[investigation] possible load optimization: use Seekable/Parallel reading
Aug 23, 2022
In case the serialization format (lang) is not provided we have to iterate all supported formats to find the best suitable.
This peace of code can be optimized using file rewinding or parallel running.
To compare:
Standard sequence reading
vs
SeekableByteChannel
readingvs concurrent reading
The text was updated successfully, but these errors were encountered: