From 1b89812679c46a6512e8181cb2aa827f128c4fbf Mon Sep 17 00:00:00 2001 From: catcherwong Date: Mon, 7 Oct 2024 05:04:37 +0000 Subject: [PATCH] cli csv support slot id Signed-off-by: catcherwong --- build/version.props | 4 ++-- src/RDBCli/Callbacks/MemoryCallback.cs | 7 ++++++- src/RDBCli/Commands/CsvCommand.cs | 4 ++-- src/RDBCli/Stats/Record.cs | 5 +++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/build/version.props b/build/version.props index d544c77..67e2164 100644 --- a/build/version.props +++ b/build/version.props @@ -1,8 +1,8 @@ - 0.9.5 - 0.9.5 + 0.9.6 + 0.9.6 \ No newline at end of file diff --git a/src/RDBCli/Callbacks/MemoryCallback.cs b/src/RDBCli/Callbacks/MemoryCallback.cs index 3f24c57..cde412d 100644 --- a/src/RDBCli/Callbacks/MemoryCallback.cs +++ b/src/RDBCli/Callbacks/MemoryCallback.cs @@ -1,5 +1,4 @@ using RDBParser; -using System.Collections.Generic; namespace RDBCli.Callbacks { @@ -278,6 +277,7 @@ public void Set(byte[] key, byte[] value, long expiry, Info info) LenOfLargestElem = length, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; _rdbDataInfo.TotalMem += record.Bytes; @@ -319,6 +319,7 @@ public void StartHash(byte[] key, long length, long expiry, Info info) Database = _dbNum, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; } @@ -340,6 +341,7 @@ public void StartList(byte[] key, long expiry, Info info) Database = _dbNum, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; } @@ -361,6 +363,7 @@ public bool StartModule(byte[] key, string module_name, long expiry, Info info) Database = _dbNum, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; return false; @@ -406,6 +409,7 @@ public void StartSortedSet(byte[] key, long length, long expiry, Info info) Database = _dbNum, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; } @@ -428,6 +432,7 @@ public void StartStream(byte[] key, long listpacks_count, long expiry, Info info Database = _dbNum, Freq = info.Freq, Idle = info.Idle, + SlotId = info.SlotId, }; } diff --git a/src/RDBCli/Commands/CsvCommand.cs b/src/RDBCli/Commands/CsvCommand.cs index 68cb202..1fee94f 100644 --- a/src/RDBCli/Commands/CsvCommand.cs +++ b/src/RDBCli/Commands/CsvCommand.cs @@ -225,7 +225,7 @@ public Task Output(string output) { // overwrite fs.SetLength(0); - var header = Encoding.UTF8.GetBytes("database,type,key,size_in_bytes,encoding,num_elements,len_largest_element,expiry,idle,freq\n"); + var header = Encoding.UTF8.GetBytes("database,type,key,size_in_bytes,encoding,num_elements,len_largest_element,expiry,idle,freq,slot_id\n"); fs.Write(header); while (!_records.IsCompleted) @@ -234,7 +234,7 @@ public Task Output(string output) { if (_records.TryTake(out var item)) { - var line = Encoding.UTF8.GetBytes($"{item.Record.Database},{item.Record.Type},{item.Record.Key},{item.Record.Bytes},{item.Record.Encoding},{item.Record.NumOfElem},{item.Record.LenOfLargestElem},{CommonHelper.GetExpireString(item.Record.Expiry)},{item.Record.Idle},{item.Record.Freq}\n"); + var line = Encoding.UTF8.GetBytes($"{item.Record.Database},{item.Record.Type},{item.Record.Key},{item.Record.Bytes},{item.Record.Encoding},{item.Record.NumOfElem},{item.Record.LenOfLargestElem},{CommonHelper.GetExpireString(item.Record.Expiry)},{item.Record.Idle},{item.Record.Freq},{item.Record.SlotId}\n"); fs.Write(line); } else diff --git a/src/RDBCli/Stats/Record.cs b/src/RDBCli/Stats/Record.cs index bef2b00..a5747f3 100644 --- a/src/RDBCli/Stats/Record.cs +++ b/src/RDBCli/Stats/Record.cs @@ -56,6 +56,11 @@ public class Record /// LFU frequency. /// public int Freq { get; set; } + + /// + /// hash slot + /// + public ulong SlotId { get; set; } } public class StreamsRecord