private static StoreIndexDescriptor readIndexRule( long id, ByteBuffer source ) throws MalformedSchemaRuleException { IndexProviderDescriptor indexProvider = readIndexProviderDescriptor( source ); byte indexRuleType = source.get(); Optional<String> name; switch ( indexRuleType ) { case GENERAL_INDEX: { SchemaDescriptor schema = readSchema( source ); name = readRuleName( source ); return IndexDescriptorFactory.forSchema( schema, name, indexProvider ).withId( id ); } case UNIQUE_INDEX: { long owningConstraint = source.getLong(); SchemaDescriptor schema = readSchema( source ); name = readRuleName( source ); IndexDescriptor descriptor = IndexDescriptorFactory.uniqueForSchema( schema, name, indexProvider ); return owningConstraint == NO_OWNING_CONSTRAINT_YET ? descriptor.withId( id ) : descriptor.withIds( id, owningConstraint ); } default: throw new MalformedSchemaRuleException( format( "Got unknown index rule type '%d'.", indexRuleType ) ); } }
private static StoreIndexDescriptor readIndexRule( long id, ByteBuffer source ) throws MalformedSchemaRuleException { IndexProviderDescriptor indexProvider = readIndexProviderDescriptor( source ); byte indexRuleType = source.get(); Optional<String> name; switch ( indexRuleType ) { case GENERAL_INDEX: { SchemaDescriptor schema = readSchema( source ); name = readRuleName( source ); return IndexDescriptorFactory.forSchema( schema, name, indexProvider ).withId( id ); } case UNIQUE_INDEX: { long owningConstraint = source.getLong(); SchemaDescriptor schema = readSchema( source ); name = readRuleName( source ); IndexDescriptor descriptor = IndexDescriptorFactory.uniqueForSchema( schema, name, indexProvider ); return owningConstraint == NO_OWNING_CONSTRAINT_YET ? descriptor.withId( id ) : descriptor.withIds( id, owningConstraint ); } default: throw new MalformedSchemaRuleException( format( "Got unknown index rule type '%d'.", indexRuleType ) ); } }