Search in sources :

Example 6 with MalformedSchemaRuleException

use of org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException in project neo4j by neo4j.

the class SchemaRuleSerialization method readIndexRule.

// PRIVATE
// READ INDEX
private static IndexRule readIndexRule(long id, ByteBuffer source) throws MalformedSchemaRuleException {
    SchemaIndexProvider.Descriptor indexProvider = readIndexProviderDescriptor(source);
    LabelSchemaDescriptor schema;
    byte indexRuleType = source.get();
    String name;
    switch(indexRuleType) {
        case GENERAL_INDEX:
            schema = readLabelSchema(source);
            name = readRuleName(id, IndexRule.class, source);
            return IndexRule.indexRule(id, NewIndexDescriptorFactory.forSchema(schema), indexProvider, name);
        case UNIQUE_INDEX:
            long owningConstraint = source.getLong();
            schema = readLabelSchema(source);
            NewIndexDescriptor descriptor = NewIndexDescriptorFactory.uniqueForSchema(schema);
            name = readRuleName(id, IndexRule.class, source);
            return IndexRule.constraintIndexRule(id, descriptor, indexProvider, owningConstraint == NO_OWNING_CONSTRAINT_YET ? null : owningConstraint, name);
        default:
            throw new MalformedSchemaRuleException(format("Got unknown index rule type '%d'.", indexRuleType));
    }
}
Also used : SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) LabelSchemaDescriptor(org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)

Example 7 with MalformedSchemaRuleException

use of org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2_10 method readSchemaRule.

private SchemaRule readSchemaRule(Collection<DynamicRecord> recordsBefore) {
    // TODO: Why was this assertion here?
    //            assert first(recordsBefore).inUse() : "Asked to deserialize schema records that were not in
    // use.";
    SchemaRule rule;
    ByteBuffer deserialized = AbstractDynamicStore.concatData(recordsBefore, new byte[100]);
    try {
        rule = SchemaRuleSerialization.deserialize(Iterables.first(recordsBefore).getId(), deserialized);
    } catch (MalformedSchemaRuleException e) {
        return null;
    }
    return rule;
}
Also used : MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) ByteBuffer(java.nio.ByteBuffer)

Example 8 with MalformedSchemaRuleException

use of org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2_4 method readSchemaRule.

private SchemaRule readSchemaRule(Collection<DynamicRecord> recordsBefore) {
    // TODO: Why was this assertion here?
    //            assert first(recordsBefore).inUse() : "Asked to deserialize schema records that were not in
    // use.";
    SchemaRule rule;
    ByteBuffer deserialized = AbstractDynamicStore.concatData(recordsBefore, new byte[100]);
    try {
        rule = SchemaRuleSerialization.deserialize(Iterables.first(recordsBefore).getId(), deserialized);
    } catch (MalformedSchemaRuleException e) {
        return null;
    }
    return rule;
}
Also used : MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) ByteBuffer(java.nio.ByteBuffer)

Example 9 with MalformedSchemaRuleException

use of org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0_2 method readSchemaRule.

private SchemaRule readSchemaRule(Collection<DynamicRecord> recordsBefore) {
    // TODO: Why was this assertion here?
    //            assert first(recordsBefore).inUse() : "Asked to deserialize schema records that were not in
    // use.";
    SchemaRule rule;
    ByteBuffer deserialized = AbstractDynamicStore.concatData(recordsBefore, new byte[100]);
    try {
        rule = SchemaRuleSerialization.deserialize(Iterables.first(recordsBefore).getId(), deserialized);
    } catch (MalformedSchemaRuleException e) {
        return null;
    }
    return rule;
}
Also used : MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) ByteBuffer(java.nio.ByteBuffer)

Example 10 with MalformedSchemaRuleException

use of org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0 method readSchemaRule.

private SchemaRule readSchemaRule(Collection<DynamicRecord> recordsBefore) {
    // TODO: Why was this assertion here?
    //            assert first(recordsBefore).inUse() : "Asked to deserialize schema records that were not in
    // use.";
    SchemaRule rule;
    ByteBuffer deserialized = AbstractDynamicStore.concatData(recordsBefore, new byte[100]);
    try {
        rule = SchemaRuleSerialization.deserialize(Iterables.first(recordsBefore).getId(), deserialized);
    } catch (MalformedSchemaRuleException e) {
        return null;
    }
    return rule;
}
Also used : MalformedSchemaRuleException(org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule) ByteBuffer(java.nio.ByteBuffer)

Aggregations

MalformedSchemaRuleException (org.neo4j.kernel.api.exceptions.schema.MalformedSchemaRuleException)11 SchemaRule (org.neo4j.storageengine.api.schema.SchemaRule)8 ByteBuffer (java.nio.ByteBuffer)7 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)2 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)2 Test (org.junit.Test)1 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)1 PrefetchingIterator (org.neo4j.helpers.collection.PrefetchingIterator)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1 RelationTypeSchemaDescriptor (org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor)1 SchemaDescriptor (org.neo4j.kernel.api.schema_new.SchemaDescriptor)1 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)1 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)1