本文整理匯總了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;
}
示例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);
}
}
示例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 );
}
}
}
示例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 ...");
}