Skip to content

Commit

Permalink
HSEARCH-1401 Remove syntactic sugar from PojoIndexingPlan/PojoIndexer
Browse files Browse the repository at this point in the history
This is an SPI type, not an API type, so let's keep it simple.
  • Loading branch information
yrodiere committed Dec 6, 2019
1 parent 55083bd commit 1ce6727
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SearchIndexingPlanImpl(PojoIndexingPlan delegate) {

@Override
public void add(Object entity) {
delegate.add( entity );
delegate.add( null, entity );
}

@Override
Expand All @@ -32,7 +32,7 @@ public void add(Object providedId, Object entity) {

@Override
public void addOrUpdate(Object entity) {
delegate.addOrUpdate( entity );
delegate.addOrUpdate( null, entity );
}

@Override
Expand All @@ -42,7 +42,7 @@ public void addOrUpdate(Object providedId, Object entity) {

@Override
public void addOrUpdate(Object entity, String... dirtyPaths) {
delegate.addOrUpdate( entity, dirtyPaths );
delegate.addOrUpdate( null, entity, dirtyPaths );
}

@Override
Expand All @@ -52,7 +52,7 @@ public void addOrUpdate(Object providedId, Object entity, String... dirtyPaths)

@Override
public void delete(Object entity) {
delegate.delete( entity );
delegate.delete( null, entity );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private CompletableFuture<?> index(PojoIndexer indexer, E entity) throws Interru

CompletableFuture<?> future;
try {
future = indexer.add( entity );
future = indexer.add( null, entity );
}
catch (RuntimeException e) {
future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public SearchIndexingPlanImpl(SearchIndexingPlanContext context) {

@Override
public void addOrUpdate(Object entity) {
context.getCurrentIndexingPlan( true ).addOrUpdate( entity );
context.getCurrentIndexingPlan( true ).addOrUpdate( null, entity );
}

@Override
public void delete(Object entity) {
context.getCurrentIndexingPlan( true ).delete( entity );
context.getCurrentIndexingPlan( true ).delete( null, entity );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public PojoIndexerImpl(PojoWorkIndexedTypeContextProvider indexedTypeContextProv
this.commitStrategy = commitStrategy;
}

@Override
public CompletableFuture<?> add(Object entity) {
return add( null, entity );
}

@Override
public CompletableFuture<?> add(Object providedId, Object entity) {
PojoRawTypeIdentifier<?> typeIdentifier = introspector.getTypeIdentifier( entity );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,27 @@ public PojoIndexingPlanImpl(PojoWorkIndexedTypeContextProvider indexedTypeContex
this.refreshStrategy = refreshStrategy;
}

@Override
public void add(Object entity) {
add( null, entity );
}

@Override
public void add(Object providedId, Object entity) {
PojoRawTypeIdentifier<?> typeIdentifier = introspector.getTypeIdentifier( entity );
AbstractPojoTypeIndexingPlan delegate = getDelegate( typeIdentifier );
delegate.add( providedId, entity );
}

@Override
public void addOrUpdate(Object entity) {
addOrUpdate( null, entity );
}

@Override
public void addOrUpdate(Object providedId, Object entity) {
PojoRawTypeIdentifier<?> typeIdentifier = introspector.getTypeIdentifier( entity );
AbstractPojoTypeIndexingPlan delegate = getDelegate( typeIdentifier );
delegate.update( providedId, entity );
}

@Override
public void addOrUpdate(Object entity, String... dirtyPaths) {
addOrUpdate( null, entity, dirtyPaths );
}

@Override
public void addOrUpdate(Object providedId, Object entity, String... dirtyPaths) {
PojoRawTypeIdentifier<?> typeIdentifier = introspector.getTypeIdentifier( entity );
AbstractPojoTypeIndexingPlan delegate = getDelegate( typeIdentifier );
delegate.update( providedId, entity, dirtyPaths );
}

@Override
public void delete(Object entity) {
delete( null, entity );
}

@Override
public void delete(Object providedId, Object entity) {
PojoRawTypeIdentifier<?> typeIdentifier = introspector.getTypeIdentifier( entity );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,4 @@ public interface PojoIndexer {
*/
CompletableFuture<?> add(Object providedId, Object entity);

/**
* Add an entity to the index, assuming that the entity is absent from the index.
* <p>
* Shorthand for {@code add(null, entity)}; see {@link #add(Object, Object)}.
*
* @param entity The entity to add to the index.
* @return A {@link CompletableFuture} reflecting the completion state of the operation.
*/
CompletableFuture<?> add(Object entity);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,12 @@
*/
public interface PojoIndexingPlan {

/**
* Add an entity to the index, assuming that the entity is absent from the index.
* <p>
* Shorthand for {@code add(null, entity)}; see {@link #add(Object, Object)}.
*
* @param entity The entity to add to the index.
*/
void add(Object entity);

/**
* Add an entity to the index, assuming that the entity is absent from the index.
* <p>
* <strong>Note:</strong> depending on the backend, this may lead to errors or duplicate entries in the index
* if the entity was actually already present in the index before this call.
* When in doubt, you should rather use {@link #addOrUpdate(Object, Object)} or {@link #addOrUpdate(Object)}.
* When in doubt, you should rather use {@link #addOrUpdate(Object, Object)}.
*
* @param providedId A value to extract the document ID from.
* Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
Expand All @@ -52,15 +43,6 @@ public interface PojoIndexingPlan {
*/
void add(Object providedId, Object entity);

/**
* Update an entity in the index, or add it if it's absent from the index.
* <p>
* Shorthand for {@code update(null, entity)}; see {@link #addOrUpdate(Object, Object)}.
*
* @param entity The entity to update in the index.
*/
void addOrUpdate(Object entity);

/**
* Update an entity in the index, or add it if it's absent from the index.
*
Expand All @@ -71,21 +53,6 @@ public interface PojoIndexingPlan {
*/
void addOrUpdate(Object providedId, Object entity);

/**
* Update an entity in the index, or add it if it's absent from the index,
* but try to avoid reindexing if the given dirty paths
* are known not to impact the indexed form of that entity.
* <p>
* Assumes that the entity may already be present in the index.
* <p>
* Shorthand for {@code update(null, entity, dirtyPaths)}; see {@link #addOrUpdate(Object, Object)}.
*
* @param entity The entity to update in the index.
* @param dirtyPaths The paths to consider dirty, formatted using the dot-notation
* ("directEntityProperty.nestedPropery").
*/
void addOrUpdate(Object entity, String... dirtyPaths);

/**
* Update an entity in the index, or add it if it's absent from the index,
* but try to avoid reindexing if the given dirty paths
Expand All @@ -100,15 +67,6 @@ public interface PojoIndexingPlan {
*/
void addOrUpdate(Object providedId, Object entity, String... dirtyPaths);

/**
* Delete an entity from the index.
* <p>
* Shorthand for {@code delete(null, entity)}; see {@link #delete(Object, Object)}.
*
* @param entity The entity to delete from the index.
*/
void delete(Object entity);

/**
* Delete an entity from the index.
* <p>
Expand Down

0 comments on commit 1ce6727

Please sign in to comment.