@Override public void visitAddedIndex( IndexDescriptor index ) { StoreIndexDescriptor rule = index.withId( schemaStorage.newRuleId() ); recordState.createSchemaRule( rule ); }
private static StoreIndexDescriptor readIndexRule( long id, boolean constraintIndex, int label, ByteBuffer serialized ) { IndexProviderDescriptor providerDescriptor = readIndexProviderDescriptor( serialized ); int[] propertyKeyIds = readIndexPropertyKeys( serialized ); LabelSchemaDescriptor schema = SchemaDescriptorFactory.forLabel( label, propertyKeyIds ); Optional<String> name = Optional.empty(); IndexDescriptor descriptor = constraintIndex ? IndexDescriptorFactory.uniqueForSchema( schema, name, providerDescriptor ) : IndexDescriptorFactory.forSchema( schema, name, providerDescriptor ); StoreIndexDescriptor storeIndexDescriptor = constraintIndex ? descriptor.withIds( id, readOwningConstraint( serialized ) ) : descriptor.withId( id ); return storeIndexDescriptor; }
private void assertEqualityByDescriptor( IndexDescriptor descriptor ) { StoreIndexDescriptor rule1 = descriptor.withId( RULE_ID ); StoreIndexDescriptor rule2 = descriptor.withId( RULE_ID_2 ); StoreIndexDescriptor rule3 = (descriptor.type() == Type.GENERAL ? forSchema( descriptor.schema() ) : uniqueForSchema( descriptor.schema() )).withId( RULE_ID ); assertEquality( rule1, rule2 ); assertEquality( rule1, rule3 ); } }
@Test( expected = IllegalArgumentException.class ) public void constraintIndexRuleNameMustNotBeTheEmptyString() { //noinspection RedundantStringConstructorCall String name = new String( "" ); namedUniqueForLabel( name, LABEL_ID, PROPERTY_ID_1 ).withIds( RULE_ID, RULE_ID_2 ); }
@Override public String toString() { return userDescription( SchemaUtil.idTokenNameLookup ); }
StoreIndexDescriptor( IndexDescriptor descriptor, long id, Long owningConstraintId ) { super( descriptor ); this.id = id; this.name = descriptor.userSuppliedName.map( SchemaRule::checkName ).orElse( "index_" + id ); if ( descriptor.providerDescriptor() == null ) { throw new IllegalArgumentException( "null provider descriptor prohibited" ); } if ( owningConstraintId != null ) { assertValidId( owningConstraintId, "owning constraint id" ); } this.owningConstraintId = owningConstraintId; }
@Override public void initialize( IndexDescriptor descriptor, IndexProgressor progressor, IndexQuery[] queries, IndexOrder indexOrder, boolean needsValues ) { assertKeysAlign( descriptor.schema().getPropertyIds() ); progressors.add( progressor ); }
@Test( expected = IllegalArgumentException.class ) public void constraintIndexRuleNameMustNotContainNullCharacter() { String name = "a\0b"; namedUniqueForLabel( name, LABEL_ID, PROPERTY_ID_1 ).withIds( RULE_ID, RULE_ID_2 ); }
@Override public IndexSampler createSampler() { TaskControl taskControl = taskCoordinator.newInstance(); if ( descriptor.type() == UNIQUE ) { return new UniqueLuceneIndexSampler( getIndexSearcher(), taskControl ); } else { return new NonUniqueLuceneIndexSampler( getIndexSearcher(), taskControl, samplingConfig ); } }
/** * Use this method in cases where {@link org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException} * was caught but it should not have been allowed to be thrown in the first place. * Typically where the index we performed an operation on is not a unique index. */ public RuntimeException notAllowed( IndexDescriptor descriptor ) { return new IllegalStateException( String.format( "Index for (%s) should not require unique values.", descriptor.userDescription( SchemaUtil.idTokenNameLookup ) ), this ); }
@Override public IndexDescriptor getBlessedDescriptorFromProvider( IndexDescriptor index ) throws MisconfiguredIndexException { IndexProvider provider = providerMap.lookup( index.providerDescriptor() ); return provider.bless( index ); }
@Override public void visitIndex( IndexDescriptor descriptor, String userDescription, double uniqueValuesPercentage, long size ) { IndexDescriptorMap indices = descriptor.type() == UNIQUE ? uniqueIndices : regularIndices; indices.putIndex( descriptor.schema(), userDescription, uniqueValuesPercentage, size ); }
static AddedAndRemoved indexUpdatesForSuffixOrContains( ReadableTransactionState txState, IndexDescriptor descriptor, IndexQuery query, IndexOrder indexOrder ) { if ( descriptor.schema().getPropertyIds().length != 1 ) { throw new IllegalStateException( "Suffix and contains queries are only supported for single property queries" ); } return indexUpdatesForScanAndFilter( txState, descriptor, query, indexOrder ); }
private MultipleIndexPopulator.IndexPopulation addPopulator( MultipleIndexPopulator multipleIndexPopulator, IndexPopulator indexPopulator, long indexId, IndexDescriptor descriptor ) { return addPopulator( multipleIndexPopulator, descriptor.withId( indexId ), indexPopulator, mock( FlippableIndexProxy.class ), mock( FailedIndexProxyFactory.class ) ); }
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 ) ); } }
public static StoreIndexDescriptor constraintIndexRule( long ruleId, int labelId, int propertyId, IndexProviderDescriptor descriptor, long constraintId ) { return IndexDescriptorFactory.uniqueForSchema( forLabel( labelId, propertyId ), descriptor ).withIds( ruleId, constraintId ); }
if ( existingIndex.type() == UNIQUE )