Skip to content

Commit

Permalink
Removing Batch OPs pending further review
Browse files Browse the repository at this point in the history
signed-of-by:Don Newton<don@opennetworking.org>
  • Loading branch information
PINS Working Group authored and donNewtonAlpha committed Nov 1, 2021
1 parent d7ed943 commit f768a4d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 103 deletions.
94 changes: 0 additions & 94 deletions common/producerstatetable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,100 +185,6 @@ void ProducerStateTable::del(const string &key, const string &op /*= DEL_COMMAND
}
}

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());
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));
}
}

// Transform data structure
vector<const char *> args1;
transform(args.begin(), args.end(), back_inserter(args1), [](const string &s) { return s.c_str(); } );

// Invoke redis command
RedisCommand command;
command.formatArgv((int)args1.size(), &args1[0], NULL);
m_pipe->push(command, REDIS_REPLY_NIL);
if (!m_buffered)
{
m_pipe->flush();
}
}

void ProducerStateTable::del(const std::vector<std::string>& keys)
{
if (m_tempViewActive)
{
// Write to temp view instead of DB
for (const auto &key : keys)
{
m_tempViewState.erase(key);
}
return;
}

// Assembly redis command args into a string vector
vector<string> args;
args.emplace_back("EVALSHA");
args.emplace_back(m_shaBatchedDel);
args.emplace_back(to_string(keys.size() + 4));
args.emplace_back(getChannelName());
args.emplace_back(getKeySetName());
args.emplace_back(getDelKeySetName());
args.emplace_back(getStateHashPrefix() + getTableName() + getTableNameSeparator());
for (const auto &key : keys)
{
args.emplace_back(key);
}
args.emplace_back("G");

// Transform data structure
vector<const char *> args1;
transform(args.begin(), args.end(), back_inserter(args1), [](const string &s) { return s.c_str(); } );

// Invoke redis command
RedisCommand command;
command.formatArgv((int)args1.size(), &args1[0], NULL);
m_pipe->push(command, REDIS_REPLY_NIL);
if (!m_buffered)
{
m_pipe->flush();
}
}

void ProducerStateTable::flush()
{
m_pipe->flush();
Expand Down
9 changes: 0 additions & 9 deletions common/producerstatetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ class ProducerStateTable : public TableBase, public TableName_KeySet
%}
#endif

// Batched version of set() and del().
// The batched methods don't include (or use) op and prefix. They are
// written for specific use case only. The consumer logic (or batch size)
// might need to change if the producer does batched operations.

// In set(), the op is ignored.
void set(const std::vector<KeyOpFieldsValuesTuple>& values);

void del(const std::vector<std::string>& keys);

void flush();

Expand Down

0 comments on commit f768a4d

Please sign in to comment.