void ProducerStateTable::set()

in common/producerstatetable.cpp [203:250]


void ProducerStateTable::set(const std::vector<KeyOpFieldsValuesTuple>& values)
{
    if (m_tempViewActive)
    {
        // Write to temp view instead of DB
        for (const auto &value : values)
        {
            const std::string &key = kfvKey(value);
            for (const auto &iv : kfvFieldsValues(value))
            {
                m_tempViewState[key][fvField(iv)] = fvValue(iv);
            }
        }
        return;
    }

    // Assembly redis command args into a string vector
    vector<string> args;
    args.emplace_back("EVALSHA");
    args.emplace_back(m_shaBatchedSet);
    args.emplace_back(to_string(values.size() + 3));
    args.emplace_back(getChannelName(m_pipe->getDbId()));
    args.emplace_back(getKeySetName());
    args.emplace_back(getStateHashPrefix() + getTableName() + getTableNameSeparator());
    for (const auto &value : values)
    {
        args.emplace_back(kfvKey(value));
    }
    args.emplace_back("G");
    for (const auto &value : values)
    {
        args.emplace_back(to_string(kfvFieldsValues(value).size()));
        for (const auto &iv : kfvFieldsValues(value))
        {
            args.emplace_back(fvField(iv));
            args.emplace_back(fvValue(iv));
        }
    }

    // Invoke redis command
    RedisCommand command;
    command.format(args);
    m_pipe->push(command, REDIS_REPLY_NIL);
    if (!m_buffered)
    {
        m_pipe->flush();
    }
}