Skip to content

Commit 7f72812

Browse files
committed
update interfaces
1 parent e1e0b0f commit 7f72812

File tree

6 files changed

+80
-10
lines changed

6 files changed

+80
-10
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#nullable enable
2+
NRedisStack.ISearchCommands.AggregateEnumerable(string! index, NRedisStack.Search.AggregationRequest! query) -> System.Collections.Generic.IEnumerable<NRedisStack.Search.Aggregation.Row>!
3+
NRedisStack.ISearchCommands.CursorDel(NRedisStack.Search.AggregationResult! result) -> bool
4+
NRedisStack.ISearchCommands.CursorRead(NRedisStack.Search.AggregationResult! result, int? count = null) -> NRedisStack.Search.AggregationResult!
5+
NRedisStack.ISearchCommandsAsync.AggregateAsyncEnumerable(string! index, NRedisStack.Search.AggregationRequest! query) -> System.Collections.Generic.IAsyncEnumerable<NRedisStack.Search.Aggregation.Row>!
6+
NRedisStack.ISearchCommandsAsync.CursorDelAsync(NRedisStack.Search.AggregationResult! result) -> System.Threading.Tasks.Task<bool>!
7+
NRedisStack.ISearchCommandsAsync.CursorReadAsync(NRedisStack.Search.AggregationResult! result, int? count = null) -> System.Threading.Tasks.Task<NRedisStack.Search.AggregationResult!>!
28
NRedisStack.SearchCommands.AggregateEnumerable(string! index, NRedisStack.Search.AggregationRequest! query) -> System.Collections.Generic.IEnumerable<NRedisStack.Search.Aggregation.Row>!
39
NRedisStack.SearchCommands.CursorDel(NRedisStack.Search.AggregationResult! result) -> bool
410
NRedisStack.SearchCommands.CursorRead(NRedisStack.Search.AggregationResult! result, int? count = null) -> NRedisStack.Search.AggregationResult!
5-
NRedisStack.SearchCommandsAsync.AggregateEnumerableAsync(string! index, NRedisStack.Search.AggregationRequest! query) -> System.Collections.Generic.IAsyncEnumerable<NRedisStack.Search.Aggregation.Row>!
11+
NRedisStack.SearchCommandsAsync.AggregateAsyncEnumerable(string! index, NRedisStack.Search.AggregationRequest! query) -> System.Collections.Generic.IAsyncEnumerable<NRedisStack.Search.Aggregation.Row>!
612
NRedisStack.SearchCommandsAsync.CursorDelAsync(NRedisStack.Search.AggregationResult! result) -> System.Threading.Tasks.Task<bool>!
713
NRedisStack.SearchCommandsAsync.CursorReadAsync(NRedisStack.Search.AggregationResult! result, int? count = null) -> System.Threading.Tasks.Task<NRedisStack.Search.AggregationResult!>!

src/NRedisStack/Search/ISearchCommands.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System.ComponentModel;
12
using NRedisStack.Search;
3+
using NRedisStack.Search.Aggregation;
24
using NRedisStack.Search.DataTypes;
35
using StackExchange.Redis;
46

@@ -18,11 +20,20 @@ public interface ISearchCommands
1820
/// Run a search query on an index, and perform aggregate transformations on the results.
1921
/// </summary>
2022
/// <param name="index">The index name.</param>
21-
/// <param name="query">The query</param>
23+
/// <param name="query">The query.</param>
2224
/// <returns>An <see langword="AggregationResult"/> object</returns>
2325
/// <remarks><seealso href="https://redis.io/commands/ft.aggregate"/></remarks>
2426
AggregationResult Aggregate(string index, AggregationRequest query);
2527

