Package org.hibernate.search.store

Examples of org.hibernate.search.store.IndexShardingStrategy


      }
    }
  }

  private IndexShardingStrategy createIndexShardingStrategy( Properties[] indexProps, IndexManager[] indexManagers ) {
    IndexShardingStrategy shardingStrategy;

    // any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName,
          DirectoryProviderFactory.class.getClassLoader(),
          "IndexShardingStrategy"
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
    );
    return shardingStrategy;
  }
View Full Code Here


          mappedClass,
          buildContext
      );
    }

    IndexShardingStrategy shardingStrategy = null;
    if ( !isDynamicSharding ) {
      shardingStrategy = createIndexShardingStrategy( indexProperties, indexManagers, buildContext );
    }

    ShardIdentifierProvider shardIdentifierProvider = null;
View Full Code Here

  }

  private IndexShardingStrategy createIndexShardingStrategy(Properties[] indexProps,
      IndexManager[] indexManagers,
      WorkerBuildContext buildContext) {
    IndexShardingStrategy shardingStrategy;

    // any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      ServiceManager serviceManager = buildContext.getServiceManager();
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName,
          "IndexShardingStrategy",
          serviceManager
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
    );
    return shardingStrategy;
  }
View Full Code Here

    is.setSimilarity( searcherSimilarity );
    return is;
  }

  private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
    final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
    final DirectoryProvider[] directoryProviders;
    if ( filterDefinitions != null && !filterDefinitions.isEmpty() ) {
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery(
          filterDefinitions.values().toArray( new FullTextFilterImplementor[filterDefinitions.size()] )
      );
    }
    else {
      //no filter get all shards
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR );
    }

    for ( DirectoryProvider provider : directoryProviders ) {
      if ( !directories.contains( provider ) ) {
        directories.add( provider );
View Full Code Here

  }
 
  private void sendWorkToShards(LuceneWork work, PerDirectoryWorkProcessor worker) throws InterruptedException {
    final Class<?> entityType = work.getEntityClass();
    DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
    IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
    work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, worker );
  }
View Full Code Here

    QueueProcessors processors = new QueueProcessors( resourcesMap );
    // divide the queue in tasks, adding to QueueProcessors by affected Directory.
    for ( LuceneWork work : queue ) {
      final Class<?> entityType = work.getEntityClass();
      DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
      IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
      work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, processors );
    }
    try {
      //this Runnable splits tasks in more runnables and then runs them:
      processors.runAll( sync );
View Full Code Here

      indexManager.addContainedEntity( mappedClass );
      providers[index] = indexManager;
    }

    //define sharding strategy for this entity:
    IndexShardingStrategy shardingStrategy;
    //any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName, DirectoryProviderFactory.class, "IndexShardingStrategy"
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), providers
    );

    //define the Similarity implementation:
    // warning: it can also be set by an annotation at class level
View Full Code Here

    }
    return is;
  }

  private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
    final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
    final DirectoryProvider[] directoryProviders;
    if ( filterDefinitions != null && !filterDefinitions.isEmpty() ) {
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery(
          filterDefinitions.values().toArray( new FullTextFilterImplementor[filterDefinitions.size()] )
      );
    }
    else {
      //no filter get all shards
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR );
    }

    for ( DirectoryProvider provider : directoryProviders ) {
      if ( !directories.contains( provider ) ) {
        directories.add( provider );
View Full Code Here

          mappedClass,
          buildContext
      );
    }

    IndexShardingStrategy shardingStrategy = null;
    if ( !isDynamicSharding ) {
      shardingStrategy = createIndexShardingStrategy( indexProperties, indexManagers, buildContext );
    }

    ShardIdentifierProvider shardIdentifierProvider = null;
View Full Code Here

  }

  private IndexShardingStrategy createIndexShardingStrategy(Properties[] indexProps,
      IndexManager[] indexManagers,
      WorkerBuildContext buildContext) {
    IndexShardingStrategy shardingStrategy;

    // any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      ServiceManager serviceManager = buildContext.getServiceManager();
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName,
          "IndexShardingStrategy",
          serviceManager
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
    );
    return shardingStrategy;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.store.IndexShardingStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.