Search in sources :

Example 26 with PropertyKeyTokenRecord

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

the class RecordLoadingTest method shouldReturnsFalseOnMissingToken.

@Test
void shouldReturnsFalseOnMissingToken() {
    // given
    NodeRecord entity = new NodeRecord(0);
    TokenHolder tokenHolder = new DelegatingTokenHolder(new ReadOnlyTokenCreator(), "Test");
    TokenStore<PropertyKeyTokenRecord> store = mock(TokenStore.class);
    BiConsumer noopReporter = mock(BiConsumer.class);
    // when
    boolean valid = RecordLoading.checkValidToken(entity, 0, tokenHolder, store, noopReporter, noopReporter, CursorContext.NULL);
    // then
    assertFalse(valid);
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) TokenHolder(org.neo4j.token.api.TokenHolder) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) BiConsumer(java.util.function.BiConsumer) Test(org.junit.jupiter.api.Test)

Example 27 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV2_0 method visitPropertyKeyTokenCommand.

private Command visitPropertyKeyTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+count(int)+key_blockId(int)
    int id = channel.getInt();
    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());
    int recordNr = readDynamicRecords(channel, record, PROPERTY_INDEX_DYNAMIC_RECORD_ADDER);
    if (recordNr == -1) {
        return null;
    }
    return new Command.PropertyKeyTokenCommand(null, record);
}
Also used : IOException(java.io.IOException) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 28 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV2_1 method visitPropertyKeyTokenCommand.

private Command visitPropertyKeyTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+count(int)+key_blockId(int)
    int id = channel.getInt();
    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 new Command.PropertyKeyTokenCommand(null, record);
}
Also used : IOException(java.io.IOException) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 29 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV2_2_4 method visitPropertyKeyTokenCommand.

private Command visitPropertyKeyTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+count(int)+key_blockId(int)
    int id = channel.getInt();
    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 new Command.PropertyKeyTokenCommand(null, record);
}
Also used : IOException(java.io.IOException) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 30 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV3_0_2 method visitPropertyKeyTokenCommand.

private Command visitPropertyKeyTokenCommand(ReadableChannel channel) throws IOException {
    int id = channel.getInt();
    PropertyKeyTokenRecord before = readPropertyKeyTokenRecord(id, channel);
    if (before == null) {
        return null;
    }
    PropertyKeyTokenRecord after = readPropertyKeyTokenRecord(id, channel);
    if (after == null) {
        return null;
    }
    return new Command.PropertyKeyTokenCommand(before, after);
}
Also used : 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