Skip to content

Commit

Permalink
Merge branch 'main' into feat/dio-http-client-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse authored Jul 8, 2024
2 parents 1f29a6a + 07266f2 commit 08a9144
Show file tree
Hide file tree
Showing 115 changed files with 1,949 additions and 823 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,18 @@ public async Task<ReplaceAllObjectsResponse> ReplaceAllObjectsAsync<T>(string in

var copyResponse = await OperationIndexAsync(indexName,
new OperationIndexParams(OperationType.Copy, tmpIndexName)
{ Scope = [ScopeType.Rules, ScopeType.Settings, ScopeType.Synonyms] }, options, cancellationToken)
{ Scope = [ScopeType.Settings, ScopeType.Rules, ScopeType.Synonyms] }, options, cancellationToken)
.ConfigureAwait(false);

var batchResponse = await ChunkedBatchAsync(tmpIndexName, objects, Action.AddObject, batchSize,
var batchResponse = await ChunkedBatchAsync(tmpIndexName, objects, Action.AddObject, true, batchSize,
options, cancellationToken).ConfigureAwait(false);

await WaitForTaskAsync(tmpIndexName, copyResponse.TaskID, requestOptions: options, ct: cancellationToken)
.ConfigureAwait(false);

copyResponse = await OperationIndexAsync(indexName,
new OperationIndexParams(OperationType.Copy, tmpIndexName)
{ Scope = [ScopeType.Rules, ScopeType.Settings, ScopeType.Synonyms] }, options, cancellationToken)
{ Scope = [ScopeType.Settings, ScopeType.Rules, ScopeType.Synonyms] }, options, cancellationToken)
.ConfigureAwait(false);
await WaitForTaskAsync(tmpIndexName, copyResponse.TaskID, requestOptions: options, ct: cancellationToken)
.ConfigureAwait(false);
Expand Down Expand Up @@ -487,9 +487,9 @@ await WaitForTaskAsync(tmpIndexName, moveResponse.TaskID, requestOptions: option
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <typeparam name="T"></typeparam>
public List<BatchResponse> ChunkedBatch<T>(string indexName, IEnumerable<T> objects, Action action = Action.AddObject,
int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default)
bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null, CancellationToken cancellationToken = default)
where T : class =>
AsyncHelper.RunSync(() => ChunkedBatchAsync(indexName, objects, action, batchSize, options, cancellationToken));
AsyncHelper.RunSync(() => ChunkedBatchAsync(indexName, objects, action, waitForTasks, batchSize, options, cancellationToken));

