static void deserializeBuffer()

in common/binaryserializer.h [123:171]


    static void deserializeBuffer(
        const char* buffer,
        const size_t size,
        std::string& dbName,
        std::string& tableName,
        std::vector<std::shared_ptr<KeyOpFieldsValuesTuple>>& kcos)
    {
        std::vector<FieldValueTuple> values;
        deserializeBuffer(buffer, size, values);
        int fvs_size = -1;
        KeyOpFieldsValuesTuple kco;
        auto& key = kfvKey(kco);
        auto& op = kfvOp(kco);
        auto& fvs = kfvFieldsValues(kco);
        for (auto& fv : values)
        {
            auto& field = fvField(fv);
            auto& value = fvValue(fv);
            // The first pair is the DB name and the table name.
            if (fvs_size < 0)
            {
                dbName = field;
                tableName = value;
                fvs_size = 0;
                continue;
            }
            // This is the beginning of a request.
            // The first pair is the key and the number of attributes.
            // If the attribute count is zero, it is a DEL request.
            if (fvs_size == 0)
            {
                key = field;
                fvs_size = std::stoi(value);
                op = (fvs_size == 0) ? DEL_COMMAND : SET_COMMAND;
                fvs.clear();
            }
            // This is an attribut pair.
            else
            {
                fvs.push_back(fv);
                --fvs_size;
            }
            // We got the last attribut pair. This is the end of a request.
            if (fvs_size == 0)
            {
                kcos.push_back(std::make_shared<KeyOpFieldsValuesTuple>(kco));
            }
        }
    }