Skip to content

Commit

Permalink
Rename stop to end in sorted set query. (#2214)
Browse files Browse the repository at this point in the history
* Rename `stop` to `end` in sorted set query.

Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand authored Sep 9, 2024
1 parent 7d0ddf5 commit c8c5b83
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 173 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#### Changes
* Node, Python: Rename `stop` to `end` in sorted set queries ([#2214](https://github.com/valkey-io/valkey-glide/pull/2214))
* Node: Added binary variant to sorted set commands - part 1 ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190))
* Node: Added binary variant to HSCAN command ([#2240](https://github.com/valkey-io/valkey-glide/pull/2240))
* Node: replace decoder by DecoderOption and route by RouteOption in API([#2234](https://github.com/valkey-io/valkey-glide/pull/2234/))
* Node: Added binary variant to sorted set commands ([#2190](https://github.com/valkey-io/valkey-glide/pull/2190), [#2210](https://github.com/valkey-io/valkey-glide/pull/2210))
Expand Down
22 changes: 11 additions & 11 deletions node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3934,7 +3934,7 @@ export class BaseClient {
* const result1 = await client.zdiffstore("zset3", ["zset1", "zset2"]);
* console.log(result1); // Output: 1 - One member exists in "key1" but not "key2", and this member was stored in "zset3".
*
* const result2 = await client.zrange("zset3", {start: 0, stop: -1});
* const result2 = await client.zrange("zset3", {start: 0, end: -1});
* console.log(result2); // Output: ["member2"] - "member2" is now stored in "my_sorted_set".
* ```
*/
Expand Down Expand Up @@ -4117,7 +4117,7 @@ export class BaseClient {
* @example
* ```typescript
* // Example usage of zrange method to retrieve all members of a sorted set in ascending order
* const result = await client.zrange("my_sorted_set", { start: 0, stop: -1 });
* const result = await client.zrange("my_sorted_set", { start: 0, end: -1 });
* console.log(result1); // Output: all members in ascending order
* // ['member1', 'member2', 'member3']
* ```
Expand All @@ -4126,7 +4126,7 @@ export class BaseClient {
* // Example usage of zrange method to retrieve members within a score range in descending order
* const result = await client.zrange("my_sorted_set", {
* start: InfBoundary.NegativeInfinity,
* stop: { value: 3, isInclusive: false },
* end: { value: 3, isInclusive: false },
* type: "byScore",
* }, { reverse: true });
* console.log(result); // Output: members with scores within the range of negative infinity to 3, in descending order
Expand Down Expand Up @@ -4166,7 +4166,7 @@ export class BaseClient {
* // Example usage of zrangeWithScores method to retrieve members within a score range with their scores
* const result = await client.zrangeWithScores("my_sorted_set", {
* start: { value: 10, isInclusive: false },
* stop: { value: 20, isInclusive: false },
* end: { value: 20, isInclusive: false },
* type: "byScore",
* });
* console.log(result); // Output: members with scores between 10 and 20 with their scores
Expand All @@ -4177,7 +4177,7 @@ export class BaseClient {
* // Example usage of zrangeWithScores method to retrieve members within a score range with their scores
* const result = await client.zrangeWithScores("my_sorted_set", {
* start: InfBoundary.NegativeInfinity,
* stop: { value: 3, isInclusive: false },
* end: { value: 3, isInclusive: false },
* type: "byScore",
* }, { reverse: true });
* console.log(result); // Output: members with scores within the range of negative infinity to 3, with their scores in descending order
Expand Down Expand Up @@ -4216,15 +4216,15 @@ export class BaseClient {
* @example
* ```typescript
* // Example usage of zrangeStore to retrieve and store all members of a sorted set in ascending order.
* const result = await client.zrangeStore("destination_key", "my_sorted_set", { start: 0, stop: -1 });
* const result = await client.zrangeStore("destination_key", "my_sorted_set", { start: 0, end: -1 });
* console.log(result); // Output: 7 - "destination_key" contains a sorted set with the 7 members from "my_sorted_set".
* ```
* @example
* ```typescript
* // Example usage of zrangeStore method to retrieve members within a score range in ascending order and store in "destination_key"
* const result = await client.zrangeStore("destination_key", "my_sorted_set", {
* start: InfBoundary.NegativeInfinity,
* stop: { value: 3, isInclusive: false },
* end: { value: 3, isInclusive: false },
* type: "byScore",
* });
* console.log(result); // Output: 5 - Stores 5 members with scores within the range of negative infinity to 3, in ascending order, in "destination_key".
Expand Down Expand Up @@ -4265,13 +4265,13 @@ export class BaseClient {
* // use `zinterstore` with default aggregation and weights
* console.log(await client.zinterstore("my_sorted_set", ["key1", "key2"]))
* // Output: 1 - Indicates that the sorted set "my_sorted_set" contains one element.
* console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, stop: -1}))
* console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, end: -1}))
* // Output: {'member1': 20} - "member1" is now stored in "my_sorted_set" with score of 20.
*
* // use `zinterstore` with default weights
* console.log(await client.zinterstore("my_sorted_set", ["key1", "key2"] , AggregationType.MAX))
* // Output: 1 - Indicates that the sorted set "my_sorted_set" contains one element, and it's score is the maximum score between the sets.
* console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, stop: -1}))
* console.log(await client.zrangeWithScores("my_sorted_set", {start: 0, end: -1}))
* // Output: {'member1': 10.5} - "member1" is now stored in "my_sorted_set" with score of 10.5.
* ```
*/
Expand Down Expand Up @@ -6345,7 +6345,7 @@ export class BaseClient {
* // search for locations within 200 km circle around stored member named 'Palermo' and store in `destination`:
* await client.geosearchstore("destination", "mySortedSet", { member: "Palermo" }, { radius: 200, unit: GeoUnit.KILOMETERS });
* // query the stored results
* const result1 = await client.zrangeWithScores("destination", { start: 0, stop: -1 });
* const result1 = await client.zrangeWithScores("destination", { start: 0, end: -1 });
* console.log(result1); // Output:
* // {
* // Palermo: 3479099956230698, // geohash of the location is stored as element's score
Expand All @@ -6366,7 +6366,7 @@ export class BaseClient {
* },
* );
* // query the stored results
* const result2 = await client.zrangeWithScores("destination", { start: 0, stop: -1 });
* const result2 = await client.zrangeWithScores("destination", { start: 0, end: -1 });
* console.log(result2); // Output:
* // {
* // Palermo: 190.4424, // distance from the search area center is stored as element's score
Expand Down
22 changes: 11 additions & 11 deletions node/src/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1671,32 +1671,32 @@ export type Boundary<T> =

/**
* Represents a range by index (rank) in a sorted set.
* The `start` and `stop` arguments represent zero-based indexes.
* The `start` and `end` arguments represent zero-based indexes.
*/
export type RangeByIndex = {
/**
* The start index of the range.
*/
start: number;
/**
* The stop index of the range.
* The end index of the range.
*/
stop: number;
end: number;
};

/**
* Represents a range by score or a range by lex in a sorted set.
* The `start` and `stop` arguments represent score boundaries.
* The `start` and `end` arguments represent score boundaries.
*/
type SortedSetRange<T> = {
/**
* The start boundary.
*/
start: Boundary<T>;
/**
* The stop boundary.
* The end boundary.
*/
stop: Boundary<T>;
end: Boundary<T>;
/**
* The limit argument for a range query.
* Represents a limit argument for a range query in a sorted set to
Expand Down Expand Up @@ -1781,19 +1781,19 @@ function createZRangeArgs(
if (rangeQuery.type == "byLex") {
args.push(
getLexBoundaryArg(rangeQuery.start),
getLexBoundaryArg(rangeQuery.stop),
getLexBoundaryArg(rangeQuery.end),
"BYLEX",
);
} else {
args.push(
getScoreBoundaryArg(rangeQuery.start),
getScoreBoundaryArg(rangeQuery.stop),
getScoreBoundaryArg(rangeQuery.end),
"BYSCORE",
);
}
} else {
args.push(rangeQuery.start.toString());
args.push(rangeQuery.stop.toString());
args.push(rangeQuery.end.toString());
}

if (reverse) {
Expand Down Expand Up @@ -1963,12 +1963,12 @@ export function createPTTL(key: GlideString): command_request.Command {
export function createZRemRangeByRank(
key: GlideString,
start: number,
stop: number,
end: number,
): command_request.Command {
return createCommand(RequestType.ZRemRangeByRank, [
key,
start.toString(),
stop.toString(),
end.toString(),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion node/tests/GlideClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe("GlideClusterClient", () => {
{ member: "_" },
{ radius: 5, unit: GeoUnit.METERS },
),
client.zrangeStore("abc", "zyx", { start: 0, stop: -1 }),
client.zrangeStore("abc", "zyx", { start: 0, end: -1 }),
client.zinter(["abc", "zxy", "lkn"]),
client.zinterWithScores(["abc", "zxy", "lkn"]),
client.zunion(["abc", "zxy", "lkn"]),
Expand Down
Loading

0 comments on commit c8c5b83

Please sign in to comment.