Search in sources :

Example 26 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV3_0 method readLabelTokenRecord.

private LabelTokenRecord readLabelTokenRecord(int id, ReadableChannel channel) throws IOException {
    // in_use(byte)+type_blockId(int)+nr_type_records(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);
    }
    LabelTokenRecord record = new LabelTokenRecord(id);
    record.setInUse(inUse);
    record.setNameId(channel.getInt());
    int nrTypeRecords = channel.getInt();
    for (int i = 0; i < nrTypeRecords; i++) {
        DynamicRecord dr = readDynamicRecord(channel);
        if (dr == null) {
            return null;
        }
        record.addNameRecord(dr);
    }
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 27 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV3_0 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    int id = channel.getInt();
    LabelTokenRecord before = readLabelTokenRecord(id, channel);
    if (before == null) {
        return null;
    }
    LabelTokenRecord after = readLabelTokenRecord(id, channel);
    if (after == null) {
        return null;
    }
    return new Command.LabelTokenCommand(before, after);
}
Also used : LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 28 with LabelTokenRecord

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

the class BatchInserterImpl method createNewLabelId.

private int createNewLabelId(String stringKey) {
    int keyId = (int) labelTokenStore.nextId();
    LabelTokenRecord record = new LabelTokenRecord(keyId);
    record.setInUse(true);
    record.setCreated();
    Collection<DynamicRecord> keyRecords = labelTokenStore.allocateNameRecords(encodeString(stringKey));
    record.setNameId((int) Iterables.first(keyRecords).getId());
    record.addNameRecords(keyRecords);
    labelTokenStore.updateRecord(record);
    labelTokens.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) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 29 with LabelTokenRecord

use of org.neo4j.kernel.impl.store.record.LabelTokenRecord 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)

Example 30 with LabelTokenRecord

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

the class TransactionWriter method create.

public void create(LabelTokenRecord labelToken) {
    labelToken.setCreated();
    update(new LabelTokenRecord(labelToken.getIntId()), labelToken);
}
Also used : LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Aggregations

LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)43 Test (org.junit.Test)26 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)23 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)20 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)14 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)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 IOException (java.io.IOException)7 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)7 SchemaRuleUtil.uniquenessConstraintRule (org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule)5 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)5 InlineNodeLabels (org.neo4j.kernel.impl.store.InlineNodeLabels)4 StorageCommand (org.neo4j.storageengine.api.StorageCommand)4 NodeStore (org.neo4j.kernel.impl.store.NodeStore)3 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)3 Command (org.neo4j.kernel.impl.transaction.command.Command)3 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)3 Collection (java.util.Collection)2