use of org.neo4j.storageengine.migration.SchemaRuleMigrationAccess in project neo4j by neo4j.
the class SchemaRuleMigrationTest method setUp.
@BeforeEach
void setUp() {
srcTokenHolders = new TokenHolders(StoreTokens.createReadOnlyTokenHolder(TokenHolder.TYPE_PROPERTY_KEY), StoreTokens.createReadOnlyTokenHolder(TokenHolder.TYPE_LABEL), StoreTokens.createReadOnlyTokenHolder(TokenHolder.TYPE_RELATIONSHIP_TYPE));
src = mock(SchemaStorage35.class);
writtenRules = new ArrayList<>();
dst = new SchemaRuleMigrationAccess() {
@Override
public void writeSchemaRule(SchemaRule rule) {
writtenRules.add(rule);
}
@Override
public Iterable<SchemaRule> getAll() {
return List.of();
}
@Override
public void close() {
}
};
}
use of org.neo4j.storageengine.migration.SchemaRuleMigrationAccess in project neo4j by neo4j.
the class RecordStorageEngineFactory method createMigrationTargetSchemaRuleAccess.
public static SchemaRuleMigrationAccess createMigrationTargetSchemaRuleAccess(NeoStores stores, CursorContext cursorContext, MemoryTracker memoryTracker) {
SchemaStore dstSchema = stores.getSchemaStore();
TokenCreator propertyKeyTokenCreator = (name, internal) -> {
PropertyKeyTokenStore keyTokenStore = stores.getPropertyKeyTokenStore();
DynamicStringStore nameStore = keyTokenStore.getNameStore();
byte[] bytes = PropertyStore.encodeString(name);
List<DynamicRecord> nameRecords = new ArrayList<>();
AbstractDynamicStore.allocateRecordsFromBytes(nameRecords, bytes, nameStore, cursorContext, memoryTracker);
nameRecords.forEach(record -> nameStore.prepareForCommit(record, cursorContext));
nameRecords.forEach(record -> nameStore.updateRecord(record, cursorContext));
nameRecords.forEach(record -> nameStore.setHighestPossibleIdInUse(record.getId()));
int nameId = Iterables.first(nameRecords).getIntId();
PropertyKeyTokenRecord keyTokenRecord = keyTokenStore.newRecord();
long tokenId = keyTokenStore.nextId(cursorContext);
keyTokenRecord.setId(tokenId);
keyTokenRecord.initialize(true, nameId);
keyTokenRecord.setInternal(internal);
keyTokenRecord.setCreated();
keyTokenStore.prepareForCommit(keyTokenRecord, cursorContext);
keyTokenStore.updateRecord(keyTokenRecord, cursorContext);
keyTokenStore.setHighestPossibleIdInUse(keyTokenRecord.getId());
return Math.toIntExact(tokenId);
};
TokenHolders dstTokenHolders = tokenHoldersForSchemaStore(stores, propertyKeyTokenCreator, cursorContext);
return new SchemaRuleMigrationAccessImpl(stores, new SchemaStorage(dstSchema, dstTokenHolders, () -> KernelVersion.LATEST), cursorContext, memoryTracker);
}
Aggregations