/// <summary>
/// Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
Expand All @@ -502,7 +502,7 @@ public List<BatchResponse> ChunkedBatch<T>(string indexName, IEnumerable<T> obje
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <typeparam name="T"></typeparam>
public async Task<List<BatchResponse>> ChunkedBatchAsync<T>(string indexName, IEnumerable<T> objects,
Action action = Action.AddObject, int batchSize = 1000, RequestOptions options = null,
Action action = Action.AddObject, bool waitForTasks = false, int batchSize = 1000, RequestOptions options = null,
CancellationToken cancellationToken = default) where T : class
{
var batchCount = (int)Math.Ceiling((double)objects.Count() / batchSize);
Expand All @@ -518,10 +518,13 @@ public async Task<List<BatchResponse>> ChunkedBatchAsync<T>(string indexName, IE
responses.Add(batchResponse);
}

foreach (var batch in responses)
if (waitForTasks)
{
await WaitForTaskAsync(indexName, batch.TaskID, requestOptions: options, ct: cancellationToken)
.ConfigureAwait(false);
foreach (var batch in responses)
{
await WaitForTaskAsync(indexName, batch.TaskID, requestOptions: options, ct: cancellationToken)
.ConfigureAwait(false);
}
}

return responses;
Expand All @@ -544,7 +547,7 @@ public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEn
RequestOptions options = null,
CancellationToken cancellationToken = default) where T : class
{
return await ChunkedBatchAsync(indexName, objects, Action.AddObject, 1000, options, cancellationToken).ConfigureAwait(false);
return await ChunkedBatchAsync(indexName, objects, Action.AddObject, false, 1000, options, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -554,11 +557,11 @@ public async Task<List<BatchResponse>> SaveObjectsAsync<T>(string indexName, IEn
/// <param name="objectIDs">The list of `objectIDs` to remove from the given Algolia `indexName`.</param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
public async Task<List<BatchResponse>> DeleteObjects(string indexName, IEnumerable<String> objectIDs,
public async Task<List<BatchResponse>> DeleteObjectsAsync(string indexName, IEnumerable<String> objectIDs,
RequestOptions options = null,
CancellationToken cancellationToken = default)
{
return await ChunkedBatchAsync(indexName, objectIDs.Select(id => new { objectID = id }), Action.DeleteObject, 1000, options, cancellationToken).ConfigureAwait(false);
return await ChunkedBatchAsync(indexName, objectIDs.Select(id => new { objectID = id }), Action.DeleteObject, false, 1000, options, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -569,11 +572,11 @@ public async Task<List<BatchResponse>> DeleteObjects(string indexName, IEnumerab
/// <param name="createIfNotExists">To be provided if non-existing objects are passed, otherwise, the call will fail.</param>
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
public async Task<List<BatchResponse>> PartialUpdateObjects<T>(string indexName, IEnumerable<T> objects, bool createIfNotExists,
public async Task<List<BatchResponse>> PartialUpdateObjectsAsync<T>(string indexName, IEnumerable<T> objects, bool createIfNotExists,
RequestOptions options = null,
CancellationToken cancellationToken = default) where T : class
{
return await ChunkedBatchAsync(indexName, objects, createIfNotExists ? Action.PartialUpdateObject : Action.PartialUpdateObjectNoCreate, 1000, options, cancellationToken).ConfigureAwait(false);
return await ChunkedBatchAsync(indexName, objects, createIfNotExists ? Action.PartialUpdateObject : Action.PartialUpdateObjectNoCreate, false, 1000, options, cancellationToken).ConfigureAwait(false);
}

private static async Task<List<TU>> CreateIterable<TU>(Func<TU, Task<TU>> executeQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ final class BrowseParamsObject {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
cursor.hashCode;

factory BrowseParamsObject.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ final class ConsequenceParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
query.hashCode +
automaticFacetFilters.hashCode +
automaticOptionalFacetFilters.hashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class FallbackParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory FallbackParams.fromJson(Map<String, dynamic> json) =>
_$FallbackParamsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ final class IndexSettings {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory IndexSettings.fromJson(Map<String, dynamic> json) =>
_$IndexSettingsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ final class SearchForFacets {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
facet.hashCode +
indexName.hashCode +
facetQuery.hashCode +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ final class SearchForHits {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
indexName.hashCode +
type.hashCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class SearchParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory SearchParams.fromJson(Map<String, dynamic> json) =>
_$SearchParamsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class SearchParamsObject {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory SearchParamsObject.fromJson(Map<String, dynamic> json) =>
_$SearchParamsObjectFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class FallbackParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory FallbackParams.fromJson(Map<String, dynamic> json) =>
_$FallbackParamsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class SearchParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory SearchParams.fromJson(Map<String, dynamic> json) =>
_$SearchParamsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class SearchParamsObject {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory SearchParamsObject.fromJson(Map<String, dynamic> json) =>
_$SearchParamsObjectFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ final class BrowseParamsObject {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
cursor.hashCode;

factory BrowseParamsObject.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ final class ConsequenceParams {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
query.hashCode +
automaticFacetFilters.hashCode +
automaticOptionalFacetFilters.hashCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ final class IndexSettings {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory IndexSettings.fromJson(Map<String, dynamic> json) =>
_$IndexSettingsFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ final class SearchForFacets {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
facet.hashCode +
indexName.hashCode +
facetQuery.hashCode +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ final class SearchForHits {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode) +
reRankingApplyFilter.hashCode +
indexName.hashCode +
type.hashCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class SearchParamsObject {
attributeCriteriaComputedByMinProximity.hashCode +
renderingContent.hashCode +
enableReRanking.hashCode +
(reRankingApplyFilter == null ? 0 : reRankingApplyFilter.hashCode);
reRankingApplyFilter.hashCode;

factory SearchParamsObject.fromJson(Map<String, dynamic> json) =>
_$SearchParamsObjectFromJson(json);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 08a9144

Please sign in to comment.