use of org.neo4j.kernel.impl.store.TokenStore in project neo4j by neo4j.
the class RecordLoading method safeLoadTokens.
static <RECORD extends TokenRecord> List<NamedToken> safeLoadTokens(TokenStore<RECORD> tokenStore, CursorContext cursorContext) {
long highId = tokenStore.getHighId();
List<NamedToken> tokens = new ArrayList<>();
DynamicStringStore nameStore = tokenStore.getNameStore();
List<DynamicRecord> nameRecords = new ArrayList<>();
MutableLongSet seenRecordIds = new LongHashSet();
int nameBlockSize = nameStore.getRecordDataSize();
try (RecordReader<RECORD> tokenReader = new RecordReader<>(tokenStore, true, cursorContext);
RecordReader<DynamicRecord> nameReader = new RecordReader<>(nameStore, false, cursorContext)) {
for (long id = 0; id < highId; id++) {
RECORD record = tokenReader.read(id);
nameRecords.clear();
if (record.inUse()) {
String name;
if (!NULL_REFERENCE.is(record.getNameId()) && safeLoadDynamicRecordChain(r -> nameRecords.add(r.copy()), nameReader, seenRecordIds, record.getNameId(), nameBlockSize)) {
record.addNameRecords(nameRecords);
name = tokenStore.getStringFor(record, cursorContext);
} else {
name = format("<name not loaded due to token(%d) referencing unused name record>", id);
}
tokens.add(new NamedToken(name, toIntExact(id), record.isInternal()));
}
}
}
return tokens;
}
Aggregations