fix(redis): show values for kvrocks bitmap and hyperloglog keys
This commit is contained in:
17 files changed
+367
-30
No files matched your search
@@ -3106,7 +3106,8 @@ export interface RedisKeyInfo {
|
||||
|
||||
export interface RedisDatabaseInfo {
|
||||
db: number;
|
||||
keys: number;
|
||||
/** 该库的键数量;服务端无法给出可信数量时(如 kvrocks 未执行过 DBSIZE SCAN)缺省。 */
|
||||
keys?: number;
|
||||
}
|
||||
|
||||
export type RedisBlobEncoding = "utf8" | "binary";
|
||||
@@ -3210,7 +3211,11 @@ export type RedisValueData =
|
||||
scan_cursor?: number;
|
||||
}
|
||||
| { kind: "stream"; entries: RedisStreamEntry[]; total?: number; next_cursor?: string }
|
||||
| { kind: "unknown" };
|
||||
// kvrocks 把位图/HLL 实现为独立类型(TYPE 返回 bitmap / hyperloglog),
|
||||
// 这里单独建模,避免落到 unknown 后界面显示不出值。
|
||||
| { kind: "bitmap"; content: RedisBlob; total_bytes?: number; truncated?: boolean; set_bits?: number }
|
||||
| { kind: "hyperloglog"; count?: number }
|
||||
| { kind: "unknown"; redis_type: string };
|
||||
|
||||
export interface RedisValue {
|
||||
key_display: string;
|
||||
|
||||
@@ -562,6 +562,8 @@ export function redisValueCollectionScanCursor(value: RedisValue): number | unde
|
||||
export function redisValueSize(value: RedisValue): number {
|
||||
switch (value.data.kind) {
|
||||
case "string":
|
||||
// kvrocks 位图与字符串一样按字节计长度
|
||||
case "bitmap":
|
||||
return value.data.total_bytes ?? decodeRedisBlob(value.data.content).byteLength;
|
||||
case "json":
|
||||
return new TextEncoder().encode(redisJsonValueText(value.data)).byteLength;
|
||||
@@ -581,6 +583,9 @@ export function redisValuePreview(value: RedisValue): string {
|
||||
switch (value.data.kind) {
|
||||
case "string":
|
||||
return previewText(redisBlobRawText(value.data.content));
|
||||
case "bitmap":
|
||||
// kvrocks 位图的 GET 结果就是字节内容,预览方式与字符串一致
|
||||
return previewText(redisBlobRawText(value.data.content));
|
||||
case "json":
|
||||
return previewText(redisJsonValueText(value.data));
|
||||
case "list": {
|
||||
|
||||
Reference in new issue
Block a user