public RawResultQueryParams ReadRawQueryParams(/*Action<int> updatePayloadType = null*/)
        {
            var v = new RawResultQueryParams();

            v.aggResults = new List <byte[]>();
            v.flags      = (int)GetVarUInt();
            v.totalcount = (int)GetVarUInt();
            v.qcount     = (int)GetVarUInt();
            v.count      = (int)GetVarUInt();

            if ((v.flags & ResultsWithPayloadTypes) != 0)
            {
                var ptCount = (int)GetVarUInt();
                for (var i = 0; i < ptCount; i++)
                {
                    var nsid   = (int)GetVarUInt();
                    var nsName = GetVString();

#pragma warning disable S125 // Sections of code should not be commented out
                    //if (updatePayloadType == null)
                    //{
                    //    throw new Exception("Internal error: Got payload types from raw query params, but there are no updatePayloadType");
                    //}
                    //updatePayloadType(nsid);
#pragma warning restore S125 // Sections of code should not be commented out
                    ReadPayloadType();
                }
            }
            ReadExtraResults(ref v);
            _flags = v.flags;

            return(v);
        }
        public void ReadExtraResults(ref RawResultQueryParams v)
        {
            while (true)
            {
                var tag = (QueryResultTag)GetVarUInt();
                if (tag == QueryResultTag.End)
                {
                    break;
                }

                var data = GetBytes();
                switch (tag)
                {
                case QueryResultTag.Explain:
                    v.explainResults = data;
                    break;

                case QueryResultTag.Aggregation:
                    v.aggResults.Add(data.ToArray());
                    break;
                }
            }
        }