use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method mustReportMissingLabel.
@Test
void mustReportMissingLabel() throws Exception {
// given
List<Pair<Long, Label[]>> nodesInStore = someData();
Path labelIndexFileCopy = copyLabelIndexFile();
// when
try (Transaction tx = db.beginTx()) {
addLabelToExistingNode(tx, nodesInStore);
tx.commit();
}
// and
replaceLabelIndexWithCopy(labelIndexFileCopy);
// then
ConsistencyCheckService.Result result = fullConsistencyCheck();
assertFalse(result.isSuccessful(), "Expected consistency check to fail");
}
use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method mustReportExtraNode.
@Test
void mustReportExtraNode() throws Exception {
// given
List<Pair<Long, Label[]>> nodesInStore = someData();
Path labelIndexFileCopy = copyLabelIndexFile();
// when
try (Transaction tx = db.beginTx()) {
removeExistingNode(tx, nodesInStore);
tx.commit();
}
// and
replaceLabelIndexWithCopy(labelIndexFileCopy);
// then
ConsistencyCheckService.Result result = fullConsistencyCheck();
assertFalse(result.isSuccessful(), "Expected consistency check to fail");
}
use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class AllNodesInStoreExistInLabelIndexTest method mustReportExtraLabelsOnExistingNode.
@Test
void mustReportExtraLabelsOnExistingNode() throws Exception {
// given
List<Pair<Long, Label[]>> nodesInStore = someData();
Path labelIndexFileCopy = copyLabelIndexFile();
// when
try (Transaction tx = db.beginTx()) {
removeLabelFromExistingNode(tx, nodesInStore);
tx.commit();
}
// and
replaceLabelIndexWithCopy(labelIndexFileCopy);
// then
ConsistencyCheckService.Result result = fullConsistencyCheck();
assertFalse(result.isSuccessful(), "Expected consistency check to fail");
}
use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class IndexConsistencyIT method someData.
void someData(int numberOfModifications) {
List<Pair<Long, Label[]>> existingNodes;
existingNodes = new ArrayList<>();
try (Transaction tx = db.beginTx()) {
randomModifications(tx, existingNodes, numberOfModifications);
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().indexFor(LABEL_ONE).on(PROPERTY_KEY).create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, TimeUnit.MINUTES);
tx.commit();
}
}
use of org.neo4j.internal.helpers.collection.Pair in project neo4j by neo4j.
the class NodeRelationshipCacheTest method shouldCacheMultipleDenseNodeRelationshipHeads.
@Test
public void shouldCacheMultipleDenseNodeRelationshipHeads() {
// GIVEN
cache = new NodeRelationshipCache(NumberArrayFactories.HEAP, 1, INSTANCE);
cache.setNodeCount(10);
long nodeId = 3;
cache.setCount(nodeId, 10, /*these do not matter ==>*/
0, OUTGOING);
// WHEN
Map<Pair<Integer, Direction>, Long> firstRelationshipIds = new HashMap<>();
int typeCount = 3;
for (int typeId = 0, relationshipId = 0; typeId < typeCount; typeId++) {
for (Direction direction : Direction.values()) {
long firstRelationshipId = relationshipId++;
cache.getAndPutRelationship(nodeId, typeId, direction, firstRelationshipId, true);
firstRelationshipIds.put(Pair.of(typeId, direction), firstRelationshipId);
}
}
AtomicInteger visitCount = new AtomicInteger();
NodeRelationshipCache.GroupVisitor visitor = (nodeId1, typeId, out, in, loop) -> {
visitCount.incrementAndGet();
assertEquals(firstRelationshipIds.get(Pair.of(typeId, OUTGOING)).longValue(), out);
assertEquals(firstRelationshipIds.get(Pair.of(typeId, INCOMING)).longValue(), in);
assertEquals(firstRelationshipIds.get(Pair.of(typeId, BOTH)).longValue(), loop);
return 0;
};
cache.getFirstRel(nodeId, visitor);
// THEN
assertEquals(typeCount, visitCount.get());
}
Aggregations