public Set<Class<?>> getRootEntities() { return this.rootEntities.toPojosSet(); }
public void postInitialize(IndexedTypeSet indexedClassesSet) { Set<Class<?>> indexedClasses = indexedClassesSet.toPojosSet(); //we initialize only once because we no longer have a reference to the reflectionManager //in theory Class<?> plainClass = beanClass; if ( entityState == EntityState.NON_INDEXABLE ) { throw new AssertionFailure( "A non indexed entity is post processed" ); } Set<Class<?>> tempMappedSubclasses = new HashSet<Class<?>>(); //together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class for ( Class<?> currentClass : indexedClasses ) { if ( plainClass != currentClass && plainClass.isAssignableFrom( currentClass ) ) { tempMappedSubclasses.add( currentClass ); } } this.mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses ); Class<?> superClass = plainClass.getSuperclass(); this.isRoot = true; while ( superClass != null ) { if ( indexedClasses.contains( superClass ) ) { this.isRoot = false; break; } superClass = superClass.getSuperclass(); } }
public void postInitialize(IndexedTypeSet indexedClassesSet) { Set<Class<?>> indexedClasses = indexedClassesSet.toPojosSet(); //we initialize only once because we no longer have a reference to the reflectionManager //in theory Class<?> plainClass = beanClass; if ( entityState == EntityState.NON_INDEXABLE ) { throw new AssertionFailure( "A non indexed entity is post processed" ); } Set<Class<?>> tempMappedSubclasses = new HashSet<Class<?>>(); //together with the caller this creates a o(2), but I think it's still faster than create the up hierarchy for each class for ( Class<?> currentClass : indexedClasses ) { if ( plainClass != currentClass && plainClass.isAssignableFrom( currentClass ) ) { tempMappedSubclasses.add( currentClass ); } } this.mappedSubclasses = Collections.unmodifiableSet( tempMappedSubclasses ); Class<?> superClass = plainClass.getSuperclass(); this.isRoot = true; while ( superClass != null ) { if ( indexedClasses.contains( superClass ) ) { this.isRoot = false; break; } superClass = superClass.getSuperclass(); } }
@Override public Set<Class<?>> getIndexedTypes() { return searchIntegrator.getIndexBindings().keySet().toPojosSet(); }
throw new IllegalArgumentException( msg ); entities.addAll( targetedClasses.toPojosSet() );
entities.addAll( targetedClasses.toPojosSet() );
/** * Internal and experimental! Creates a {@link CacheQuery}, filtered according to the given {@link HSQuery}. * * @param hSearchQuery {@link HSQuery} * @return the CacheQuery object which can be used to iterate through results */ public <E> CacheQuery<E> getQuery(HSQuery hSearchQuery) { if (timeoutExceptionFactory != null) { hSearchQuery.timeoutExceptionFactory(timeoutExceptionFactory); } Class<?>[] classes = hSearchQuery.getTargetedEntities().toPojosSet().toArray(new Class[hSearchQuery.getTargetedEntities().size()]); queryInterceptor.enableClasses(classes); return new CacheQueryImpl<>(hSearchQuery, cache, queryInterceptor.getKeyTransformationHandler()); }
private void assertIsDoubleSet(IndexedTypeSet typeSet) { Assert.assertFalse( "Verify it's not a singleton", typeSet == IndexedTypeSets.empty() ); Assert.assertFalse( typeSet.isEmpty() ); Assert.assertEquals( 2, typeSet.size() ); Iterator<IndexedTypeIdentifier> iterator = typeSet.iterator(); Assert.assertTrue( iterator.hasNext() ); iterator.next(); // increment once iterator.next(); // increment twice Assert.assertFalse( iterator.hasNext() ); iterator.forEachRemaining( l -> Assert.fail( "should never happen" ) ); //no more elements Set<Class<?>> pojosSet = typeSet.toPojosSet(); Assert.assertTrue( pojosSet.contains( TYPE_A.getPojoType() ) ); Assert.assertTrue( pojosSet.contains( TYPE_B.getPojoType() ) ); Assert.assertEquals( 2, pojosSet.size() ); }
/** * Internal and experimental! Creates a {@link CacheQuery}, filtered according to the given {@link HSQuery}. * * @param hSearchQuery {@link HSQuery} * @return the CacheQuery object which can be used to iterate through results */ public <E> CacheQuery<E> getQuery(HSQuery hSearchQuery, IndexedQueryMode queryMode) { if (timeoutExceptionFactory != null) { hSearchQuery.timeoutExceptionFactory(timeoutExceptionFactory); } Class<?>[] classes = hSearchQuery.getTargetedEntities().toPojosSet().toArray(new Class[hSearchQuery.getTargetedEntities().size()]); queryInterceptor.enableClasses(classes); if (queryMode == IndexedQueryMode.BROADCAST) { ExecutorService asyncExecutor = queryInterceptor.getAsyncExecutor(); return new ClusteredCacheQueryImpl<>(new QueryDefinition(hSearchQuery), asyncExecutor, cache, keyTransformationHandler, null); } else { return new CacheQueryImpl<>(hSearchQuery, cache, keyTransformationHandler); } }
private void assertIsEmpty(IndexedTypeSet typeSet) { Assert.assertTrue( "Verify the singleton optimisation applies", typeSet == IndexedTypeSets.empty() ); Assert.assertTrue( typeSet.isEmpty() ); Assert.assertEquals( 0, typeSet.size() ); typeSet.iterator().forEachRemaining( l -> Assert.fail( "should never happen" ) ); Assert.assertEquals( 0, typeSet.toPojosSet().size() ); }
private void assertIsSingletonSet(IndexedTypeSet typeSet, Class<?> someType, boolean recursive) { Assert.assertFalse( "Verify it's not a singleton", typeSet == IndexedTypeSets.empty() ); Assert.assertFalse( typeSet.isEmpty() ); Assert.assertEquals( 1, typeSet.size() ); Iterator<IndexedTypeIdentifier> iterator = typeSet.iterator(); Assert.assertTrue( iterator.hasNext() ); IndexedTypeIdentifier firstElement = iterator.next(); // increment once Assert.assertFalse( iterator.hasNext() ); iterator.forEachRemaining( l -> Assert.fail( "should never happen" ) ); //no more elements Set<Class<?>> pojosSet = typeSet.toPojosSet(); Assert.assertTrue( pojosSet.contains( someType ) ); Assert.assertEquals( 1, pojosSet.size() ); IndexedTypeSet typeSet2 = firstElement.asTypeSet(); if ( recursive ) { assertIsSingletonSet( typeSet2, someType, false ); } Assert.assertEquals( typeSet2, typeSet2 ); Assert.assertEquals( firstElement.getPojoType(), someType ); }
/** * Decide which object loader to use depending on the targeted entities. If there is only a single entity targeted * a <code>QueryLoader</code> can be used which will only execute a single query to load the entities. If more than * one entity is targeted a <code>MultiClassesQueryLoader</code> must be used. We also have to consider whether * projections or <code>Criteria</code> are used. * * @return The loader instance to use to load the results of the query. */ private Loader getLoader() { ObjectLoaderBuilder loaderBuilder = new ObjectLoaderBuilder() .criteria( criteria ) .targetedEntities( hSearchQuery.getTargetedEntities() ) .indexedTargetedEntities( hSearchQuery.getIndexedTargetedEntities().toPojosSet() ) .session( session ) .searchFactory( hSearchQuery.getExtendedSearchIntegrator() ) .timeoutManager( hSearchQuery.getTimeoutManager() ) .lookupMethod( objectLookupMethod ) .retrievalMethod( databaseRetrievalMethod ); if ( hSearchQuery.getProjectedFields() != null ) { return getProjectionLoader( loaderBuilder ); } else { return loaderBuilder.buildLoader(); } }