當前位置: 首頁>>代碼示例>>Java>>正文


Java Indexed類代碼示例

本文整理匯總了Java中org.hibernate.search.annotations.Indexed的典型用法代碼示例。如果您正苦於以下問題:Java Indexed類的具體用法?Java Indexed怎麽用?Java Indexed使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Indexed類屬於org.hibernate.search.annotations包,在下文中一共展示了Indexed類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIndexedClasses

import org.hibernate.search.annotations.Indexed; //導入依賴的package包/類
/**
 * 인덱싱된 엔티티의 수형을 반환합니다.
 *
 * @param sessionFactory the session factory
 * @return 인덱싱된 엔티티의 수형들
 */
public static Set<Class> getIndexedClasses(SessionFactory sessionFactory) {
    if (log.isDebugEnabled())
        log.debug("매핑된 엔티티중에 인덱싱을 수행할 엔티티들을 조회합니다.");

    final Set<Class> classes = Sets.newHashSet();
    Collection<ClassMetadata> metadatas = sessionFactory.getAllClassMetadata().values();

    for (ClassMetadata meta : metadatas) {
        Class clazz = meta.getMappedClass();
        if (clazz.getAnnotation(Indexed.class) != null) {
            classes.add(clazz);

                log.trace("인덱싱된 엔티티=[{}]", clazz);
        }
    }
    return classes;
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:24,代碼來源:SearchTool.java

示例2: clearLuceneIndexes

import org.hibernate.search.annotations.Indexed; //導入依賴的package包/類
/**
 * Clear lucene indexes.
 *
 * @throws Exception the exception
 */
private void clearLuceneIndexes() throws Exception {

  final Reflections reflections = new Reflections();
  for (final Class<?> clazz : reflections
      .getTypesAnnotatedWith(Indexed.class)) {
    fullTextEntityManager.purgeAll(clazz);
  }
}
 
開發者ID:WestCoastInformatics,項目名稱:UMLS-Terminology-Server,代碼行數:14,代碼來源:LuceneReindexAlgorithm.java

示例3: parse

import org.hibernate.search.annotations.Indexed; //導入依賴的package包/類
public void parse(Metamodel metaModel) {
	// clear the (old) state
	this.isRootType.clear();
	this.managedTypes.clear();
	this.idProperties.clear();
	this.managedTypes.clear();
	this.managedTypes.putAll(
			metaModel.getManagedTypes().stream().filter(
					(meta3) -> {
						return meta3 instanceof EntityType;
					}
			).collect(
					Collectors.toMap(
							(meta) -> {
								return meta.getJavaType();
							}, (meta2) -> {
								return meta2;
							}
					)
			)
	);
	Set<EntityType<?>> emptyVisited = Collections.emptySet();
	this.totalVisitedEntities.clear();
	for ( EntityType<?> curEntType : metaModel.getEntities() ) {
		// we only consider Entities that are @Indexed here
		if ( curEntType.getJavaType().isAnnotationPresent( Indexed.class ) ) {
			this.idProperties.put( curEntType.getJavaType(), this.getIdProperty( metaModel, curEntType ) );
			this.isRootType.put( curEntType.getJavaType(), true );
			Map<Class<? extends Annotation>, Set<Attribute<?, ?>>> attributeForAnnotationType = buildAttributeForAnnotationType(
					curEntType
			);
			// and do the recursion
			this.doRecursion( attributeForAnnotationType, curEntType, emptyVisited );
		}
	}
}
 
開發者ID:Hotware,項目名稱:Hibernate-Search-GenericJPA,代碼行數:37,代碼來源:MetaModelParser.java

示例4: computeLuceneIndexes

import org.hibernate.search.annotations.Indexed; //導入依賴的package包/類
/**
 * Compute lucene indexes.
 *
 * @param indexedObjects the indexed objects
 * @throws Exception the exception
 */
private void computeLuceneIndexes(String indexedObjects) throws Exception {
  // set of objects to be re-indexed
  final Set<String> objectsToReindex = new HashSet<>();
  final Map<String, Class<?>> reindexMap = new HashMap<>();
  final Reflections reflections = new Reflections();
  for (final Class<?> clazz : reflections
      .getTypesAnnotatedWith(Indexed.class)) {
    reindexMap.put(clazz.getSimpleName(), clazz);
  }

  // if no parameter specified, re-index all objects
  if (indexedObjects == null || indexedObjects.isEmpty()) {

    // Add all class names
    for (final String className : reindexMap.keySet()) {
      if (objectsToReindex.contains(className)) {
        // This restriction can be removed by using full class names
        // however, then calling the mojo is more complicated
        throw new Exception(
            "Reindex process assumes simple class names are different.");
      }
      objectsToReindex.add(className);
    }

    // otherwise, construct set of indexed objects
  } else {

    // remove white-space and split by comma
    String[] objects = indexedObjects.replaceAll(" ", "").split(",");

    // add each value to the set
    for (final String object : objects)
      objectsToReindex.add(object);

  }

  Logger.getLogger(getClass()).info("Starting reindexing for:");
  for (final String objectToReindex : objectsToReindex) {
    Logger.getLogger(getClass()).info("  " + objectToReindex);
  }

  // Reindex each object
  for (final String key : reindexMap.keySet()) {
    // Concepts
    if (objectsToReindex.contains(key)) {
      Logger.getLogger(getClass()).info("  Creating indexes for " + key);
      fullTextEntityManager.purgeAll(reindexMap.get(key));
      fullTextEntityManager.flushToIndexes();
      fullTextEntityManager.createIndexer(reindexMap.get(key))
          .batchSizeToLoadObjects(100).cacheMode(CacheMode.IGNORE)
          .idFetchSize(100).threadsToLoadObjects(10).startAndWait();
      // optimize flags are default true.
      objectsToReindex.remove(key);
    }
  }

  if (objectsToReindex.size() != 0) {
    throw new Exception(
        "The following objects were specified for re-indexing, but do not exist as indexed objects: "
            + objectsToReindex.toString());
  }

  // Cleanup
  Logger.getLogger(getClass()).info("done ...");
}
 
開發者ID:WestCoastInformatics,項目名稱:UMLS-Terminology-Server,代碼行數:72,代碼來源:LuceneReindexAlgorithm.java


注:本文中的org.hibernate.search.annotations.Indexed類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。