Skip to content

Commit

Permalink
HSEARCH-4155 Consistently use the terms "add or update" rather than "…
Browse files Browse the repository at this point in the history
…update" for document indexing

Just for consistency and to avoid misleading language.

Signed-off-by: Yoann Rodière <yoann@hibernate.org>
  • Loading branch information
yrodiere committed Feb 10, 2021
1 parent aa3845d commit 5983693
Show file tree
Hide file tree
Showing 58 changed files with 229 additions and 229 deletions.
Expand Up @@ -45,7 +45,7 @@ public CompletableFuture<?> add(DocumentReferenceProvider referenceProvider,
}

@Override
public CompletableFuture<?> update(DocumentReferenceProvider referenceProvider,
public CompletableFuture<?> addOrUpdate(DocumentReferenceProvider referenceProvider,
DocumentContributor documentContributor,
DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) {
return index( referenceProvider, documentContributor, refreshStrategy );
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void add(DocumentReferenceProvider referenceProvider,
}

@Override
public void update(DocumentReferenceProvider referenceProvider,
public void addOrUpdate(DocumentReferenceProvider referenceProvider,
DocumentContributor documentContributor) {
index( referenceProvider, documentContributor );
}
Expand Down
Expand Up @@ -58,7 +58,7 @@ public CompletableFuture<?> add(DocumentReferenceProvider referenceProvider,
}

@Override
public CompletableFuture<?> update(DocumentReferenceProvider referenceProvider,
public CompletableFuture<?> addOrUpdate(DocumentReferenceProvider referenceProvider,
DocumentContributor documentContributor,
DocumentCommitStrategy commitStrategy,
DocumentRefreshStrategy refreshStrategy) {
Expand Down
Expand Up @@ -68,7 +68,7 @@ public void add(DocumentReferenceProvider referenceProvider,
}

@Override
public void update(DocumentReferenceProvider referenceProvider,
public void addOrUpdate(DocumentReferenceProvider referenceProvider,
DocumentContributor documentContributor) {
String id = referenceProvider.identifier();
String routingKey = referenceProvider.routingKey();
Expand Down
Expand Up @@ -37,7 +37,7 @@ CompletableFuture<?> add(DocumentReferenceProvider referenceProvider, DocumentCo
* @param refreshStrategy How to handle the refresh.
* @return A {@link CompletableFuture} that completes once the document is updated.
*/
CompletableFuture<?> update(DocumentReferenceProvider referenceProvider, DocumentContributor documentContributor,
CompletableFuture<?> addOrUpdate(DocumentReferenceProvider referenceProvider, DocumentContributor documentContributor,
DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy);

/**
Expand Down
Expand Up @@ -14,7 +14,7 @@
* A set of works to be executed on a single index.
* <p>
* Works are accumulated when methods such as {@link #add(DocumentReferenceProvider, DocumentContributor)}
* or {@link #update(DocumentReferenceProvider, DocumentContributor)} are called,
* or {@link #addOrUpdate(DocumentReferenceProvider, DocumentContributor)} are called,
* and executed only when {@link #execute()} is called.
* <p>
* Relative ordering of works within a plan will be preserved.
Expand All @@ -39,7 +39,7 @@ public interface IndexIndexingPlan<R> {
* @param documentReferenceProvider A source of information about the identity of the document to update.
* @param documentContributor A contributor to the document, adding fields to the indexed document.
*/
void update(DocumentReferenceProvider documentReferenceProvider, DocumentContributor documentContributor);
void addOrUpdate(DocumentReferenceProvider documentReferenceProvider, DocumentContributor documentContributor);

/**
* Delete a document from the index.
Expand Down
Expand Up @@ -102,7 +102,7 @@ public void addUpdateDelete_noRouting() {
plan.execute().join();
clientSpy.verifyExpectationsMet();

plan.update( referenceProvider( "1" ), document -> {
plan.addOrUpdate( referenceProvider( "1" ), document -> {
document.addValue( index.binding().string, "text2" );
} );
clientSpy.expectNext(
Expand Down Expand Up @@ -156,7 +156,7 @@ public void addUpdateDelete_routing() {
plan.execute().join();
clientSpy.verifyExpectationsMet();

plan.update( referenceProvider( "1", routingKey ), document -> {
plan.addOrUpdate( referenceProvider( "1", routingKey ), document -> {
document.addValue( index.binding().string, "text2" );
} );
clientSpy.expectNext(
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void update_byTerm() throws IOException {
setup( MultiTenancyStrategyName.NONE );

IndexIndexingPlan<?> plan = index.createIndexingPlan( sessionContext );
plan.update( referenceProvider( "1" ), document -> {
plan.addOrUpdate( referenceProvider( "1" ), document -> {
DocumentElement nested = document.addObject( index.binding().nestedObject.self );
nested.addValue( index.binding().nestedObject.field2, "value" );
} );
Expand All @@ -75,7 +75,7 @@ public void update_byQuery() throws IOException {
setup( MultiTenancyStrategyName.DISCRIMINATOR );

IndexIndexingPlan<?> plan = index.createIndexingPlan( sessionContext );
plan.update( referenceProvider( "1" ), document -> {
plan.addOrUpdate( referenceProvider( "1" ), document -> {
DocumentElement nested = document.addObject( index.binding().nestedObject.self );
nested.addValue( index.binding().nestedObject.field2, "value" );
} );
Expand Down
Expand Up @@ -222,7 +222,7 @@ public void update_only_updates_elements_of_the_tenant() {
assertThatQuery( checkQuery )
.hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_ID_1, DOCUMENT_ID_2 );

plan.update( referenceProvider( DOCUMENT_ID_2 ), document -> {
plan.addOrUpdate( referenceProvider( DOCUMENT_ID_2 ), document -> {
document.addValue( index.binding().string, UPDATED_STRING );
document.addValue( index.binding().integer, INTEGER_VALUE_4 );

Expand Down Expand Up @@ -355,7 +355,7 @@ public void not_using_multi_tenancy_for_update_while_enabled_throws_exception()
assertThatThrownBy( () -> {
IndexIndexingPlan<?> plan = index.createIndexingPlan( new StubBackendSessionContext() );

plan.update( referenceProvider( DOCUMENT_ID_2 ), document -> {
plan.addOrUpdate( referenceProvider( DOCUMENT_ID_2 ), document -> {
document.addValue( index.binding().string, UPDATED_STRING );
document.addValue( index.binding().integer, INTEGER_VALUE_4 );

Expand Down
Expand Up @@ -74,7 +74,7 @@ public void using_multi_tenancy_for_add_while_disabled_throws_exception() {

assertThatThrownBy( () -> {
IndexIndexingPlan<?> plan = index.createIndexingPlan( tenant1SessionContext );
plan.update( referenceProvider( "1" ), document -> { } );
plan.addOrUpdate( referenceProvider( "1" ), document -> { } );
plan.execute().join();
} )
.isInstanceOf( SearchException.class )
Expand All @@ -90,7 +90,7 @@ public void using_multi_tenancy_for_update_while_disabled_throws_exception() {

assertThatThrownBy( () -> {
IndexIndexingPlan<?> plan = index.createIndexingPlan( tenant1SessionContext );
plan.update( referenceProvider( "1" ), document -> { } );
plan.addOrUpdate( referenceProvider( "1" ), document -> { } );
plan.execute().join();
} )
.isInstanceOf( SearchException.class )
Expand Down
Expand Up @@ -107,7 +107,7 @@ public void success() {
tasks = new CompletableFuture<?>[booksToUpdate];
for ( int i = 0; i < booksToUpdate; i++ ) {
final String id = String.valueOf( i );
tasks[i] = indexer.update(
tasks[i] = indexer.addOrUpdate(
referenceProvider( id ),
document -> document.addValue( index.binding().title, "The Boss of the Rings chap. " + id ),
commitStrategy, refreshStrategy
Expand Down Expand Up @@ -175,13 +175,13 @@ public void add_failure() {
}

@Test
public void update_failure() {
public void addOrUpdate_failure() {
IndexIndexer indexer = index.createIndexer();

// Trigger failures in the next operations
setupHelper.getBackendAccessor().ensureIndexingOperationsFail( index.name() );

CompletableFuture<?> future = indexer.update(
CompletableFuture<?> future = indexer.addOrUpdate(
referenceProvider( "1" ),
document -> document.addValue( index.binding().title, "Document #1" ),
commitStrategy, refreshStrategy
Expand Down
Expand Up @@ -99,7 +99,7 @@ public void success() {
.hasDocRefHitsAnyOrder( index.typeName(), "1", "2", "3" );

// Update
plan.update( referenceProvider( "2" ), document -> document.addValue( index.binding().title, "The Boss of the Rings chap. 2" ) );
plan.addOrUpdate( referenceProvider( "2" ), document -> document.addValue( index.binding().title, "The Boss of the Rings chap. 2" ) );
future = plan.execute();
Awaitility.await().until( future::isDone );
// The operations should succeed.
Expand Down Expand Up @@ -167,12 +167,12 @@ public void add_failure() {
}

@Test
public void update_failure() {
public void addOrUpdate_failure() {
setup();

IndexIndexingPlan<?> plan = index.createIndexingPlan( sessionContext );
plan.update( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) );
plan.update( referenceProvider( "2" ), document -> document.addValue( index.binding().title, "Title of Book 2" ) );
plan.addOrUpdate( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) );
plan.addOrUpdate( referenceProvider( "2" ), document -> document.addValue( index.binding().title, "Title of Book 2" ) );

// Trigger failures in the next operations
setupHelper.getBackendAccessor().ensureIndexingOperationsFail( index.name() );
Expand Down
Expand Up @@ -107,7 +107,7 @@ public void test() {
indexed.setText( "updated" );

backendMock.expectWorks( IndexedEntity.NAME )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.field( "text", "updated" )
.objectField( "contained", b2 -> b2
.field( "text", "initial" )
Expand All @@ -128,7 +128,7 @@ public void test() {
contained.setText( "updated" );

backendMock.expectWorks( IndexedEntity.NAME )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.field( "text", "updated" )
.objectField( "contained", b2 -> b2
.field( "text", "updated" )
Expand Down
Expand Up @@ -80,7 +80,7 @@ public void testMuffins() {
box.addMuffin( muffin );

backendMock.expectWorks( "Box" )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.field( "color", "red-and-white" )
.objectField( "muffinSet", b2 -> b2
.field( "kind", "blueberry" ) ) )
Expand All @@ -90,7 +90,7 @@ public void testMuffins() {

// Test lazy-loading a set of muffins
backendMock.expectWorks( "Box" )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.field( "color", "blue" )
.objectField( "muffinSet", b2 -> b2
.field( "kind", "blueberry" ) ) )
Expand Down Expand Up @@ -123,7 +123,7 @@ public void testDoughnuts() {
.add( "2", b -> b.field( "kind", "glazed" ) )
.processedThenExecuted();
backendMock.expectWorks( "Box" )
.update( "2", b -> b
.addOrUpdate( "2", b -> b
.field( "color", "red-and-white" )
.objectField( "doughnutSet", b2 -> b2
.field( "kind", "glazed" ) ) )
Expand All @@ -133,7 +133,7 @@ public void testDoughnuts() {

// Test lazy-loading a set of doughnuts
backendMock.expectWorks( "Box" )
.update( "2", b -> b
.addOrUpdate( "2", b -> b
.field( "color", "blue" )
.objectField( "doughnutSet", b2 -> b2
.field( "kind", "glazed" ) ) )
Expand Down
Expand Up @@ -76,7 +76,7 @@ public void directPersistUpdateDelete() {
entity1.setDirectField( "updatedValue" );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "typeBridge", b2 -> b2
.field( "directField", entity1.getDirectField() )
.objectField( "child", b3 -> b3
Expand Down Expand Up @@ -148,7 +148,7 @@ public void indirectAssociationUpdate_typeBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "typeBridge", b2 -> b2
.field( "directField", null )
.objectField( "child", b3 -> b3
Expand All @@ -174,7 +174,7 @@ public void indirectAssociationUpdate_typeBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "typeBridge", b2 -> b2
.field( "directField", null )
.objectField( "child", b3 -> b3
Expand Down Expand Up @@ -209,7 +209,7 @@ public void indirectAssociationUpdate_typeBridge() {
containingEntity1.setContainedSingle( null );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "typeBridge", b2 -> b2
.field( "directField", null )
.objectField( "child", b3 -> b3
Expand Down Expand Up @@ -277,7 +277,7 @@ public void indirectValueUpdate_typeBridge() {
containedEntity.setIncludedInTypeBridge( "updatedValue" );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "typeBridge", b2 -> b2
.field( "directField", null )
.objectField( "child", b3 -> b3
Expand Down Expand Up @@ -353,7 +353,7 @@ public void indirectAssociationUpdate_singleValuedPropertyBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "singleValuedPropertyBridge", b2 -> b2
.field( "includedInSingleValuedPropertyBridge", "initialValue" )
)
Expand All @@ -376,7 +376,7 @@ public void indirectAssociationUpdate_singleValuedPropertyBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "singleValuedPropertyBridge", b2 -> b2
.field( "includedInSingleValuedPropertyBridge", "updatedValue" )
)
Expand Down Expand Up @@ -408,7 +408,7 @@ public void indirectAssociationUpdate_singleValuedPropertyBridge() {
containingEntity1.setContainedSingle( null );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "singleValuedPropertyBridge", b2 -> b2
.field( "includedInSingleValuedPropertyBridge", null )
)
Expand Down Expand Up @@ -471,7 +471,7 @@ public void indirectValueUpdate_singleValuedPropertyBridge() {
containedEntity.setIncludedInSingleValuedPropertyBridge( "updatedValue" );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "singleValuedPropertyBridge", b2 -> b2
.field( "includedInSingleValuedPropertyBridge", "updatedValue" )
)
Expand Down Expand Up @@ -539,7 +539,7 @@ public void directAssociationUpdate_multiValuedPropertyBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "multiValuedPropertyBridge", b2 -> b2
.field( "includedInMultiValuedPropertyBridge", "value1" )
)
Expand Down Expand Up @@ -567,7 +567,7 @@ public void directAssociationUpdate_multiValuedPropertyBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "multiValuedPropertyBridge", b2 -> b2
.field( "includedInMultiValuedPropertyBridge", "value1 value2" )
)
Expand Down Expand Up @@ -599,7 +599,7 @@ public void directAssociationUpdate_multiValuedPropertyBridge() {
session.persist( containedEntity );

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "multiValuedPropertyBridge", b2 -> b2
.field( "includedInMultiValuedPropertyBridge", "updatedValue" )
)
Expand All @@ -617,7 +617,7 @@ public void directAssociationUpdate_multiValuedPropertyBridge() {
entity1.getAssociation2().clear();

backendMock.expectWorks( IndexedEntity.INDEX )
.update( "1", b -> b
.addOrUpdate( "1", b -> b
.objectField( "multiValuedPropertyBridge", b2 -> b2
.field( "includedInMultiValuedPropertyBridge", null )
)
Expand Down

0 comments on commit 5983693

Please sign in to comment.