From 6335548dbaf011883104b7c437babcf74f124a0b Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Thu, 15 Aug 2024 13:49:38 -0700 Subject: [PATCH] Java & Node: Update docs for `LCS`. (#2087) Update docs. Signed-off-by: Yury-Fridlyand --- .../api/commands/StringBaseCommands.java | 452 +++++++++--------- .../glide/api/models/BaseTransaction.java | 165 ++----- node/src/BaseClient.ts | 6 +- node/src/Transaction.ts | 2 + 4 files changed, 276 insertions(+), 349 deletions(-) diff --git a/java/client/src/main/java/glide/api/commands/StringBaseCommands.java b/java/client/src/main/java/glide/api/commands/StringBaseCommands.java index 38f6c50117..3f46f6a2cb 100644 --- a/java/client/src/main/java/glide/api/commands/StringBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/StringBaseCommands.java @@ -672,8 +672,8 @@ public interface StringBaseCommands { CompletableFuture append(GlideString key, GlideString value); /** - * Returns the longest common subsequence between strings stored at key1 and - * key2. + * Returns all the longest common subsequences combined between strings stored at key1 + * and key2. * * @since Valkey 7.0 and above. * @apiNote When in cluster mode, key1 and key2 must map to the same @@ -681,9 +681,9 @@ public interface StringBaseCommands { * @see valkey.io for details. * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. - * @return A String containing the longest common subsequence between the 2 strings. - * An empty String is returned if the keys do not exist or have no common - * subsequences. + * @return A String containing all the longest common subsequences combined between + * the 2 strings. An empty String is returned if the keys do not exist or have no + * common subsequences. * @example *
{@code
      * // testKey1 = abcd, testKey2 = axcd
@@ -694,8 +694,8 @@ public interface StringBaseCommands {
     CompletableFuture lcs(String key1, String key2);
 
     /**
-     * Returns the longest common subsequence between strings stored at key1 and 
-     * key2.
+     * Returns all the longest common subsequences combined between strings stored at key1
+     *  and key2.
      *
      * @since Valkey 7.0 and above.
      * @apiNote When in cluster mode, key1 and key2 must map to the same
@@ -703,9 +703,9 @@ public interface StringBaseCommands {
      * @see valkey.io for details.
      * @param key1 The key that stores the first string.
      * @param key2 The key that stores the second string.
-     * @return A String containing the longest common subsequence between the 2 strings.
-     *     An empty String is returned if the keys do not exist or have no common
-     *     subsequences.
+     * @return A String containing all the longest common subsequences combined between
+     *     the 2 strings. An empty GlideString is returned if the keys do not exist or
+     *     have no common subsequences.
      * @example
      *     
{@code
      * // testKey1 = abcd, testKey2 = axcd
@@ -716,8 +716,8 @@ public interface StringBaseCommands {
     CompletableFuture lcs(GlideString key1, GlideString key2);
 
     /**
-     * Returns the length of the longest common subsequence between strings stored at key1
-     *  and key2.
+     * Returns the total length of all the longest common subsequences between strings stored at
+     * key1 and key2.
      *
      * @since Valkey 7.0 and above.
      * @apiNote When in cluster mode, key1 and key2 must map to the same
@@ -725,7 +725,7 @@ public interface StringBaseCommands {
      * @see valkey.io for details.
      * @param key1 The key that stores the first string.
      * @param key2 The key that stores the second string.
-     * @return The length of the longest common subsequence between the 2 strings.
+     * @return The total length of all the longest common subsequences the 2 strings.
      * @example
      *     
{@code
      * // testKey1 = abcd, testKey2 = axcd
@@ -736,8 +736,8 @@ public interface StringBaseCommands {
     CompletableFuture lcsLen(String key1, String key2);
 
     /**
-     * Returns the length of the longest common subsequence between strings stored at key1
-     *  and key2.
+     * Returns the total length of all the longest common subsequences between strings stored at
+     * key1 and key2.
      *
      * @since Valkey 7.0 and above.
      * @apiNote When in cluster mode, key1 and key2 must map to the same
@@ -756,8 +756,8 @@ public interface StringBaseCommands {
     CompletableFuture lcsLen(GlideString key1, GlideString key2);
 
     /**
-     * Returns the indices and length of the longest common subsequence between strings stored at
-     * key1 and key2.
+     * Returns the indices and the total length of all the longest common subsequences between strings
+     * stored at key1 and key2.
      *
      * @since Valkey 7.0 and above.
      * @apiNote When in cluster mode, key1 and key2 must map to the same
@@ -766,41 +766,41 @@ public interface StringBaseCommands {
      * @param key1 The key that stores the first string.
      * @param key2 The key that stores the second string.
      * @return A Map containing the indices of the longest common subsequence between the
-     *     2 strings and the length of the longest common subsequence. The resulting map contains two
-     *     keys, "matches" and "len":
+     *     2 strings and the total length of all the longest common subsequences. The resulting map
+     *     contains two keys, "matches" and "len":
      *     
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the string "abcd123" and key2 - * holds the string "bcdef123" then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Long[][][] {
-     *      {
-     *          {4L, 6L},
-     *          {5L, 7L}
-     *      },
-     *      {
-     *          {1L, 3L},
-     *          {0L, 2L}
-     *      }
-     *  }
+     * client.mset(Map.of("key1", "abcd123", "key2", "bcdef123")).get();
+     * Map response = client.lcsIdx("key1", "key2").get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Long[][][] {
+     *         {                         // the first substring match is `"123"`
+     *             {4L, 6L},             // in `"key1"` it is located between indices `4` and `6`
+     *             {5L, 7L}              // and in `"key2"` - in between `5` and `7`
+     *         },
+     *         {                         // second substring match is `"bcd"`
+     *             {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
+     *             {0L, 2L}              // and in `"key2"` - in between `0` and `2`
+     *         }
+     *     },
+     *     "len", 6                      // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is "123" in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * "bcd" in key1 at index 1 to 3 which matches - * the substring in key2 at index 0 to 2. */ CompletableFuture> lcsIdx(String key1, String key2); /** - * Returns the indices and length of the longest common subsequence between strings stored at - * key1 and key2. + * Returns the indices and the total length of all the longest common subsequences between strings + * stored at key1 and key2. * * @since Valkey 7.0 and above. * @apiNote When in cluster mode, key1 and key2 must map to the same @@ -809,41 +809,41 @@ public interface StringBaseCommands { * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the total length of all the longest common subsequences. The resulting map + * contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the GlideString gs("abcd123") and key2 - * holds the GlideString gs("bcdef123") then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Long[][][] {
-     *      {
-     *          {4L, 6L},
-     *          {5L, 7L}
-     *      },
-     *      {
-     *          {1L, 3L},
-     *          {0L, 2L}
-     *      }
-     *  }
+     * client.mset(Map.of(gs("key1"), gs("abcd123"), gs("key2"), gs("bcdef123"))).get();
+     * Map response = client.lcsIdx(gs("key1"), gs("key2")).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Long[][][] {
+     *         {                         // the first substring match is `gs("123")`
+     *             {4L, 6L},             // in `gs("key1")` it is located between indices `4` and `6`
+     *             {5L, 7L}              // and in `gs("key2")` - in between `5` and `7`
+     *         },
+     *         {                         // second substring match is `gs("bcd")`
+     *             {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
+     *             {0L, 2L}              // and in `gs("key2")` - in between `0` and `2`
+     *         }
+     *     },
+     *     "len", 6                      // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is gs("123") in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * gs("bcd") in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2. */ CompletableFuture> lcsIdx(GlideString key1, GlideString key2); /** - * Returns the indices and length of the longest common subsequence between strings stored at - * key1 and key2. + * Returns the indices and the total length of all the longest common subsequences between strings + * stored at key1 and key2. * * @since Valkey 7.0 and above. * @apiNote When in cluster mode, key1 and key2 must map to the same @@ -853,41 +853,42 @@ public interface StringBaseCommands { * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the total length of all the longest common subsequences. The resulting map + * contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. This value doesn't count towards the + * minMatchLen filter. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the string "abcd123" and key2 - * holds the string "bcdef123" then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Long[][][] {
-     *      {
-     *          {4L, 6L},
-     *          {5L, 7L}
-     *      },
-     *      {
-     *          {1L, 3L},
-     *          {0L, 2L}
-     *      }
-     *  }
+     * client.mset(Map.of("key1", "abcd123", "key2", "bcdef123")).get();
+     * Map response = client.lcsIdx("key1", "key2", 2).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Long[][][] {
+     *         {                         // the first substring match is `"123"`
+     *             {4L, 6L},             // in `"key1"` it is located between indices `4` and `6`
+     *             {5L, 7L}              // and in `"key2"` - in between `5` and `7`
+     *         },
+     *         {                         // second substring match is `"bcd"`
+     *             {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
+     *             {0L, 2L}              // and in `"key2"` - in between `0` and `2`
+     *         }
+     *     },
+     *     "len", 6                      // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is "123" in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * "bcd" in key1 at index 1 to 3 which matches - * the substring in key2 at index 0 to 2. */ CompletableFuture> lcsIdx(String key1, String key2, long minMatchLen); /** - * Returns the indices and length of the longest common subsequence between strings stored at - * key1 and key2. + * Returns the indices and the total length of all the longest common subsequences between strings + * stored at key1 and key2. * * @since Valkey 7.0 and above. * @apiNote When in cluster mode, key1 and key2 must map to the same @@ -897,41 +898,42 @@ public interface StringBaseCommands { * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the total length of all the longest common subsequences. The resulting map + * contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. This value doesn't count towards the + * minMatchLen filter. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the GlideString gs("abcd123") and key2 - * holds the GlideString gs("bcdef123") then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Long[][][] {
-     *      {
-     *          {4L, 6L},
-     *          {5L, 7L}
-     *      },
-     *      {
-     *          {1L, 3L},
-     *          {0L, 2L}
-     *      }
-     *  }
+     * client.mset(Map.of(gs("key1"), gs("abcd123"), gs("key2"), gs("bcdef123"))).get();
+     * Map response = client.lcsIdx(gs("key1"), gs("key2"), 2).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Long[][][] {
+     *         {                         // the first substring match is `gs("123")`
+     *             {4L, 6L},             // in `gs("key1")` it is located between indices `4` and `6`
+     *             {5L, 7L}              // and in `gs("key2")` - in between `5` and `7`
+     *         },
+     *         {                         // second substring match is `gs("bcd")`
+     *             {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
+     *             {0L, 2L}              // and in `gs("key2")` - in between `0` and `2`
+     *         }
+     *     },
+     *     "len", 6                      // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is gs("123") in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * gs("bcd") in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2. */ CompletableFuture> lcsIdx( GlideString key1, GlideString key2, long minMatchLen); /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -941,42 +943,42 @@ CompletableFuture> lcsIdx( * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the lengths of the longest common subsequences. The resulting map contains + * two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the string "abcd1234" and key2 - * holds the string "bcdef1234" then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Object[] {
-     *      new Object[] {
-     *          new Long[] {4L, 7L},
-     *          new Long[] {5L, 8L},
-     *          4L},
-     *      new Object[] {
-     *          new Long[] {1L, 3L},
-     *          new Long[] {0L, 2L},
-     *          3L}
-     *      }
+     * client.mset(Map.of("key1", "abcd1234", "key2", "bcdef1234")).get();
+     * Map response = client.lcsIdxWithMatchLen("key1", "key2").get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Object[][] {
+     *         {                                    // the first substring match is `"1234"`
+     *             new Long[] {4L, 7L},             // in `"key1"` it is located between indices `4` and `7`
+     *             new Long[] {5L, 8L},             // and in `"key2"` - in between `5` and `8`
+     *             4L                               // the match length
+     *         },
+     *         {                                    // second substring match is `"bcd"`
+     *             new Long[] {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
+     *             new Long[] {0L, 2L},             // and in `"key2"` - in between `0` and `2`
+     *             3L                               // the match length
+     *         }
+     *     },
+     *     "len", 6                                 // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is "1234" in key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * "bcd" in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. */ CompletableFuture> lcsIdxWithMatchLen(String key1, String key2); /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -986,43 +988,42 @@ CompletableFuture> lcsIdx( * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the lengths of the longest common subsequences. The resulting map contains + * two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the GlideString gs("abcd1234") and key2 - * holds the GlideString gs("bcdef1234") then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Object[] {
-     *      new Object[] {
-     *          new Long[] {4L, 7L},
-     *          new Long[] {5L, 8L},
-     *          4L},
-     *      new Object[] {
-     *          new Long[] {1L, 3L},
-     *          new Long[] {0L, 2L},
-     *          3L}
-     *      }
+     * client.mset(Map.of(gs("key1"), gs("abcd1234"), gs("key2"), gs("bcdef1234"))).get();
+     * Map response = client.lcsIdxWithMatchLen(gs("key1"), gs("key2")).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Object[][] {
+     *         {                                    // the first substring match is `gs("1234")`
+     *             new Long[] {4L, 7L},             // in `gs("key1")` it is located between indices `4` and `7`
+     *             new Long[] {5L, 8L},             // and in `gs("key2")` - in between `5` and `8`
+     *             4L                               // the match length
+     *         },
+     *         {                                    // second substring match is `"bcd"`
+     *             new Long[] {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
+     *             new Long[] {0L, 2L},             // and in `gs("key2")` - in between `0` and `2`
+     *             3L                               // the match length
+     *         }
+     *     },
+     *     "len", 6                                 // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is gs("1234") in - * key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * gs("bcd") in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. */ CompletableFuture> lcsIdxWithMatchLen(GlideString key1, GlideString key2); /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -1033,43 +1034,44 @@ CompletableFuture> lcsIdx( * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the total length of all the longest common subsequences. The resulting map + * contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. This value doesn't count towards the + * minMatchLen filter. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the string "abcd1234" and key2 - * holds the string "bcdef1234" then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Object[] {
-     *      new Object[] {
-     *          new Long[] {4L, 7L},
-     *          new Long[] {5L, 8L},
-     *          4L},
-     *      new Object[] {
-     *          new Long[] {1L, 3L},
-     *          new Long[] {0L, 2L},
-     *          3L}
-     *      }
+     * client.mset(Map.of("key1", "abcd1234", "key2", "bcdef1234")).get();
+     * Map response = client.lcsIdxWithMatchLen("key1", "key2", 2).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Object[][] {
+     *         {                                    // the first substring match is `"1234"`
+     *             new Long[] {4L, 7L},             // in `"key1"` it is located between indices `4` and `7`
+     *             new Long[] {5L, 8L},             // and in `"key2"` - in between `5` and `8`
+     *             4L                               // the match length
+     *         },
+     *         {                                    // second substring match is `"bcd"`
+     *             new Long[] {1L, 3L},             // in `"key1"` it is located between indices `1` and `3`
+     *             new Long[] {0L, 2L},             // and in `"key2"` - in between `0` and `2`
+     *             3L                               // the match length
+     *         }
+     *     },
+     *     "len", 6                                 // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is "1234" in key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * "bcd" in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. */ CompletableFuture> lcsIdxWithMatchLen( String key1, String key2, long minMatchLen); /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -1080,38 +1082,38 @@ CompletableFuture> lcsIdxWithMatchLen( * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return A Map containing the indices of the longest common subsequence between the - * 2 strings and the length of the longest common subsequence. The resulting map contains two - * keys, "matches" and "len": + * 2 strings and the total length of all the longest common subsequences. The resulting map + * contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. This value doesn't count towards the + * minMatchLen filter. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the GlideString gs("abcd1234") and key2 - * holds the GlideString gs("bcdef1234") then the sample result would be + * See example for more details. + * @example *
{@code
-     * new Object[] {
-     *      new Object[] {
-     *          new Long[] {4L, 7L},
-     *          new Long[] {5L, 8L},
-     *          4L},
-     *      new Object[] {
-     *          new Long[] {1L, 3L},
-     *          new Long[] {0L, 2L},
-     *          3L}
-     *      }
+     * client.mset(Map.of(gs("key1"), gs("abcd1234"), gs("key2"), gs("bcdef1234"))).get();
+     * Map response = client.lcsIdxWithMatchLen(gs("key1"), gs("key2"), 2).get();
+     * // the response contains data in the following format:
+     * Map data = Map.of(
+     *     "matches", new Object[][] {
+     *         {                                    // the first substring match is `gs("1234")`
+     *             new Long[] {4L, 7L},             // in `gs("key1")` it is located between indices `4` and `7`
+     *             new Long[] {5L, 8L},             // and in `gs("key2")` - in between `5` and `8`
+     *             4L                               // the match length
+     *         },
+     *         {                                    // second substring match is `"bcd"`
+     *             new Long[] {1L, 3L},             // in `gs("key1")` it is located between indices `1` and `3`
+     *             new Long[] {0L, 2L},             // and in `gs("key2")` - in between `0` and `2`
+     *             3L                               // the match length
+     *         }
+     *     },
+     *     "len", 6                                 // total length of the all matches found
+     * );
      * }
- * The result indicates that the first substring match is gs("1234") in - * key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * gs("bcd") in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. */ CompletableFuture> lcsIdxWithMatchLen( GlideString key1, GlideString key2, long minMatchLen); diff --git a/java/client/src/main/java/glide/api/models/BaseTransaction.java b/java/client/src/main/java/glide/api/models/BaseTransaction.java index cf2b77401e..4620f375b8 100644 --- a/java/client/src/main/java/glide/api/models/BaseTransaction.java +++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java @@ -225,6 +225,7 @@ import command_request.CommandRequestOuterClass.Command.ArgsArray; import command_request.CommandRequestOuterClass.RequestType; import command_request.CommandRequestOuterClass.Transaction; +import glide.api.commands.StringBaseCommands; import glide.api.models.commands.ExpireOptions; import glide.api.models.commands.FlushMode; import glide.api.models.commands.GetExOptions; @@ -3038,7 +3039,7 @@ public T zintercard(@NonNull ArgType[] keys, long limit) { * , and stores the result in destination. If destination already * exists, it is overwritten. Otherwise, a new sorted set will be created.
* To perform a zinterstore operation while specifying aggregation settings, use - * {@link #zinterstore(Object, KeysOrWeightedKeys, Aggregate)}. + * {@link #zinterstore(String, KeysOrWeightedKeys, Aggregate)}. * * @see valkey.io for more details. * @param destination The key of the destination sorted set. @@ -3064,7 +3065,7 @@ public T zinterstore( * , and stores the result in destination. If destination already * exists, it is overwritten. Otherwise, a new sorted set will be created.
* To perform a zinterstore operation while specifying aggregation settings, use - * {@link #zinterstore(Object, KeysOrWeightedKeys, Aggregate)}. + * {@link #zinterstore(GlideString, KeysOrWeightedKeysBinary, Aggregate)}. * * @see valkey.io for more details. * @param destination The key of the destination sorted set. @@ -6243,8 +6244,8 @@ public T functionDelete(@NonNull ArgType libName) { } /** - * Returns the longest common subsequence between strings stored at key1 and - * key2. + * Returns all the longest common subsequences combined between strings stored at key1 + * and key2. * * @since Valkey 7.0 and above. * @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type @@ -6252,9 +6253,9 @@ public T functionDelete(@NonNull ArgType libName) { * @see valkey.io for details. * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. - * @return Command Response - A String containing the longest common subsequence - * between the 2 strings. An empty String is returned if the keys do not exist or - * have no common subsequences. + * @return Command Response - A String containing all the longest common subsequences + * combined between the 2 strings. An empty String/GlideString is + * returned if the keys do not exist or have no common subsequences. */ public T lcs(@NonNull ArgType key1, @NonNull ArgType key2) { checkTypeOrThrow(key1); @@ -6263,8 +6264,8 @@ public T lcs(@NonNull ArgType key1, @NonNull ArgType key2) { } /** - * Returns the length of the longest common subsequence between strings stored at key1 - * and key2. + * Returns the total length of all the longest common subsequences between strings stored at + * key1 and key2. * * @since Valkey 7.0 and above. * @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type @@ -6272,7 +6273,8 @@ public T lcs(@NonNull ArgType key1, @NonNull ArgType key2) { * @see valkey.io for details. * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. - * @return Command Response - The length of the longest common subsequence between the 2 strings. + * @return Command Response - The total length of all the longest common subsequences between the + * 2 strings. */ public T lcsLen(@NonNull ArgType key1, @NonNull ArgType key2) { checkTypeOrThrow(key1); @@ -6394,35 +6396,16 @@ public T sunion(@NonNull ArgType[] keys) { * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. * @return Command Response - A Map containing the indices of the longest common - * subsequence between the 2 strings and the length of the longest common subsequence. The - * resulting map contains two keys, "matches" and "len": + * subsequence between the 2 strings and the total length of all the longest common + * subsequences. The resulting map contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the string "abcd123" and key2 - * holds the string "bcdef123" then the sample result would be - *
{@code
-     * new Long[][][] {
-     *     {
-     *         {4L, 6L},
-     *         {5L, 7L}
-     *     },
-     *     {
-     *         {1L, 3L},
-     *         {0L, 2L}
-     *     }
-     * }
-     * }
- * The result indicates that the first substring match is "123" in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * "bcd" in key1 at index 1 to 3 which matches - * the substring in key2 at index 0 to 2. + * See example of {@link StringBaseCommands#lcsIdx(String, String)} for more details. */ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2) { checkTypeOrThrow(key1); @@ -6432,8 +6415,8 @@ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2) { } /** - * Returns the indices and length of the longest common subsequence between strings stored at - * key1 and key2. + * Returns the indices and the total length of all the longest common subsequences between strings + * stored at key1 and key2. * * @since Valkey 7.0 and above. * @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type @@ -6443,35 +6426,17 @@ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2) { * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return Command Response - A Map containing the indices of the longest common - * subsequence between the 2 strings and the length of the longest common subsequence. The - * resulting map contains two keys, "matches" and "len": + * subsequence between the 2 strings and the total length of all the longest common + * subsequences. The resulting map contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. This value doesn't count towards the + * minMatchLen filter. *
  • "matches" is mapped to a three dimensional Long array that stores pairs * of indices that represent the location of the common subsequences in the strings held * by key1 and key2. *
- * - * @example If key1 holds the string "abcd123" and key2 - * holds the string "bcdef123" then the sample result would be - *
{@code
-     * new Long[][][] {
-     *     {
-     *         {4L, 6L},
-     *         {5L, 7L}
-     *     },
-     *     {
-     *         {1L, 3L},
-     *         {0L, 2L}
-     *     }
-     * }
-     * }
- * The result indicates that the first substring match is "123" in key1 - * at index 4 to 6 which matches the substring in key2 - * at index 5 to 7. And the second substring match is - * "bcd" in key1 at index 1 to 3 which matches - * the substring in key2 at index 0 to 2. + * See example of {@link StringBaseCommands#lcsIdx(String, String, long)} for more details. */ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2, long minMatchLen) { checkTypeOrThrow(key1); @@ -6488,7 +6453,7 @@ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2, long min } /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -6498,39 +6463,17 @@ public T lcsIdx(@NonNull ArgType key1, @NonNull ArgType key2, long min * @param key1 The key that stores the first string. * @param key2 The key that stores the second string. * @return Command Response - A Map containing the indices of the longest common - * subsequence between the 2 strings and the length of the longest common subsequence. The + * subsequence between the 2 strings and the lengths of the longest common subsequences. The * resulting map contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the string "abcd1234" and key2 - * holds the string "bcdef1234" then the sample result would be - *
{@code
-     * new Object[] {
-     *     new Object[] {
-     *         new Long[] {4L, 7L},
-     *         new Long[] {5L, 8L},
-     *         4L
-     *     },
-     *     new Object[] {
-     *         new Long[] {1L, 3L},
-     *         new Long[] {0L, 2L},
-     *         3L
-     *     }
-     * }
-     * }
- * The result indicates that the first substring match is "1234" in key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * "bcd" in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. + * See example of {@link StringBaseCommands#lcsIdxWithMatchLen(String, String)} for more + * details. */ public T lcsIdxWithMatchLen(@NonNull ArgType key1, @NonNull ArgType key2) { checkTypeOrThrow(key1); @@ -6546,7 +6489,7 @@ public T lcsIdxWithMatchLen(@NonNull ArgType key1, @NonNull ArgType ke } /** - * Returns the indices and length of the longest common subsequence between strings stored at + * Returns the indices and lengths of the longest common subsequences between strings stored at * key1 and key2. * * @since Valkey 7.0 and above. @@ -6557,39 +6500,17 @@ public T lcsIdxWithMatchLen(@NonNull ArgType key1, @NonNull ArgType ke * @param key2 The key that stores the second string. * @param minMatchLen The minimum length of matches to include in the result. * @return Command Response - A Map containing the indices of the longest common - * subsequence between the 2 strings and the length of the longest common subsequence. The + * subsequence between the 2 strings and the lengths of the longest common subsequences. The * resulting map contains two keys, "matches" and "len": *
    - *
  • "len" is mapped to the length of the longest common subsequence between the 2 strings - * stored as Long. - *
  • "matches" is mapped to a three dimensional Long array that stores pairs - * of indices that represent the location of the common subsequences in the strings held - * by key1 and key2. + *
  • "len" is mapped to the total length of the all longest common subsequences between + * the 2 strings stored as Long. + *
  • "matches" is mapped to a three dimensional array that stores pairs of indices that + * represent the location of the common subsequences in the strings held by key1 + * and key2 and the match length. *
- * - * @example If key1 holds the string "abcd1234" and key2 - * holds the string "bcdef1234" then the sample result would be - *
{@code
-     * new Object[] {
-     *     new Object[] {
-     *         new Long[] { 4L, 7L },
-     *         new Long[] { 5L, 8L },
-     *         4L
-     *     },
-     *     new Object[] {
-     *         new Long[] { 1L, 3L },
-     *         new Long[] { 0L, 2L },
-     *         3L
-     *     }
-     * }
-     * }
- * The result indicates that the first substring match is "1234" in key1 - * at index 4 to 7 which matches the substring in key2 - * at index 5 to 8 and the last element in the array is the - * length of the substring match which is 4. And the second substring match is - * "bcd" in key1 at index 1 to 3 which - * matches the substring in key2 at index 0 to 2 and - * the last element in the array is the length of the substring match which is 3. + * See example of {@link StringBaseCommands#lcsIdxWithMatchLen(String, String, long)} for more + * details. */ public T lcsIdxWithMatchLen( @NonNull ArgType key1, @NonNull ArgType key2, long minMatchLen) { diff --git a/node/src/BaseClient.ts b/node/src/BaseClient.ts index 4dc45abe4a..705dcbf6b8 100644 --- a/node/src/BaseClient.ts +++ b/node/src/BaseClient.ts @@ -5625,7 +5625,7 @@ export class BaseClient { * ```typescript * await client.mset({"testKey1": "abcd", "testKey2": "axcd"}); * const result = await client.lcs("testKey1", "testKey2"); - * console.log(result); // Output: 'cd' + * console.log(result); // Output: 'acd' * ``` */ public async lcs(key1: string, key2: string): Promise { @@ -5647,7 +5647,7 @@ export class BaseClient { * ```typescript * await client.mset({"testKey1": "abcd", "testKey2": "axcd"}); * const result = await client.lcsLen("testKey1", "testKey2"); - * console.log(result); // Output: 2 + * console.log(result); // Output: 3 * ``` */ public async lcsLen(key1: string, key2: string): Promise { @@ -5675,6 +5675,8 @@ export class BaseClient { * of indices that represent the location of the common subsequences in the strings held * by `key1` and `key2`. * + * See example for more details. + * * @example * ```typescript * await client.mset({"key1": "ohmytext", "key2": "mynewtext"}); diff --git a/node/src/Transaction.ts b/node/src/Transaction.ts index c7b7746158..9e450936c5 100644 --- a/node/src/Transaction.ts +++ b/node/src/Transaction.ts @@ -3334,6 +3334,8 @@ export class BaseTransaction> { * - `"matches"` is mapped to a three dimensional array of integers that stores pairs * of indices that represent the location of the common subsequences in the strings held * by `key1` and `key2`. + * + * See example of {@link BaseClient.lcsIdx|lcsIdx} for more details. */ public lcsIdx( key1: string,