Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
yrajas committed Oct 22, 2024
1 parent 17e3ea0 commit f0450e4
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 249 deletions.
3 changes: 0 additions & 3 deletions libs/server/API/GarnetApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,5 @@ public int GetScratchBufferOffset()
public bool ResetScratchBuffer(int offset)
=> storageSession.scratchBufferManager.ResetScratchBuffer(offset);
#endregion

public unsafe GarnetStatus CustomCommand(RespCommand cmd, ArgSlice key, ArgSlice[] args, CommandType cmdType, out ArgSlice output)
=> storageSession.CustomCommand(cmd, key, args, cmdType, out output, ref context);
}
}
6 changes: 0 additions & 6 deletions libs/server/API/GarnetWatchApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,6 @@ public int GetScratchBufferOffset()
public bool ResetScratchBuffer(int offset)
=> garnetApi.ResetScratchBuffer(offset);

public GarnetStatus CustomCommand(RespCommand cmd, ArgSlice key, ArgSlice[] input, CommandType cmdType, out ArgSlice output)
{
garnetApi.WATCH(key, StoreType.Main);
return garnetApi.CustomCommand(cmd, key, input, cmdType, out output);
}

#endregion
}
}
1 change: 0 additions & 1 deletion libs/server/API/IGarnetApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,6 @@ public bool IterateObjectStore<TScanFunctions>(ref TScanFunctions scanFunctions,

#endregion

public GarnetStatus CustomCommand(RespCommand cmd, ArgSlice key, ArgSlice[] input, CommandType cmdType, out ArgSlice output);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions libs/server/ArgSlice/ArgSlice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public unsafe struct ArgSlice
public const int Size = 12;

[FieldOffset(0)]
public byte* ptr;
internal byte* ptr;

[FieldOffset(8)]
public int length;
internal int length;

/// <summary>
/// Create new ArgSlice from given pointer and length
Expand Down
2 changes: 0 additions & 2 deletions libs/server/Custom/CustomFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public abstract class CustomFunctions
/// </summary>
protected static MemoryPool<byte> MemoryPool => MemoryPool<byte>.Shared;

//public CustomCommandManager customCommandManager;

internal RespServerSession respServerSession;

/// <summary>
Expand Down
46 changes: 0 additions & 46 deletions libs/server/Custom/CustomProcedureWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,6 @@ namespace Garnet.server
/// </summary>
public abstract class CustomProcedure : CustomFunctions
{
internal ScratchBufferManager scratchBufferManager;

//unsafe object CustomOperation<TGarnetApi>(TGarnetApi api, string cmd, params object[] args)
// where TGarnetApi : IGarnetApi
//unsafe object CustomOperation<TGarnetApi>(TGarnetApi api, string cmd, params object[] args)
// where TGarnetApi : IGarnetApi
//{
//switch (cmd)
//{
// // We special-case a few performance-sensitive operations to directly invoke via the storage API
// case "SET" when args.Length == 2:
// case "set" when args.Length == 2:
// {
// if (!respServerSession.CheckACLPermissions(RespCommand.SET))
// return Encoding.ASCII.GetString(CmdStrings.RESP_ERR_NOAUTH);
// var key = scratchBufferManager.CreateArgSlice(Convert.ToString(args[0]));
// var value = scratchBufferManager.CreateArgSlice(Convert.ToString(args[1]));
// _ = api.SET(key, value);
// return "OK";
// }
// case "GET":
// case "get":
// {
// if (!respServerSession.CheckACLPermissions(RespCommand.GET))
// throw new Exception(Encoding.ASCII.GetString(CmdStrings.RESP_ERR_NOAUTH));
// var key = scratchBufferManager.CreateArgSlice(Convert.ToString(args[0]));
// var status = api.GET(key, out var value);
// if (status == GarnetStatus.OK)
// return value.ToString();
// return null;
// }
// // As fallback, we use RespServerSession with a RESP-formatted input. This could be optimized
// // in future to provide parse state directly.
// default:
// {
//var request = scratchBufferManager.FormatCommandAsResp(cmd, args, null);
//_ = respServerSession.TryConsumeMessages(request.ptr, request.length);
//var response = scratchBufferNetworkSender.GetResponse();
//var result = ProcessResponse(response.ptr, response.length);
//scratchBufferNetworkSender.Reset();
//return result;
// }
//}
//}


/// <summary>
/// Custom command implementation
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions libs/server/Custom/CustomRespCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed unsafe partial class RespServerSession : ServerSessionBase
{
private bool TryTransactionProc(byte id, CustomTransactionProcedure proc, int parseStateFirstArgIdx = 0, int parseStateLastArgIdx = -1)
{
// Define _output
// Define output
var output = new MemoryResult<byte>(null, 0);

// Run procedure
Expand All @@ -28,7 +28,7 @@ private bool TryTransactionProc(byte id, CustomTransactionProcedure proc, int pa
var procInput = new CustomProcedureInput(ref parseState, parseStateFirstArgIdx, parseStateLastArgIdx);
if (txnManager.RunTransactionProc(id, ref procInput, proc, ref output))
{
// Write _output to wire
// Write output to wire
if (output.MemoryOwner != null)
SendAndReset(output.MemoryOwner, output.Length);
else
Expand All @@ -37,7 +37,7 @@ private bool TryTransactionProc(byte id, CustomTransactionProcedure proc, int pa
}
else
{
// Write _output to wire
// Write output to wire
if (output.MemoryOwner != null)
SendAndReset(output.MemoryOwner, output.Length);
else
Expand Down
121 changes: 0 additions & 121 deletions libs/server/Storage/Session/CustomOps.cs

This file was deleted.

59 changes: 0 additions & 59 deletions libs/server/Storage/Session/MainStore/MainStoreOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,65 +1124,6 @@ public unsafe GarnetStatus SCAN<TContext>(long cursor, ArgSlice match, long coun
return GarnetStatus.OK;
}

public unsafe GarnetStatus CustomCommand<TContext>(RespCommand cmd, ArgSlice key, ArgSlice[] args, CommandType type, out ArgSlice value, ref TContext context)
where TContext : ITsavoriteContext<SpanByte, SpanByte, RawStringInput, SpanByteAndMemory, long, MainSessionFunctions, MainStoreFunctions, MainStoreAllocator>
{
var sbKey = key.SpanByte;
value = default;

var sessionParseState = new SessionParseState();
sessionParseState.InitializeWithArguments(args);

var rawStringInput = new RawStringInput(cmd, ref sessionParseState);

var _output = new SpanByteAndMemory { SpanByte = scratchBufferManager.ViewRemainingArgSlice().SpanByte };
return GarnetStatus.OK;
//GarnetStatus status;
//if (type == CommandType.ReadModifyWrite)
//{
// status = RMW_MainStore(ref sbKey, ref rawStringInput, ref _output, ref context);
// //Debug.Assert(!output.IsSpanByte);

// if (output.Memory != null)
// SendAndReset(output.Memory, output.Length);
// else
// while (!RespWriteUtils.WriteDirect(CmdStrings.RESP_OK, ref dcurr, dend))
// SendAndReset();
//}
//else
//{
// status = Read_MainStore(ref sbKey, ref rawStringInput, ref _output, ref context);
// //Debug.Assert(!_output.IsSpanByte); // why?

// if (status == GarnetStatus.OK)
// if (!_output.IsSpanByte)
// {
// value = scratchBufferManager.FormatScratch(0, _output.AsReadOnlySpan());
// _output.Memory.Dispose();
// }
// else
// {
// value = scratchBufferManager.CreateArgSlice(_output.Length);
// }
//}


//if (ret == GarnetStatus.OK)
//{
// if (!_output.IsSpanByte)
// {
// value = scratchBufferManager.FormatScratch(0, _output.AsReadOnlySpan());
// _output.Memory.Dispose();
// }
// else
// {
// value = scratchBufferManager.CreateArgSlice(_output.Length);
// }
//}

//return RMW_MainStore(ref sbKey, ref rawStringInput, ref output, ref context);
}

public GarnetStatus GetKeyType<TContext, TObjectContext>(ArgSlice key, out string keyType, ref TContext context, ref TObjectContext objectContext)
where TContext : ITsavoriteContext<SpanByte, SpanByte, RawStringInput, SpanByteAndMemory, long, MainSessionFunctions, MainStoreFunctions, MainStoreAllocator>
where TObjectContext : ITsavoriteContext<byte[], IGarnetObject, ObjectInput, GarnetObjectStoreOutput, long, ObjectSessionFunctions, ObjectStoreFunctions, ObjectStoreAllocator>
Expand Down
3 changes: 0 additions & 3 deletions main/GarnetServer/Extensions/ProcCustomCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public override unsafe bool Execute<TGarnetApi>(TGarnetApi garnetApi, ref Custom
{
args[i] = GetNextArg(ref procInput, ref offset);
}
// id from registration of custom raw string cmd
//garnetApi.CustomCommand(0, key, new ArgSlice(input.ptr + offset, input.length - offset), ref cmdOutput);
//InvokeCustomRawStringCommand(garnetApi, "SETIFPM", key, args);

ExecuteCustomRawStringCommand(garnetApi, "SETIFPM", key, args, out var _output);
return true;
Expand Down
3 changes: 0 additions & 3 deletions main/GarnetServer/Extensions/TxnCustomCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public override void Finalize<TGarnetApi>(TGarnetApi api, ref CustomProcedureInp
{
args[i] = GetNextArg(ref procInput, ref offset);
}
// id from registration of custom raw string cmd
//garnetApi.CustomCommand(0, key, new ArgSlice(input.ptr + offset, input.length - offset), ref cmdOutput);
//InvokeCustomRawStringCommand(garnetApi, "SETIFPM", key, args);

//ExecuteCustomRawStringCommand(api, "SETIFPM", key, args, out var _output);

Expand Down

0 comments on commit f0450e4

Please sign in to comment.