Search in sources :

Example 21 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method shouldReadPropertyKeyCommand.

@Test
void shouldReadPropertyKeyCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
    PropertyKeyTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    new Command.PropertyKeyTokenCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyKeyTokenCommand);
    Command.PropertyKeyTokenCommand propertyKeyTokenCommand = (Command.PropertyKeyTokenCommand) command;
    // Then
    assertBeforeAndAfterEquals(propertyKeyTokenCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 22 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class LogCommandSerializationV4_0Test method shouldReadInternalPropertyKeyCommand.

@Test
void shouldReadInternalPropertyKeyCommand() throws Exception {
    // Given
    InMemoryClosableChannel channel = new InMemoryClosableChannel();
    PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
    PropertyKeyTokenRecord after = before.copy();
    after.initialize(true, 13);
    after.setCreated();
    after.setInternal(true);
    new Command.PropertyKeyTokenCommand(writer(), before, after).serialize(channel);
    // When
    CommandReader reader = createReader();
    StorageCommand command = reader.read(channel);
    assertTrue(command instanceof Command.PropertyKeyTokenCommand);
    Command.PropertyKeyTokenCommand propertyKeyTokenCommand = (Command.PropertyKeyTokenCommand) command;
    // Then
    assertBeforeAndAfterEquals(propertyKeyTokenCommand, before, after);
}
Also used : CommandReader(org.neo4j.storageengine.api.CommandReader) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) StorageCommand(org.neo4j.storageengine.api.StorageCommand) StorageCommand(org.neo4j.storageengine.api.StorageCommand) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 23 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class LogTruncationTest method createPropertyKeyTokenRecord.

private static PropertyKeyTokenRecord createPropertyKeyTokenRecord(int id) {
    PropertyKeyTokenRecord propertyKeyTokenRecord = new PropertyKeyTokenRecord(id);
    propertyKeyTokenRecord.setInUse(true);
    propertyKeyTokenRecord.setNameId(333);
    propertyKeyTokenRecord.addNameRecord(new DynamicRecord(43));
    return propertyKeyTokenRecord;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 24 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class AbstractRecordCloningTest method preparedPropertyKeyTokenClone.

@RepeatedTest(1000)
void preparedPropertyKeyTokenClone() {
    PropertyKeyTokenRecord propertyKeyTokenRecord = getPropertyKeyTokenRecord();
    propertyKeyTokenFormat.prepare(propertyKeyTokenRecord, propertyKeyTokenRecordSize, idSequence, NULL);
    keys.propertyKeyToken().assertRecordsEquals(propertyKeyTokenRecord, propertyKeyTokenRecord.copy());
}
Also used : PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) RepeatedTest(org.junit.jupiter.api.RepeatedTest)

Example 25 with PropertyKeyTokenRecord

use of org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord in project neo4j by neo4j.

the class ManyPropertyKeysIT method databaseWithManyPropertyKeys.

private GraphDatabaseAPI databaseWithManyPropertyKeys(int propertyKeyCount) throws IOException {
    var cacheTracer = PageCacheTracer.NULL;
    var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer("databaseWithManyPropertyKeys"));
    StoreFactory storeFactory = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName()), pageCache, fileSystem, NullLogProvider.getInstance(), cacheTracer, writable());
    NeoStores neoStores = storeFactory.openAllNeoStores(true);
    PropertyKeyTokenStore store = neoStores.getPropertyKeyTokenStore();
    for (int i = 0; i < propertyKeyCount; i++) {
        PropertyKeyTokenRecord record = new PropertyKeyTokenRecord((int) store.nextId(cursorContext));
        record.setInUse(true);
        Collection<DynamicRecord> nameRecords = store.allocateNameRecords(PropertyStore.encodeString(key(i)), cursorContext, INSTANCE);
        record.addNameRecords(nameRecords);
        record.setNameId((int) Iterables.first(nameRecords).getId());
        store.updateRecord(record, NULL);
    }
    neoStores.flush(cursorContext);
    neoStores.close();
    return database();
}
Also used : PropertyKeyTokenStore(org.neo4j.kernel.impl.store.PropertyKeyTokenStore) DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Aggregations

PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)65 Test (org.junit.Test)31 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)30 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)28 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)16 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)14 IOException (java.io.IOException)10 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)8 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)8 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)8 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)8 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)8 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)6 StorageCommand (org.neo4j.storageengine.api.StorageCommand)6 SchemaRuleUtil.uniquenessConstraintRule (org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule)5 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)5 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)5 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)5 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)4