forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Latest PagedFlux Changes from Azure Core (Azure#8303)
* Update PagedFlux usage to use new changes from Azure Core * Use custom PagedFlux implementation in Azure Search to support pages with additional metadata * Updated PagedFlux usage in Azure Search to allow search to use its non-String continuation token * Update paging to new guidelines * Fixed sample and test code * Added missing documentation * Remove unused dependency * Add logic to handle when Azure Resource Group isn't set * Changes based on PR feedback * Moved PagedResponse classes into util * Fix constructor scoping issue
- Loading branch information
1 parent
feb5efd
commit 2c9db7f
Showing
30 changed files
with
695 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
sdk/search/azure-search/src/main/java/com/azure/search/AutocompletePagedResponse.java
This file was deleted.
Oops, something went wrong.
228 changes: 83 additions & 145 deletions
228
sdk/search/azure-search/src/main/java/com/azure/search/SearchIndexAsyncClient.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sdk/search/azure-search/src/main/java/com/azure/search/util/AutocompletePagedFlux.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.search.util; | ||
|
||
import com.azure.core.http.rest.PagedFluxBase; | ||
import com.azure.search.models.AutocompleteItem; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Implementation of {@link PagedFluxBase} where the element type is {@link AutocompleteItem} and the page type is | ||
* {@link AutocompletePagedResponse}. | ||
*/ | ||
public final class AutocompletePagedFlux extends PagedFluxBase<AutocompleteItem, AutocompletePagedResponse> { | ||
/** | ||
* Creates an instance of {@link AutocompletePagedFlux} that retrieves a single page. | ||
* | ||
* @param firstPageRetriever Supplier that handles retrieving the first page. | ||
*/ | ||
public AutocompletePagedFlux(Supplier<Mono<AutocompletePagedResponse>> firstPageRetriever) { | ||
super(firstPageRetriever); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
sdk/search/azure-search/src/main/java/com/azure/search/util/AutocompletePagedIterable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.search.util; | ||
|
||
import com.azure.core.http.rest.PagedIterableBase; | ||
import com.azure.search.models.AutocompleteItem; | ||
|
||
/** | ||
* Implementation of {@link PagedIterableBase} where the element type is {@link AutocompleteItem} and the page type is | ||
* {@link AutocompletePagedResponse}. | ||
*/ | ||
public final class AutocompletePagedIterable extends PagedIterableBase<AutocompleteItem, AutocompletePagedResponse> { | ||
/** | ||
* Creates instance given {@link AutocompletePagedIterable}. | ||
* | ||
* @param pagedFluxBase The {@link AutocompletePagedFlux} that will be consumed as an iterable. | ||
*/ | ||
public AutocompletePagedIterable(AutocompletePagedFlux pagedFluxBase) { | ||
super(pagedFluxBase); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
sdk/search/azure-search/src/main/java/com/azure/search/util/AutocompletePagedResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.search.util; | ||
|
||
import com.azure.core.annotation.Immutable; | ||
import com.azure.core.http.rest.PagedResponseBase; | ||
import com.azure.core.http.rest.Response; | ||
import com.azure.core.http.rest.SimpleResponse; | ||
import com.azure.search.models.AutocompleteItem; | ||
import com.azure.search.models.AutocompleteResult; | ||
|
||
/** | ||
* This class represents a response from the autocomplete API. It contains the {@link AutocompleteItem | ||
* AutocompleteItems} returned from the service. | ||
*/ | ||
@Immutable | ||
public final class AutocompletePagedResponse extends PagedResponseBase<Void, AutocompleteItem> { | ||
private final Double coverage; | ||
|
||
/** | ||
* Creates an {@link AutocompletePagedResponse} from the returned {@link Response}. | ||
* | ||
* @param autocompleteResponse Autocomplete response returned from the service. | ||
*/ | ||
public AutocompletePagedResponse(SimpleResponse<AutocompleteResult> autocompleteResponse) { | ||
super(autocompleteResponse.getRequest(), | ||
autocompleteResponse.getStatusCode(), | ||
autocompleteResponse.getHeaders(), | ||
autocompleteResponse.getValue().getResults(), | ||
null, | ||
null); | ||
|
||
this.coverage = autocompleteResponse.getValue().getCoverage(); | ||
} | ||
|
||
/** | ||
* The percentage of the index covered in the autocomplete request. | ||
* <p> | ||
* If {@code minimumCoverage} wasn't supplied in the request this will be {@code null}. | ||
* | ||
* @return The percentage of the index covered in the suggest request if {@code minimumCoverage} was set in the | ||
* request, otherwise {@code null}. | ||
*/ | ||
public Double getCoverage() { | ||
return coverage; | ||
} | ||
} |
Oops, something went wrong.