use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyPropertyKeyTokenCommandToTheStoreInRecovery.
@Test
public void shouldApplyPropertyKeyTokenCommandToTheStoreInRecovery() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(true);
final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command.PropertyKeyTokenCommand command = new Command.PropertyKeyTokenCommand(before, after);
final Token token = new Token("token", 21);
when(propertyKeyTokenStore.getToken((int) command.getKey())).thenReturn(token);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(propertyKeyTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
verify(propertyKeyTokenStore, times(1)).updateRecord(after);
verify(cacheAccess, times(1)).addPropertyKeyToken(token);
}
use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.
the class NeoStoreTransactionApplierTest method shouldApplyPropertyKeyTokenCommandToTheStore.
// PROPERTY KEY TOKEN COMMAND
@Test
public void shouldApplyPropertyKeyTokenCommandToTheStore() throws Exception {
// given
final BatchTransactionApplier applier = newApplier(false);
final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord(42);
after.setInUse(true);
after.setNameId(323);
final Command command = new PropertyKeyTokenCommand(before, after);
// when
boolean result = apply(applier, command::handle, transactionToApply);
// then
assertFalse(result);
verify(propertyKeyTokenStore, times(1)).updateRecord(after);
}
use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.
the class LogTruncationTest method createPropertyKeyTokenRecord.
private PropertyKeyTokenRecord createPropertyKeyTokenRecord(int id) {
PropertyKeyTokenRecord propertyKeyTokenRecord = new PropertyKeyTokenRecord(id);
propertyKeyTokenRecord.setInUse(true);
propertyKeyTokenRecord.setNameId(333);
propertyKeyTokenRecord.addNameRecord(new DynamicRecord(43));
return propertyKeyTokenRecord;
}
use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord 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);
}
use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.
the class LogCommandSerializationV3_0_10 method readPropertyKeyTokenRecord.
private PropertyKeyTokenRecord readPropertyKeyTokenRecord(int id, ReadableChannel channel) throws IOException {
// in_use(byte)+count(int)+key_blockId(int)
byte inUseFlag = channel.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
PropertyKeyTokenRecord record = new PropertyKeyTokenRecord(id);
record.setInUse(inUse);
record.setPropertyCount(channel.getInt());
record.setNameId(channel.getInt());
if (readDynamicRecords(channel, record, PROPERTY_INDEX_DYNAMIC_RECORD_ADDER) == -1) {
return null;
}
return record;
}
Aggregations