use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenStoreTestTemplate method tokensMustPreserveTheirInternalFlag.
@Test
void tokensMustPreserveTheirInternalFlag() {
R tokenRecord = createInUseRecord(allocateNameRecords("MyInternalToken"));
tokenRecord.setInternal(true);
storeToken(tokenRecord);
R readBack = store.getRecord(tokenRecord.getId(), store.newRecord(), NORMAL, NULL);
store.ensureHeavy(readBack, NULL);
assertThat(readBack).isEqualTo(tokenRecord);
assertThat(tokenRecord.isInternal()).isEqualTo(true);
assertThat(readBack.isInternal()).isEqualTo(true);
NamedToken token = store.getToken(toIntExact(tokenRecord.getId()), NULL);
assertThat(token.name()).isEqualTo("MyInternalToken");
assertThat(token.id()).isIn(toIntExact(tokenRecord.getId()));
assertTrue(token.isInternal());
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class GraphCountsSection method relationshipCounts.
private static List<Map<String, Object>> relationshipCounts(TokenRead tokens, Read read, Anonymizer anonymizer) {
List<Map<String, Object>> relationshipCounts = new ArrayList<>();
Map<String, Object> relationshipCount = new HashMap<>();
relationshipCount.put("count", read.countsForRelationshipWithoutTxState(-1, -1, -1));
relationshipCounts.add(relationshipCount);
List<NamedToken> labels = Iterators.asList(tokens.labelsGetAllTokens());
tokens.relationshipTypesGetAllTokens().forEachRemaining(t -> {
long count = read.countsForRelationshipWithoutTxState(-1, t.id(), -1);
Map<String, Object> relationshipTypeCount = new HashMap<>();
relationshipTypeCount.put("relationshipType", anonymizer.relationshipType(t.name(), t.id()));
relationshipTypeCount.put("count", count);
relationshipCounts.add(relationshipTypeCount);
for (NamedToken label : labels) {
long startCount = read.countsForRelationshipWithoutTxState(label.id(), t.id(), -1);
if (startCount > 0) {
Map<String, Object> x = new HashMap<>();
x.put("relationshipType", anonymizer.relationshipType(t.name(), t.id()));
x.put("startLabel", anonymizer.label(label.name(), label.id()));
x.put("count", startCount);
relationshipCounts.add(x);
}
long endCount = read.countsForRelationshipWithoutTxState(-1, t.id(), label.id());
if (endCount > 0) {
Map<String, Object> x = new HashMap<>();
x.put("relationshipType", anonymizer.relationshipType(t.name(), t.id()));
x.put("endLabel", anonymizer.label(label.name(), label.id()));
x.put("count", endCount);
relationshipCounts.add(x);
}
}
});
return relationshipCounts;
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class CacheInvalidationTransactionApplier method visitLabelTokenCommand.
@Override
public boolean visitLabelTokenCommand(LabelTokenCommand command) {
NamedToken labelId = labelTokenStore.getToken(command.tokenId(), cursorContext);
cacheAccess.addLabelToken(labelId);
return false;
}
Aggregations