use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenStore method readAllTokens.
private List<NamedToken> readAllTokens(boolean ignoreInconsistentTokens, CursorContext cursorContext) {
long highId = getHighId();
ArrayList<NamedToken> records = new ArrayList<>();
records.ensureCapacity(Math.toIntExact(highId));
RECORD record = newRecord();
for (int i = 0; i < highId; i++) {
if (!getRecord(i, record, RecordLoad.LENIENT_CHECK, cursorContext).inUse()) {
continue;
}
if (record.getNameId() != Record.RESERVED.intValue()) {
try {
String name = getStringFor(record, cursorContext);
records.add(new NamedToken(name, i, record.isInternal()));
} catch (Exception e) {
if (!ignoreInconsistentTokens) {
throw e;
}
}
}
}
return records;
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class CacheInvalidationTransactionApplier method visitRelationshipTypeTokenCommand.
@Override
public boolean visitRelationshipTypeTokenCommand(RelationshipTypeTokenCommand command) {
NamedToken type = relationshipTypeTokenStore.getToken(command.tokenId(), cursorContext);
cacheAccess.addRelationshipTypeToken(type);
return false;
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class CacheInvalidationTransactionApplier method visitPropertyKeyTokenCommand.
@Override
public boolean visitPropertyKeyTokenCommand(PropertyKeyTokenCommand command) {
NamedToken index = propertyKeyTokenStore.getToken(command.tokenId(), cursorContext);
cacheAccess.addPropertyKeyToken(index);
return false;
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class LabelIT method shouldListAllLabels.
@Test
void shouldListAllLabels() throws Exception {
// given
KernelTransaction transaction = newTransaction(AnonymousContext.writeToken());
int label1Id = transaction.tokenWrite().labelGetOrCreateForName("label1");
int label2Id = transaction.tokenWrite().labelGetOrCreateForName("label2");
// when
Iterator<NamedToken> labelIdsBeforeCommit = transaction.tokenRead().labelsGetAllTokens();
// then
assertThat(asCollection(labelIdsBeforeCommit)).contains(new NamedToken("label1", label1Id), new NamedToken("label2", label2Id));
// when
commit();
transaction = newTransaction();
Iterator<NamedToken> labelIdsAfterCommit = transaction.tokenRead().labelsGetAllTokens();
// then
assertThat(asCollection(labelIdsAfterCommit)).contains(new NamedToken("label1", label1Id), new NamedToken("label2", label2Id));
commit();
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class PropertyIT method shouldListAllPropertyKeys.
@Test
void shouldListAllPropertyKeys() throws Exception {
// given
dbWithNoCache();
KernelTransaction transaction = newTransaction(AnonymousContext.writeToken());
int prop1 = transaction.tokenWrite().propertyKeyGetOrCreateForName("prop1");
int prop2 = transaction.tokenWrite().propertyKeyGetOrCreateForName("prop2");
// when
Iterator<NamedToken> propIdsBeforeCommit = transaction.tokenRead().propertyKeyGetAllTokens();
// then
assertThat(asCollection(propIdsBeforeCommit)).contains(new NamedToken("prop1", prop1), new NamedToken("prop2", prop2));
// when
commit();
transaction = newTransaction();
Iterator<NamedToken> propIdsAfterCommit = transaction.tokenRead().propertyKeyGetAllTokens();
// then
assertThat(asCollection(propIdsAfterCommit)).contains(new NamedToken("prop1", prop1), new NamedToken("prop2", prop2));
commit();
}
Aggregations