mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
LCS -> STRALGO LCS.
STRALGO should be a container for mostly read-only string algorithms in Redis. The algorithms should have two main characteristics: 1. They should be non trivial to compute, and often not part of programming language standard libraries. 2. They should be fast enough that it is a good idea to have optimized C implementations. Next thing I would love to see? A small strings compression algorithm.
This commit is contained in:
@@ -424,29 +424,29 @@ start_server {tags {"string"}} {
|
||||
set rna2 {ATTAAAGGTTTATACCTTCCCAGGTAACAAACCAACCAACTTTCGATCTCTTGTAGATCTGTTCTCTAAACGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACTCACGCAGTATAATTAATAACTAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATCTTCTGCAGGCTGCTTACGGTTTCGTCCGTGTTGCAGCCGATCATCAGCACATCTAGGTTT}
|
||||
set rnalcs {ACCTTCCCAGGTAACAAACCAACCAACTTTCGATCTCTTGTAGATCTGTTCTCTAAACGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACTCACGCAGTATAATTAATAACTAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATCTTCTGCAGGCTGCTTACGGTTTCGTCCGTGTTGCAGCCGATCATCAGCACATCTAGGTTT}
|
||||
|
||||
test {LCS string output with STRINGS option} {
|
||||
r LCS STRINGS $rna1 $rna2
|
||||
test {STRALGO LCS string output with STRINGS option} {
|
||||
r STRALGO LCS STRINGS $rna1 $rna2
|
||||
} $rnalcs
|
||||
|
||||
test {LCS len} {
|
||||
r LCS LEN STRINGS $rna1 $rna2
|
||||
test {STRALGO LCS len} {
|
||||
r STRALGO LCS LEN STRINGS $rna1 $rna2
|
||||
} [string length $rnalcs]
|
||||
|
||||
test {LCS with KEYS option} {
|
||||
r set virus1 $rna1
|
||||
r set virus2 $rna2
|
||||
r LCS KEYS virus1 virus2
|
||||
r STRALGO LCS KEYS virus1 virus2
|
||||
} $rnalcs
|
||||
|
||||
test {LCS indexes} {
|
||||
dict get [r LCS IDX KEYS virus1 virus2] matches
|
||||
dict get [r STRALGO LCS IDX KEYS virus1 virus2] matches
|
||||
} {{{238 238} {239 239}} {{236 236} {238 238}} {{229 230} {236 237}} {{224 224} {235 235}} {{1 222} {13 234}}}
|
||||
|
||||
test {LCS indexes with match len} {
|
||||
dict get [r LCS IDX KEYS virus1 virus2 WITHMATCHLEN] matches
|
||||
dict get [r STRALGO LCS IDX KEYS virus1 virus2 WITHMATCHLEN] matches
|
||||
} {{{238 238} {239 239} 1} {{236 236} {238 238} 1} {{229 230} {236 237} 2} {{224 224} {235 235} 1} {{1 222} {13 234} 222}}
|
||||
|
||||
test {LCS indexes with match len and minimum match len} {
|
||||
dict get [r LCS IDX KEYS virus1 virus2 WITHMATCHLEN MINMATCHLEN 5] matches
|
||||
dict get [r STRALGO LCS IDX KEYS virus1 virus2 WITHMATCHLEN MINMATCHLEN 5] matches
|
||||
} {{{1 222} {13 234} 222}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user