Search in sources :

Example 6 with SchemaRecord

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

the class SchemaRuleCommandTest method shouldWriteCreatedSchemaRuleToStore.

@Test
public void shouldWriteCreatedSchemaRuleToStore() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(storeApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(schemaStore).updateRecord(Iterables.first(afterRecords));
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Example 7 with SchemaRecord

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

the class SchemaRuleCommandTest method shouldCreateIndexForCreatedSchemaRule.

@Test
public void shouldCreateIndexForCreatedSchemaRule() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    visitSchemaRuleCommand(indexApplier, new SchemaRuleCommand(beforeRecords, afterRecords, rule));
    // THEN
    verify(indexes).createIndexes(rule);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) Test(org.junit.Test)

Example 8 with SchemaRecord

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

the class TransactionRecordState method dropSchemaRule.

public void dropSchemaRule(SchemaRule rule) {
    RecordProxy<Long, SchemaRecord, SchemaRule> change = recordChangeSet.getSchemaRuleChanges().getOrLoad(rule.getId(), rule);
    SchemaRecord records = change.forChangingData();
    for (DynamicRecord record : records) {
        record.setInUse(false);
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule)

Example 9 with SchemaRecord

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

the class SchemaRuleCommandTest method serialize.

private SchemaRecord serialize(SchemaRule rule, long id, boolean inUse, boolean created) {
    DynamicRecord record = new DynamicRecord(id);
    record.setData(rule.serialize());
    if (created) {
        record.setCreated();
    }
    if (inUse) {
        record.setInUse(true);
    }
    return new SchemaRecord(singletonList(record));
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord)

Example 10 with SchemaRecord

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

the class SchemaRuleCommandTest method shouldWriteSchemaRuleToLog.

@Test
public void shouldWriteSchemaRuleToLog() throws Exception {
    // GIVEN
    SchemaRecord beforeRecords = serialize(rule, id, false, false);
    SchemaRecord afterRecords = serialize(rule, id, true, true);
    SchemaRuleCommand command = new SchemaRuleCommand(beforeRecords, afterRecords, rule);
    InMemoryClosableChannel buffer = new InMemoryClosableChannel();
    when(neoStores.getSchemaStore()).thenReturn(schemaStore);
    // WHEN
    command.serialize(buffer);
    Command readCommand = reader.read(buffer);
    // THEN
    assertThat(readCommand, instanceOf(SchemaRuleCommand.class));
    assertSchemaRule((SchemaRuleCommand) readCommand);
}
Also used : SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) SchemaRecord(org.neo4j.kernel.impl.store.record.SchemaRecord) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) Command(org.neo4j.kernel.impl.transaction.command.Command) SchemaRuleCommand(org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand) Test(org.junit.Test)

Aggregations

SchemaRecord (org.neo4j.kernel.impl.store.record.SchemaRecord)12 Test (org.junit.Test)7 SchemaRuleCommand (org.neo4j.kernel.impl.transaction.command.Command.SchemaRuleCommand)7 SchemaRule (org.neo4j.storageengine.api.schema.SchemaRule)4 Command (org.neo4j.kernel.impl.transaction.command.Command)3 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)2 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)2 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)2 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)2 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)2 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)2 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)2 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 LinkedList (java.util.LinkedList)1 NeoStores (org.neo4j.kernel.impl.store.NeoStores)1 NodeStore (org.neo4j.kernel.impl.store.NodeStore)1 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)1 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)1