use of org.neo4j.collection.primitive.PrimitiveLongLongMap in project neo4j by neo4j.
the class CheckTxLogs method validateCheckPoints.
boolean validateCheckPoints(PhysicalLogFiles logFiles, InconsistenciesHandler handler) throws IOException {
final long lowestLogVersion = logFiles.getLowestLogVersion();
final long highestLogVersion = logFiles.getHighestLogVersion();
boolean success = true;
try (PrimitiveLongLongMap logFileSizes = Primitive.offHeapLongLongMap()) {
for (long i = lowestLogVersion; i <= highestLogVersion; i++) {
logFileSizes.put(i, fs.getFileSize(logFiles.getLogFileForVersion(i)));
}
LogEntryCursor logEntryCursor = LogTestUtils.openLogs(fs, logFiles);
while (logEntryCursor.next()) {
LogEntry logEntry = logEntryCursor.get();
if (logEntry instanceof CheckPoint) {
LogPosition logPosition = logEntry.<CheckPoint>as().getLogPosition();
// if the file has been pruned we cannot validate the check point
if (logPosition.getLogVersion() >= lowestLogVersion) {
long size = logFileSizes.get(logPosition.getLogVersion());
if (logPosition.getByteOffset() < 0 || size < 0 || logPosition.getByteOffset() > size) {
long currentLogVersion = logEntryCursor.getCurrentLogVersion();
handler.reportInconsistentCheckPoint(currentLogVersion, logPosition, size);
success = false;
}
}
}
}
}
return success;
}
use of org.neo4j.collection.primitive.PrimitiveLongLongMap in project neo4j by neo4j.
the class PrimitiveLongMapTest method longLongEntryVisitorShouldSeeAllEntriesIfItDoesNotBreakOut.
@SuppressWarnings("unchecked")
@Test
public void longLongEntryVisitorShouldSeeAllEntriesIfItDoesNotBreakOut() {
// GIVEN
PrimitiveLongLongVisitor<RuntimeException> visitor;
try (PrimitiveLongLongMap map = Primitive.offHeapLongLongMap()) {
map.put(1, 100);
map.put(2, 200);
map.put(3, 300);
visitor = mock(PrimitiveLongLongVisitor.class);
// WHEN
map.visitEntries(visitor);
}
// THEN
verify(visitor).visited(1, 100);
verify(visitor).visited(2, 200);
verify(visitor).visited(3, 300);
verifyNoMoreInteractions(visitor);
}
use of org.neo4j.collection.primitive.PrimitiveLongLongMap in project neo4j by neo4j.
the class PrimitiveLongMapTest method longLongKeyVisitorShouldNotSeeEntriesAfterRequestingBreakOut.
@Test
public void longLongKeyVisitorShouldNotSeeEntriesAfterRequestingBreakOut() {
// GIVEN
AtomicInteger counter = new AtomicInteger();
try (PrimitiveLongLongMap map = Primitive.offHeapLongLongMap()) {
map.put(1, 100);
map.put(2, 200);
map.put(3, 300);
map.put(4, 400);
// WHEN
map.visitKeys(value -> counter.incrementAndGet() > 2);
}
// THEN
assertThat(counter.get(), is(3));
}
use of org.neo4j.collection.primitive.PrimitiveLongLongMap in project neo4j by neo4j.
the class PrimitiveLongMapTest method longLongKeyVisitorShouldSeeAllEntriesIfItDoesNotBreakOut.
@SuppressWarnings("unchecked")
@Test
public void longLongKeyVisitorShouldSeeAllEntriesIfItDoesNotBreakOut() {
// GIVEN
PrimitiveLongVisitor<RuntimeException> visitor = mock(PrimitiveLongVisitor.class);
try (PrimitiveLongLongMap map = Primitive.offHeapLongLongMap()) {
map.put(1, 100);
map.put(2, 200);
map.put(3, 300);
// WHEN
map.visitKeys(visitor);
}
// THEN
verify(visitor).visited(1);
verify(visitor).visited(2);
verify(visitor).visited(3);
verifyNoMoreInteractions(visitor);
}
use of org.neo4j.collection.primitive.PrimitiveLongLongMap in project neo4j by neo4j.
the class PrimitiveLongMapTest method longLongEntryVisitorShouldNotSeeEntriesAfterRequestingBreakOut.
@Test
public void longLongEntryVisitorShouldNotSeeEntriesAfterRequestingBreakOut() {
// GIVEN
AtomicInteger counter = new AtomicInteger();
try (PrimitiveLongLongMap map = Primitive.offHeapLongLongMap()) {
map.put(1, 100);
map.put(2, 200);
map.put(3, 300);
map.put(4, 400);
// WHEN
map.visitEntries((key, value) -> counter.incrementAndGet() > 2);
}
// THEN
assertThat(counter.get(), is(3));
}
Aggregations