Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

Automatic reindexing - without fine-grained dirty checking #38

Merged
merged 43 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
406622a
Enable collection event processing in the ORM integration
yrodiere Mar 13, 2018
2407e90
Add ContainerValueExtractorPath to represent a chain of extractors
yrodiere Mar 15, 2018
5c6667b
Add BoundPojoModelPath to model POJO access path during indexing
yrodiere Mar 14, 2018
0cdba98
Introduce a PojoMappingHelper to aggregate mapping-related global hel…
yrodiere Mar 15, 2018
feabd23
Store augmented models (markers) in dedicated objects
yrodiere Mar 15, 2018
a1aef49
Add a way to define the inverse side of an association explicitly
yrodiere Mar 15, 2018
02e651f
Provide the TypeMetadataContributorProvider to the MapperFactory inst…
yrodiere Mar 21, 2018
6772578
Build only one PojoAugmentedTypeModelProvider and PojoMappingHelper p…
yrodiere Mar 23, 2018
b68c040
Move work planning to the POJO mapper module
yrodiere Mar 26, 2018
6de2e3f
Rename POJO managers/workers to make it clear they are about *indexed…
yrodiere Mar 22, 2018
0833952
Reduce the visibility of some unnecessarily exposed methods in POJO t…
yrodiere Mar 26, 2018
f33d8fb
Move POJO model/mapping contributors and collectors to SPIs to allow …
yrodiere Mar 23, 2018
74d9ed1
Add metadata about which type is an entity in the POJO mapper
yrodiere Mar 23, 2018
e9c887c
Automatically contribute association inverse sides based on Hibernate…
yrodiere Mar 26, 2018
2c44350
Test basic automatic indexing in the ORM integration
yrodiere Mar 13, 2018
6ef6292
Add inverse side of associations in ORM tests
yrodiere Mar 26, 2018
176e684
Include whether a type is abstract or not in type models
yrodiere Apr 4, 2018
614c62f
Implement basic automatic reindexing across entities
yrodiere Mar 23, 2018
857d803
Test automatic indexing after indirect changes in the ORM integration
yrodiere Mar 13, 2018
e1ceb6e
Support polymorphic associations in automatic reindexing
yrodiere Mar 28, 2018
a0cf67b
Test automatic indexing with polymorphic associations in the ORM inte…
yrodiere Mar 28, 2018
4b2fae4
Test automatic indexing with generic, polymorphic associations in the…
yrodiere Mar 29, 2018
038b6a1
Move ContainerValueExtractorPath to API and use it in programmatic ma…
yrodiere Apr 4, 2018
0b27eed
Add PojoModelPath to model unbound POJO access paths
yrodiere Mar 28, 2018
11db6a3
Support associations in embeddables when the inverse side information…
yrodiere Apr 5, 2018
a54545d
Test automatic indexing with associations in embeddables on one side …
yrodiere Mar 16, 2018
76e7c50
Add a way to define a property/value as embedding associations
yrodiere Apr 6, 2018
5a31695
Automatically contribute association embeddeds based on Hibernate ORM…
yrodiere Apr 6, 2018
38d34e4
Support associations in embeddables when the inverse side information…
yrodiere Apr 6, 2018
167ca41
Test automatic indexing with embeddables on both sides in the ORM int…
yrodiere Apr 5, 2018
3eb2fa5
Take dependencies from TypeBridge/PropertyBridge into account in auto…
yrodiere Apr 6, 2018
193e8eb
Test automatic indexing with TypeBridge/PropertyBridge in the ORM int…
yrodiere Apr 6, 2018
225a139
Make sure to not contribute any dependency related to bridges that we…
yrodiere Apr 6, 2018
691f66b
Test automatic indexing with indexed-embedded TypeBridge/PropertyBrid…
yrodiere Apr 6, 2018
9508ef9
Add a protection against infinite recursion in PojoAssociationPathInv…
yrodiere Apr 9, 2018
ad8ad1f
Clarify the implementation of ChangesetPojoContainedTypeWorker.WorkPl…
yrodiere Apr 11, 2018
ab9e2f5
Use a get prefix where relevant in methods of POJO path classes
yrodiere Apr 12, 2018
e9949a4
Rename "augmented models" to "additional metadata"
yrodiere Apr 12, 2018
85ede4e
Add some documentation to indexing processor builders
yrodiere Apr 13, 2018
c388669
Clean up and document generic type parameters in POJO workers and typ…
yrodiere Apr 13, 2018
6d56fb3
Try to clarify node and path attributes in dependency collectors
yrodiere Apr 13, 2018
147faed
Clean up and document generic type parameters in PojoModelElement et.…
yrodiere Apr 13, 2018
c8f1707
Rename the markForReindexing boolean to shouldMarkForReindexing for m…
yrodiere Apr 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


