Skip to content

Commit

Permalink
Move the logic for finding index rules by name, into SchemaStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Jan 10, 2019
1 parent 54da1b8 commit fd75d73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Expand Up @@ -173,16 +173,7 @@ public void visitRemovedIndex( IndexDescriptor index )
if ( name.isPresent() )
{
String indexName = name.get();
Iterator<StoreIndexDescriptor> itr = schemaStorage.indexesGetAll();
while ( itr.hasNext() )
{
StoreIndexDescriptor sid = itr.next();
if ( sid.getUserSuppliedName().map( n -> n.equals( indexName ) ).orElse( false ) )
{
rule = sid;
break;
}
}
rule = schemaStorage.indexGetForName( indexName );
}
else
{
Expand Down
Expand Up @@ -74,6 +74,26 @@ public StoreIndexDescriptor indexGetForSchema( final IndexDescriptor descriptor
return foundRule;
}

/**
* Find the IndexRule that has the given user supplied name.
*
* @param indexName the user supplied index name to look for.
* @return the matching IndexRule, or null if no matching index rule was found.
*/
public StoreIndexDescriptor indexGetForName( String indexName )
{
Iterator<StoreIndexDescriptor> itr = indexesGetAll();
while ( itr.hasNext() )
{
StoreIndexDescriptor sid = itr.next();
if ( sid.getUserSuppliedName().map( n -> n.equals( indexName ) ).orElse( false ) )
{
return sid;
}
}
return null;
}

public Iterator<StoreIndexDescriptor> indexesGetAll()
{
return loadAllSchemaRules( Predicates.alwaysTrue(), StoreIndexDescriptor.class, false );
Expand Down

0 comments on commit fd75d73

Please sign in to comment.