28+
/// <summary>
29+
/// Run a search query on an index, and perform aggregate transformations on the results.
30+
/// </summary>
31+
/// <param name="index">The index name.</param>
32+
/// <param name="query">The query.</param>
33+
/// <returns>A sequence of <see langword="Row"/> values.</returns>
34+
/// <remarks><seealso href="https://redis.io/commands/ft.aggregate"/></remarks>
35+
IEnumerable<Row> AggregateEnumerable(string index, AggregationRequest query);
36+
2637
/// <summary>
2738
/// Add an alias to an index.
2839
/// </summary>
@@ -92,22 +103,43 @@ public interface ISearchCommands
92103
/// <summary>
93104
/// Delete a cursor from the index.
94105
/// </summary>
95-
/// <param name="indexName">The index name</param>
106+
/// <param name="indexName">The index name.</param>
96107
/// <param name="cursorId">The cursor's ID.</param>
97108
/// <returns><see langword="true"/> if it has been deleted, <see langword="false"/> if it did not exist.</returns>
98109
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-del/"/></remarks>
110+
[Obsolete("When possible, use CursorDel(AggregationResult) instead.")]
111+
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
99112
bool CursorDel(string indexName, long cursorId);
113+
114+
/// <summary>
115+
/// Delete a cursor from the index.
116+
/// </summary>
117+
/// <param name="result">The result of a previous call to Aggregate or CursorRead.</param>
118+
/// <returns><see langword="true"/> if it has been deleted, <see langword="false"/> if it did not exist.</returns>
119+
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-del/"/></remarks>
120+
bool CursorDel(AggregationResult result);
100121

101122
/// <summary>
102123
/// Read next results from an existing cursor.
103124
/// </summary>
104-
/// <param name="indexName">The index name</param>
125+
/// <param name="indexName">The index name.</param>
105126
/// <param name="cursorId">The cursor's ID.</param>
106127
/// <param name="count">Limit the amount of returned results.</param>
107128
/// <returns>A AggregationResult object with the results</returns>
108129
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-read/"/></remarks>
130+
[Obsolete("When possible, use AggregateEnumerable or CursorRead(AggregationResult, int?) instead.")]
131+
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
109132
AggregationResult CursorRead(string indexName, long cursorId, int? count = null);
110133

134+
/// <summary>
135+
/// Read next results from an existing cursor.
136+
/// </summary>
137+
/// <param name="result">The result of a previous call to Aggregate or CursorRead.</param>
138+
/// <param name="count">Limit the amount of returned results.</param>
139+
/// <returns>A AggregationResult object with the results</returns>
140+
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-read/"/></remarks>
141+
public AggregationResult CursorRead(AggregationResult result, int? count = null);
142+
111143
/// <summary>
112144
/// Add terms to a dictionary.
113145
/// </summary>

src/NRedisStack/Search/ISearchCommandsAsync.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System.ComponentModel;
12
using NRedisStack.Search;
3+
using NRedisStack.Search.Aggregation;
24
using NRedisStack.Search.DataTypes;
35
using StackExchange.Redis;
46

@@ -22,6 +24,15 @@ public interface ISearchCommandsAsync
2224
/// <remarks><seealso href="https://redis.io/commands/ft.aggregate"/></remarks>
2325
Task<AggregationResult> AggregateAsync(string index, AggregationRequest query);
2426

27+
/// <summary>
28+
/// Run a search query on an index, and perform aggregate transformations on the results.
29+
/// </summary>
30+
/// <param name="index">The index name.</param>
31+
/// <param name="query">The query.</param>
32+
/// <returns>A sequence of <see langword="Row"/> values.</returns>
33+
/// <remarks><seealso href="https://redis.io/commands/ft.aggregate"/></remarks>
34+
IAsyncEnumerable<Row> AggregateAsyncEnumerable(string index, AggregationRequest query);
35+
2536
/// <summary>
2637
/// Add an alias to an index.
2738
/// </summary>
@@ -95,8 +106,18 @@ public interface ISearchCommandsAsync
95106
/// <param name="cursorId">The cursor's ID.</param>
96107
/// <returns><see langword="true"/> if it has been deleted, <see langword="false"/> if it did not exist.</returns>
97108
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-del/"/></remarks>
109+
[Obsolete("When possible, use CursorDelAsync(AggregationResult, int?) instead.")]
110+
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
98111
Task<bool> CursorDelAsync(string indexName, long cursorId);
99112

