Search in sources :

Example 31 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV3_0 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;
}
Also used : IOException(java.io.IOException) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 32 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV3_0 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)

Example 33 with PropertyKeyTokenRecord

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

the class PhysicalLogCommandReaderV2_2_10 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 34 with PropertyKeyTokenRecord

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

the class BatchInserterImpl method createNewPropertyKeyId.

private int createNewPropertyKeyId(String stringKey) {
    int keyId = (int) propertyKeyTokenStore.nextId();
    PropertyKeyTokenRecord record = new PropertyKeyTokenRecord(keyId);
    record.setInUse(true);
    record.setCreated();
    Collection<DynamicRecord> keyRecords = propertyKeyTokenStore.allocateNameRecords(encodeString(stringKey));
    record.setNameId((int) Iterables.first(keyRecords).getId());
    record.addNameRecords(keyRecords);
    propertyKeyTokenStore.updateRecord(record);
    propertyKeyTokens.addToken(new Token(stringKey, keyId));
    return keyId;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) UniquenessConstraint(org.neo4j.kernel.api.constraints.UniquenessConstraint) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)

Example 35 with PropertyKeyTokenRecord

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

the class SchemaRecordCheckTest method shouldReportInvalidPropertyReferenceFromIndexRule.

@Test
public void shouldReportInvalidPropertyReferenceFromIndexRule() throws Exception {
    // given
    int schemaRuleId = 0;
    DynamicRecord record = inUse(dynamicRecord(schemaRuleId));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule = indexRule(schemaRuleId, labelId, propertyKeyId, providerDescriptor);
    when(checker().ruleAccess.loadSingleSchemaRule(schemaRuleId)).thenReturn(rule);
    add(inUse(new LabelTokenRecord(labelId)));
    PropertyKeyTokenRecord propertyKeyToken = add(notInUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    ConsistencyReport.SchemaConsistencyReport report = check(record);
    // then
    verify(report).propertyKeyNotInUse(propertyKeyToken);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

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