public Map<String, String> getNodeIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Node.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No node index '" + indexName + "' found" ); } return config; }
private void makeSureAllIndexesAreInstantiated() { for ( String name : indexStore.getNames( Node.class ) ) { Map<String, String> config = indexStore.get( Node.class, name ); if ( config.get( IndexManager.PROVIDER ).equals( LuceneIndexImplementation.SERVICE_NAME ) ) { ensureInstantiated( new IndexIdentifier( IndexEntityType.Node, name ) ); } } for ( String name : indexStore.getNames( Relationship.class ) ) { Map<String, String> config = indexStore.get( Relationship.class, name ); if ( config.get( IndexManager.PROVIDER ).equals( LuceneIndexImplementation.SERVICE_NAME ) ) { ensureInstantiated( new IndexIdentifier( IndexEntityType.Relationship, name ) ); } } }
public Map<String, String> getRelationshipIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Relationship.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No relationship index '" + indexName + "' found" ); } return config; }
private void removeProvidersFromIndexDbFile( DatabaseLayout databaseLayout ) { IndexConfigStore indexStore = new IndexConfigStore( databaseLayout, fileSystemRule.get() ); for ( Class<? extends PropertyContainer> cls : new Class[] {Node.class, Relationship.class} ) { for ( String name : indexStore.getNames( cls ) ) { Map<String, String> config = indexStore.get( cls, name ); config = new HashMap<>( config ); config.remove( IndexManager.PROVIDER ); indexStore.set( Node.class, name, config ); } } } }
private Map<String, String> config( Class<? extends PropertyContainer> cls, String indexName, Map<String, String> config ) { // TODO Doesn't look right if ( config != null ) { config = MapUtil.stringMap( new HashMap<>( config ), IndexManager.PROVIDER, LuceneIndexImplementation.SERVICE_NAME ); indexStore.setIfNecessary( cls, indexName, config ); return config; } else { return indexStore.get( cls, indexName ); } }
@Override public boolean checkIndexExistence( IndexEntityType entityType, String indexName, Map<String,String> config ) { Map<String, String> configuration = indexConfigStore.get( entityType.entityClass(), indexName ); if ( configuration == null ) { return false; } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); assertConfigMatches( provider, indexName, configuration, config ); return true; }
@Override public ExplicitIndex relationshipChanges( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> configuration = indexConfigStore.get( Relationship.class, indexName ); if ( configuration == null ) { throw new ExplicitIndexNotFoundKernelException( "Relationship index '" + indexName + " not found" ); } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); ExplicitIndexProviderTransaction transaction = transactions.get( providerName ); if ( transaction == null ) { transactions.put( providerName, transaction = provider.newTransaction( this ) ); } return transaction.relationshipIndex( indexName, configuration ); }
@Override public ExplicitIndex nodeChanges( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> configuration = indexConfigStore.get( Node.class, indexName ); if ( configuration == null ) { throw new ExplicitIndexNotFoundKernelException( "Node index '" + indexName + " not found" ); } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); ExplicitIndexProviderTransaction transaction = transactions.computeIfAbsent( providerName, k -> provider.newTransaction( this ) ); return transaction.nodeIndex( indexName, configuration ); }
private ExplicitIndexTransactionStateImpl newExplicitIndexTxState() { indexConfigStore = mock( IndexConfigStore.class ); when( indexConfigStore.get( eq( Node.class ), anyString() ) ).thenReturn( config ); when( indexConfigStore.get( eq( Relationship.class ), anyString() ) ).thenReturn( config ); ExplicitIndexProvider explicitIndexProvider = mock( ExplicitIndexProvider.class ); when( explicitIndexProvider.getProviderByName( anyString() ) ).thenReturn( provider ); return new ExplicitIndexTransactionStateImpl( indexConfigStore, explicitIndexProvider ); } }
IndexType getIndexType( IndexIdentifier identifier, boolean recovery ) throws ExplicitIndexNotFoundKernelException { Pair<Integer, IndexType> type = cache.get( identifier ); Map<String, String> config = indexStore.get( identifier.entityType.entityClass(), identifier.indexName ); if ( config == null ) { if ( recovery ) { return null; } throw new ExplicitIndexNotFoundKernelException( "Index '%s' doesn't exist.", identifier ); } if ( type != null && config.hashCode() == type.first() ) { return type.other(); } type = Pair.of( config.hashCode(), IndexType.getIndexType( config ) ); cache.put( identifier, type ); return type.other(); }
@Test public void shouldReportIndexDoesNotExist() { // given ExplicitIndexTransactionStateImpl state = newExplicitIndexTxState(); when( indexConfigStore.get( any( Class.class ), anyString() ) ).thenReturn( null ); // when boolean exists = state.checkIndexExistence( IndexEntityType.Relationship, "name", null ); // then assertFalse( exists ); }
Map<String,String> config = indexConfigStore.get( entityType.entityClass(), indexName ); if ( config == null )
Map<String, String> storedConfig = indexStore.get( cls, indexName ); if ( storedConfig != null && suppliedConfig == null )
Map<String,String> existing = indexStore.get( entityType.entityClass(), indexName ); if ( existing != null )
public Map<String, String> getNodeIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Node.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No node index '" + indexName + "' found" ); } return config; }
public Map<String, String> getRelationshipIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Relationship.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No relationship index '" + indexName + "' found" ); } return config; }
@Override public boolean checkIndexExistence( IndexEntityType entityType, String indexName, Map<String,String> config ) { Map<String, String> configuration = indexConfigStore.get( entityType.entityClass(), indexName ); if ( configuration == null ) { return false; } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); assertConfigMatches( provider, indexName, configuration, config ); return true; }
@Override public ExplicitIndex nodeChanges( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> configuration = indexConfigStore.get( Node.class, indexName ); if ( configuration == null ) { throw new ExplicitIndexNotFoundKernelException( "Node index '" + indexName + " not found" ); } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); ExplicitIndexProviderTransaction transaction = transactions.computeIfAbsent( providerName, k -> provider.newTransaction( this ) ); return transaction.nodeIndex( indexName, configuration ); }
@Override public ExplicitIndex relationshipChanges( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> configuration = indexConfigStore.get( Relationship.class, indexName ); if ( configuration == null ) { throw new ExplicitIndexNotFoundKernelException( "Relationship index '" + indexName + " not found" ); } String providerName = configuration.get( IndexManager.PROVIDER ); IndexImplementation provider = providerLookup.getProviderByName( providerName ); ExplicitIndexProviderTransaction transaction = transactions.get( providerName ); if ( transaction == null ) { transactions.put( providerName, transaction = provider.newTransaction( this ) ); } return transaction.relationshipIndex( indexName, configuration ); }
Map<String,String> config = indexConfigStore.get( entityType.entityClass(), indexName ); if ( config == null )