Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli csv support slot id #74

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>

<RDBParserVersion>0.9.5</RDBParserVersion>
<RDBCliVersion>0.9.5</RDBCliVersion>
<RDBParserVersion>0.9.6</RDBParserVersion>
<RDBCliVersion>0.9.6</RDBCliVersion>

</PropertyGroup>
</Project>
7 changes: 6 additions & 1 deletion src/RDBCli/Callbacks/MemoryCallback.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using RDBParser;
using System.Collections.Generic;

namespace RDBCli.Callbacks
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};
}

Expand All @@ -340,6 +341,7 @@ public void StartList(byte[] key, long expiry, Info info)
Database = _dbNum,
Freq = info.Freq,
Idle = info.Idle,
SlotId = info.SlotId,
};
}

Expand All @@ -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;
Expand Down Expand Up @@ -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,
};
}

Expand All @@ -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,
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/RDBCli/Commands/CsvCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Task<string> 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)
Expand All @@ -234,7 +234,7 @@ public Task<string> 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
Expand Down
5 changes: 5 additions & 0 deletions src/RDBCli/Stats/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class Record
/// LFU frequency.
/// </summary>
public int Freq { get; set; }

/// <summary>
/// hash slot
/// </summary>
public ulong SlotId { get; set; }
}

public class StreamsRecord
Expand Down