git-svn-id: svn://home0/checkDataIntegrity@3053 71dcc7fd-b1f2-4e5d-bb8e-274146e81173
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -24,12 +24,12 @@ public class Main {
|
|||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final AtomicLong count = new AtomicLong();
|
final AtomicLong count = new AtomicLong();
|
||||||
final AtomicLong countErr = new AtomicLong();
|
final AtomicLong countErr = new AtomicLong();
|
||||||
final ThreadLocal<byte[]> bufs0 = ThreadLocal.withInitial(() -> new byte[4096]);
|
final ThreadLocal<byte[]> bufs0 = ThreadLocal.withInitial(() -> new byte[8192]);
|
||||||
final ThreadLocal<byte[]> bufs1 = ThreadLocal.withInitial(() -> new byte[4096]);
|
final ThreadLocal<byte[]> bufs1 = ThreadLocal.withInitial(() -> new byte[8192]);
|
||||||
|
|
||||||
try (Stream<Path> walk = Files.walk(Path.of(path0))) {
|
try (Stream<Path> walk = Files.walk(Path.of(path0))) {
|
||||||
walk
|
walk
|
||||||
// .parallel()
|
.parallel()
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.forEach(p0 -> {
|
.forEach(p0 -> {
|
||||||
long cnt = count.incrementAndGet();
|
long cnt = count.incrementAndGet();
|
||||||
@@ -43,21 +43,25 @@ public class Main {
|
|||||||
final byte[] buf0 = bufs0.get();
|
final byte[] buf0 = bufs0.get();
|
||||||
final byte[] buf1 = bufs1.get();
|
final byte[] buf1 = bufs1.get();
|
||||||
try (InputStream inputStream0 = Files.newInputStream(p0); InputStream inputStream1 = Files.newInputStream(p1);) {
|
try (InputStream inputStream0 = Files.newInputStream(p0); InputStream inputStream1 = Files.newInputStream(p1);) {
|
||||||
final int len0 = inputStream0.read(buf0);
|
int len0, len1;
|
||||||
final int len1 = inputStream1.read(buf1);
|
do {
|
||||||
if (len0 != len1) {
|
len0 = inputStream0.read(buf0);
|
||||||
System.out.println(rel + ": Length mismatch");
|
len1 = inputStream1.read(buf1);
|
||||||
countErr.incrementAndGet();
|
if (len0 != len1) {
|
||||||
return;
|
System.out.println(rel + ": Length mismatch");
|
||||||
}
|
countErr.incrementAndGet();
|
||||||
if (len0 == -1) {
|
break;
|
||||||
return;
|
}
|
||||||
}
|
if (len0 == -1) {
|
||||||
if (!Arrays.equals(buf0, 0, len0, buf1, 0, len1)) {
|
break;
|
||||||
System.out.println(rel + ": Data mismatch");
|
}
|
||||||
countErr.incrementAndGet();
|
if (!Arrays.equals(buf0, 0, len0, buf1, 0, len1)) {
|
||||||
return;
|
System.out.println(rel + ": Data mismatch");
|
||||||
|
countErr.incrementAndGet();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
while (len0 > -1);
|
||||||
}
|
}
|
||||||
catch (NoSuchFileException nsfExc) {
|
catch (NoSuchFileException nsfExc) {
|
||||||
// System.out.println(rel + ": NoSuchFileException");
|
// System.out.println(rel + ": NoSuchFileException");
|
||||||
|
|||||||
Reference in New Issue
Block a user