/**
* @author Yoann Rodiere
* @param <D> The expected document type.
*/
public interface DocumentContributor<D> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.hibernate.search.v6poc.backend.document.DocumentElement;
import org.hibernate.search.v6poc.backend.document.model.spi.IndexSchemaCollector;
import org.hibernate.search.v6poc.backend.index.impl.SimplifyingIndexManager;
import org.hibernate.search.v6poc.backend.index.spi.IndexManager;
import org.hibernate.search.v6poc.backend.index.spi.IndexManagerBuilder;
import org.hibernate.search.v6poc.backend.spi.Backend;
Expand Down Expand Up @@ -116,10 +115,7 @@ public IndexModelBindingContext getRootBindingContext() {

@Override
public IndexManager<D> build() {
IndexManager<D> result = builder.build();
// Optimize changeset execution in the resulting index manager
result = new SimplifyingIndexManager<>( result );
return result;
return builder.build();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
*/
package org.hibernate.search.v6poc.engine.impl;

import java.lang.invoke.MethodHandles;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message: s/wether/whether/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -37,11 +39,15 @@
import org.hibernate.search.v6poc.entity.mapping.spi.MappingImplementor;
import org.hibernate.search.v6poc.entity.mapping.spi.MappingKey;
import org.hibernate.search.v6poc.entity.model.spi.MappableTypeModel;
import org.hibernate.search.v6poc.logging.impl.Log;
import org.hibernate.search.v6poc.util.AssertionFailure;
import org.hibernate.search.v6poc.util.SearchException;
import org.hibernate.search.v6poc.util.impl.common.LoggerFactory;

public class SearchMappingRepositoryBuilderImpl implements SearchMappingRepositoryBuilder {

private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );

private final ConfigurationPropertySource mainPropertySource;
private final Properties overriddenProperties = new Properties();
private final Collection<MetadataContributor> contributors = new ArrayList<>();
Expand Down Expand Up @@ -98,7 +104,7 @@ public SearchMappingRepository build() {
MetadataCollectorImpl metadataCollector = new MetadataCollectorImpl();
contributors.forEach( c -> c.contribute( buildContext, metadataCollector ) );

Map<MappingKey<?>, Mapper<?, ?>> mappers =
Map<MappingKey<?>, Mapper<?>> mappers =
metadataCollector.createMappers( buildContext, propertySource, indexManagerBuildingStateProvider );

Map<MappingKey<?>, MappingImplementor<?>> mappings = new HashMap<>();
Expand Down Expand Up @@ -143,13 +149,13 @@ public <C> void collectDiscoverer(MapperFactory<C, ?> mapperFactory,
getOrCreateContribution( mapperFactory ).collectDiscoverer( metadataDiscoverer );
}

Map<MappingKey<?>, Mapper<?, ?>> createMappers(
Map<MappingKey<?>, Mapper<?>> createMappers(
BuildContext buildContext, ConfigurationPropertySource propertySource,
IndexManagerBuildingStateHolder indexManagerBuildingStateProvider) {
frozen = true;
Map<MappingKey<?>, Mapper<?, ?>> mappers = new HashMap<>();
Map<MappingKey<?>, Mapper<?>> mappers = new HashMap<>();
contributionByMappingKey.forEach( (mappingKey, contribution) -> {
Mapper<?, ?> mapper = contribution.preBuild( buildContext, propertySource, indexManagerBuildingStateProvider );
Mapper<?> mapper = contribution.preBuild( buildContext, propertySource, indexManagerBuildingStateProvider );
mappers.put( mappingKey, mapper );
} );
return mappers;
Expand Down Expand Up @@ -191,6 +197,9 @@ private static class MapperContribution<C, M> {
}

public void mapToIndex(MappableTypeModel typeModel, String indexName) {
if ( typeModel.isAbstract() ) {
throw log.cannotMapAbstractTypeToIndex( typeModel, indexName );
}
getOrCreateContribution( typeModel ).mapToIndex( indexName );
}

Expand All @@ -202,10 +211,10 @@ public void collectDiscoverer(TypeMetadataDiscoverer<C> metadataDiscoverer) {
metadataDiscoverers.add( metadataDiscoverer );
}

public Mapper<C, M> preBuild(BuildContext buildContext, ConfigurationPropertySource propertySource,
public Mapper<M> preBuild(BuildContext buildContext, ConfigurationPropertySource propertySource,
IndexManagerBuildingStateHolder indexManagerBuildingStateHolder) {
ContributorProvider contributorProvider = new ContributorProvider();
Mapper<C, M> mapper = mapperFactory.createMapper( buildContext, propertySource );
Mapper<M> mapper = mapperFactory.createMapper( buildContext, propertySource, contributorProvider );

Set<MappableTypeModel> potentiallyMappedToIndexTypes = new LinkedHashSet<>( contributionByType.keySet() );
for ( MappableTypeModel typeModel : potentiallyMappedToIndexTypes ) {
Expand All @@ -214,8 +223,7 @@ public Mapper<C, M> preBuild(BuildContext buildContext, ConfigurationPropertySou
if ( indexName != null ) {
mapper.addIndexed(
typeModel,
indexManagerBuildingStateHolder.startBuilding( indexName ),
contributorProvider
indexManagerBuildingStateHolder.startBuilding( indexName )
);
}
}
Expand Down Expand Up @@ -257,6 +265,11 @@ public void forEach(MappableTypeModel typeModel, Consumer<C> contributorConsumer
.flatMap( TypeMappingContribution::getContributors )
.forEach( contributorConsumer );
}

@Override
public Set<? extends MappableTypeModel> getTypesContributedTo() {
return Collections.unmodifiableSet( new HashSet<>( contributionByType.keySet() ) );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
import org.hibernate.search.v6poc.entity.mapping.spi.MappingImplementor;
import org.hibernate.search.v6poc.entity.model.spi.MappableTypeModel;

public interface Mapper<C, M> {
public interface Mapper<M> {

/**
* @param typeModel A model of the type to be mapped
* @param indexManagerBuildingState The building state for the index to be mapped
* @param contributorProvider A provider of composite mapping contributors, with contributions
* guaranteed to be ordered from supertype to subtype, allowing the builder to support overrides if necessary.
*/
void addIndexed(MappableTypeModel typeModel,
IndexManagerBuildingState<?> indexManagerBuildingState,
TypeMetadataContributorProvider<C> contributorProvider);
void addIndexed(MappableTypeModel typeModel, IndexManagerBuildingState<?> indexManagerBuildingState);

MappingImplementor<M> build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface MapperFactory<C, M> {

MappingKey<M> getMappingKey();

Mapper<C, M> createMapper(BuildContext buildContext, ConfigurationPropertySource propertySource);
Mapper<M> createMapper(BuildContext buildContext, ConfigurationPropertySource propertySource,
TypeMetadataContributorProvider<C> contributorProvider);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.search.v6poc.entity.mapping.building.spi;

import java.util.Set;
import java.util.function.Consumer;

import org.hibernate.search.v6poc.entity.model.spi.MappableTypeModel;
Expand All @@ -16,9 +17,14 @@
public interface TypeMetadataContributorProvider<C> {

/**
* @param typeModel The model of a type to retrieve contributors for.
* @param typeModel The model of a type to retrieve contributors for, including supertype contributors.
* @param contributorConsumer The consumer that will be applied to each contributor.
*/
void forEach(MappableTypeModel typeModel, Consumer<C> contributorConsumer);

/**
* @return A set containing all the types that were contributed to so far.
*/
Set<? extends MappableTypeModel> getTypesContributedTo();

}
Loading