Repository: microsoft/garnet
File: libs/server/Resp/Vector/RespServerSessionVectors.cs (C#)

Code before:
        {
            if (!storageSession.vectorManager.IsEnabled)
            {
                return AbortWithErrorMessage("ERR Vector Set (preview) commands are not enabled");
            }

            if (parseState.Count != 1)
            {
                return AbortWithWrongNumberOfArguments("VINFO");
            }

            var key = parseState.GetArgSliceByRef(0);
            var res = storageApi.VectorSetInfo(key, out VectorQuantType quantType, out uint vectorDimensions, out uint reducedDimensions, out uint buildExplorationFactor, out uint numLinks, out long size);
            if (res == GarnetStatus.NOTFOUND)
            {
                WriteNull();
                return true;
            }
            
            if (res == GarnetStatus.WRONGTYPE)
            {
                WriteError("ERR Not a Vector Set"u8);
                return true;
            }

            string quantTypeStr = quantType switch
            {
                VectorQuantType.NoQuant => "no-quant",
                VectorQuantType.Bin => "bin",
                VectorQuantType.Q8 => "q8",
                VectorQuantType.XPreQ8 => "xpreq8",
                _ => "invalid",
            };

            WriteArrayLength(12);
            WriteSimpleString("quant-type");
            WriteSimpleString($"{quantTypeStr}");
            WriteSimpleString("input-vector-dimensions");
            WriteSimpleString($"{vectorDimensions}");
            WriteSimpleString("reduced-dimensions");
            WriteSimpleString($"{reducedDimensions}");
            WriteSimpleString("build-exploration-factor");
            WriteSimpleString($"{buildExplorationFactor}");
            WriteSimpleString("num-links");
            WriteSimpleString($"{numLinks}");
            WriteSimpleString("size");
            WriteSimpleString($"{size}");
            return true;
        }

        private bool NetworkVISMEMBER<TGarnetApi>(ref TGarnetApi storageApi)

Review comment (suggestion):
This allocates a bunch of strings and then has to map things to ASCII.  Not a high priority command, but we should follow best practice here and do this alloc free.

Pattern is to only use the `ReadOnlySpan<byte>` taking overloads (and the `u8` suffix) for constant strings.  For the numbers, use `TryWriteIntXXAsBulkString` and `SendAndReset()` with a while loop.

Code after:

            // TODO: implement!

            while (!RespWriteUtils.TryWriteDirect(CmdStrings.RESP_OK, ref dcurr, dend))
                SendAndReset();

            return true;
        }

        private bool NetworkVINFO<TGarnetApi>(ref TGarnetApi storageApi)
            where TGarnetApi : IGarnetApi
        {
            if (!storageSession.vectorManager.IsEnabled)
            {
                return AbortWithErrorMessage("ERR Vector Set (preview) commands are not enabled");
            }

            if (parseState.Count != 1)
            {
                return AbortWithWrongNumberOfArguments("VINFO");
            }

            var key = parseState.GetArgSliceByRef(0);
            var res = storageApi.VectorSetInfo(key, out VectorQuantType quantType, out var vectorDimensions, out var reducedDimensions, out var buildExplorationFactor, out var numLinks, out var size);
            if (res == GarnetStatus.NOTFOUND)
            {
                WriteNullArray();
                return true;
            }
            else if (res == GarnetStatus.WRONGTYPE)
            {
                return AbortVectorSetWrongType();
            }
            else if (res == GarnetStatus.BADSTATE)
            {
                return AbortVectorSetPartiallyDeleted(ref key);
            }

            var quantTypeSpan = quantType switch
            {
                VectorQuantType.NoQuant => "f32"u8,
                VectorQuantType.Bin => "bin"u8,
                VectorQuantType.Q8 => "q8"u8,
                VectorQuantType.XPreQ8 => "xpreq8"u8,
                _ => throw new GarnetException($"Invalid VectorQuantType: {quantType}"),
            };

            WriteArrayLength(12);
            WriteSimpleString("quant-type"u8);
            WriteSimpleString(quantTypeSpan);
            WriteSimpleString("input-vector-dimensions"u8);