Search in sources :

Example 21 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV2_1 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(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);
    }
    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 new Command.LabelTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 22 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV2_0 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(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);
    }
    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 new Command.LabelTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 23 with LabelTokenRecord

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

the class WriteTransactionCommandOrderingTest method injectAllPossibleCommands.

private TransactionRecordState injectAllPossibleCommands() {
    RecordChangeSet recordChangeSet = mock(RecordChangeSet.class);
    RecordChanges<Integer, LabelTokenRecord, Void> labelTokenChanges = mock(RecordChanges.class);
    RecordChanges<Integer, RelationshipTypeTokenRecord, Void> relationshipTypeTokenChanges = mock(RecordChanges.class);
    RecordChanges<Integer, PropertyKeyTokenRecord, Void> propertyKeyTokenChanges = mock(RecordChanges.class);
    RecordChanges<Long, NodeRecord, Void> nodeRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, RelationshipRecord, Void> relationshipRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, PropertyRecord, PrimitiveRecord> propertyRecordChanges = mock(RecordChanges.class);
    RecordChanges<Long, RelationshipGroupRecord, Integer> relationshipGroupChanges = mock(RecordChanges.class);
    RecordChanges<Long, SchemaRecord, SchemaRule> schemaRuleChanges = mock(RecordChanges.class);
    when(recordChangeSet.getLabelTokenChanges()).thenReturn(labelTokenChanges);
    when(recordChangeSet.getRelationshipTypeTokenChanges()).thenReturn(relationshipTypeTokenChanges);
    when(recordChangeSet.getPropertyKeyTokenChanges()).thenReturn(propertyKeyTokenChanges);
    when(recordChangeSet.getNodeRecords()).thenReturn(nodeRecordChanges);
    when(recordChangeSet.getRelRecords()).thenReturn(relationshipRecordChanges);
    when(recordChangeSet.getPropertyRecords()).thenReturn(propertyRecordChanges);
    when(recordChangeSet.getRelGroupRecords()).thenReturn(relationshipGroupChanges);
    when(recordChangeSet.getSchemaRuleChanges()).thenReturn(schemaRuleChanges);
    List<RecordProxy<Long, NodeRecord, Void>> nodeChanges = new LinkedList<>();
    RecordChange<Long, NodeRecord, Void> deletedNode = mock(RecordChange.class);
    when(deletedNode.getBefore()).thenReturn(inUseNode());
    when(deletedNode.forReadingLinkage()).thenReturn(missingNode());
    nodeChanges.add(deletedNode);
    RecordChange<Long, NodeRecord, Void> createdNode = mock(RecordChange.class);
    when(createdNode.getBefore()).thenReturn(missingNode());
    when(createdNode.forReadingLinkage()).thenReturn(createdNode());
    nodeChanges.add(createdNode);
    RecordChange<Long, NodeRecord, Void> updatedNode = mock(RecordChange.class);
    when(updatedNode.getBefore()).thenReturn(inUseNode());
    when(updatedNode.forReadingLinkage()).thenReturn(inUseNode());
    nodeChanges.add(updatedNode);
    when(nodeRecordChanges.changes()).thenReturn(nodeChanges);
    when(nodeRecordChanges.changeSize()).thenReturn(3);
    when(recordChangeSet.changeSize()).thenReturn(3);
    when(labelTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, LabelTokenRecord, Void>>emptyList());
    when(relationshipTypeTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, RelationshipTypeTokenRecord, Void>>emptyList());
    when(propertyKeyTokenChanges.changes()).thenReturn(Collections.<RecordProxy<Integer, PropertyKeyTokenRecord, Void>>emptyList());
    when(relationshipRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipRecord, Void>>emptyList());
    when(propertyRecordChanges.changes()).thenReturn(Collections.<RecordProxy<Long, PropertyRecord, PrimitiveRecord>>emptyList());
    when(relationshipGroupChanges.changes()).thenReturn(Collections.<RecordProxy<Long, RelationshipGroupRecord, Integer>>emptyList());
    when(schemaRuleChanges.changes()).thenReturn(Collections.<RecordProxy<Long, SchemaRecord, SchemaRule>>emptyList());
    NeoStores neoStores = mock(NeoStores.class);
    when(neoStores.getNodeStore()).thenReturn(mock(NodeStore.class));
    when(neoStores.getRelationshipGroupStore()).thenReturn(mock(RelationshipGroupStore.class));
    when(neoStores.getRelationshipStore()).thenReturn(mock(RelationshipStore.class));
    return new TransactionRecordState(neoStores, mock(IntegrityValidator.class), recordChangeSet, 0, null, null, null, null, null);
}
Also used : RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) NodeStore(org.neo4j.kernel.impl.store.NodeStore) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PrimitiveRecord(org.neo4j.kernel.impl.store.record.PrimitiveRecord) RecordProxy(org.neo4j.kernel.impl.transaction.state.RecordAccess.RecordProxy) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipGroupStore(org.neo4j.kernel.impl.store.RelationshipGroupStore) LinkedList(java.util.LinkedList) NeoStores(org.neo4j.kernel.impl.store.NeoStores) RelationshipStore(org.neo4j.kernel.impl.store.RelationshipStore)

Example 24 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV3_0_2 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 25 with LabelTokenRecord

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

the class PhysicalLogCommandReaderV2_2 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(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);
    }
    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 new Command.LabelTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) 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