113+
/// <summary>
114+
/// Delete a cursor from the index.
115+
/// </summary>
116+
/// <param name="result">The result of a previous call to AggregateAsync or CursorReadAsync.</param>
117+
/// <returns><see langword="true"/> if it has been deleted, <see langword="false"/> if it did not exist.</returns>
118+
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-del/"/></remarks>
119+
Task<bool> CursorDelAsync(AggregationResult result);
120+
100121
/// <summary>
101122
/// Read next results from an existing cursor.
102123
/// </summary>
@@ -105,8 +126,19 @@ public interface ISearchCommandsAsync
105126
/// <param name="count">Limit the amount of returned results.</param>
106127
/// <returns>A AggregationResult object with the results</returns>
107128
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-read/"/></remarks>
129+
[Obsolete("When possible, use AggregateAsyncEnumerable or CursorReadAsync(AggregationResult, int?) instead.")]
130+
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
108131
Task<AggregationResult> CursorReadAsync(string indexName, long cursorId, int? count = null);
109132

133+
/// <summary>
134+
/// Read next results from an existing cursor.
135+
/// </summary>
136+
/// <param name="result">The result of a previous AggregateAsync or CursorReadAsync call.</param>
137+
/// <param name="count">Limit the amount of returned results.</param>
138+
/// <returns>A AggregationResult object with the results</returns>
139+
/// <remarks><seealso href="https://redis.io/commands/ft.cursor-read/"/></remarks>
140+
Task<AggregationResult> CursorReadAsync(AggregationResult result, int? count = null);
141+
110142
/// <summary>
111143
/// Add terms to a dictionary.
112144
/// </summary>

src/NRedisStack/Search/SearchCommands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public bool Create(string indexName, Schema schema)
120120
}
121121

122122
/// <inheritdoc/>
123-
[Obsolete("When possible, use CursorDelAsync(AggregationResult, int?) instead.")]
123+
[Obsolete("When possible, use CursorDel(AggregationResult) instead.")]
124124
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
125125
public bool CursorDel(string indexName, long cursorId)
126126
{
@@ -144,7 +144,7 @@ public bool CursorDel(AggregationResult result)
144144
}
145145

146146
/// <inheritdoc/>
147-
[Obsolete("When possible, use CursorReadAsync(AggregationResult, int?) instead.")]
147+
[Obsolete("When possible, use CusorReadEnumerable or CursorRead(AggregationResult, int?) instead.")]
148148
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
149149
public AggregationResult CursorRead(string indexName, long cursorId, int? count = null)
150150
{

src/NRedisStack/Search/SearchCommandsAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async Task<AggregationResult> AggregateAsync(string index, AggregationReq
8383
return result.ToAggregationResult(index, query, server, database);
8484
}
8585

86-
public async IAsyncEnumerable<Row> AggregateEnumerableAsync(string index, AggregationRequest query)
86+
public async IAsyncEnumerable<Row> AggregateAsyncEnumerable(string index, AggregationRequest query)
8787
{
8888
if (!query.IsWithCursor()) query.Cursor();
8989

@@ -185,7 +185,7 @@ public async Task<bool> CursorDelAsync(AggregationResult result)
185185
}
186186

187187
/// <inheritdoc/>
188-
[Obsolete("When possible, use CursorReadAsync(AggregationResult, int?) instead.")]
188+
[Obsolete("When possible, use AggregateAsyncEnumerable or CursorReadAsync(AggregationResult, int?) instead.")]
189189
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
190190
public async Task<AggregationResult> CursorReadAsync(string indexName, long cursorId, int? count = null)
191191
{

tests/NRedisStack.Tests/Search/SearchTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ public async Task TestCursorAsync(string endpointId)
12051205
.Cursor(1, 3000);
12061206

12071207
// actual search
1208-
AggregationResult res = ft.Aggregate(index, r);
1208+
AggregationResult res = await ft.AggregateAsync(index, r);
12091209
Row? row = res.GetRow(0);
12101210
Assert.NotNull(row);
12111211
Assert.Equal("def", row.Value.GetString("name"));
@@ -1259,7 +1259,7 @@ public async Task TestCursorEnumerableAsync(string endpointId)
12591259
.Cursor(1, 3000);
12601260

12611261
// actual search
1262-
await using var iter = ft.AggregateEnumerableAsync(index, r).GetAsyncEnumerator();
1262+
await using var iter = ft.AggregateAsyncEnumerable(index, r).GetAsyncEnumerator();
12631263
Assert.True(await iter.MoveNextAsync());
12641264
var row = iter.Current;
12651265
Assert.Equal("def", row.GetString("name"));

0 commit comments

Comments
 (0)