5#include "rb-output-stats.h"
8#include "ns3/rng-seed-manager.h"
21 m_tableName = tableName;
25 ret = m_db->SpinExec(
"CREATE TABLE IF NOT EXISTS " + tableName +
26 "(Frame INTEGER NOT NULL, "
27 "SubFrame INTEGER NOT NULL,"
28 "Slot INTEGER NOT NULL,"
29 "Symbol INTEGER NOT NULL,"
30 "RBIndexActive INTEGER NOT NULL,"
31 "BwpId INTEGER NOT NULL,"
32 "CellId INTEGER NOT NULL,"
33 "Seed INTEGER NOT NULL,"
34 "Run INTEGER NOT NULL);");
37 RbOutputStats::DeleteWhere(m_db,
38 RngSeedManager::GetSeed(),
39 RngSeedManager::GetRun(),
46 const std::vector<int> rbUsed,
57 m_slotCache.emplace_back(c);
62 if (m_slotCache.size() * c.GetSize() > 500000)
75RbOutputStats::DeleteWhere(SQLiteOutput* p, uint32_t seed, uint32_t run,
const std::string& table)
79 ret = p->SpinPrepare(&stmt,
"DELETE FROM \"" + table +
"\" WHERE SEED = ? AND RUN = ?;");
80 NS_ABORT_IF(ret ==
false);
81 ret = p->Bind(stmt, 1, seed);
82 NS_ABORT_IF(ret ==
false);
83 ret = p->Bind(stmt, 2, run);
85 ret = p->SpinExec(stmt);
86 NS_ABORT_IF(ret ==
false);
90RbOutputStats::WriteCache()
92 bool ret = m_db->SpinExec(
"BEGIN TRANSACTION;");
93 for (
const auto& v : m_slotCache)
95 for (
const auto& rb : v.rbUsed)
98 ret = m_db->SpinPrepare(&stmt,
99 "INSERT INTO " + m_tableName +
" VALUES (?,?,?,?,?,?,?,?,?);");
101 ret = m_db->Bind(stmt, 1, v.sfnSf.GetFrame());
103 ret = m_db->Bind(stmt, 2, v.sfnSf.GetSubframe());
105 ret = m_db->Bind(stmt, 3, v.sfnSf.GetSlot());
107 ret = m_db->Bind(stmt, 4, v.sym);
109 ret = m_db->Bind(stmt, 5, rb);
111 ret = m_db->Bind(stmt, 6, v.bwpId);
113 ret = m_db->Bind(stmt, 7, v.cellId);
115 ret = m_db->Bind(stmt, 8, RngSeedManager::GetSeed());
117 ret = m_db->Bind(stmt, 9,
static_cast<uint32_t
>(RngSeedManager::GetRun()));
120 ret = m_db->SpinExec(stmt);
125 ret = m_db->SpinExec(
"END TRANSACTION;");
void EmptyCache()
Force the cache write to disk, emptying the cache itself.
RbOutputStats()
Constructor.
void SetDb(SQLiteOutput *db, const std::string &tableName="rbStats")
Install the output database.
void SaveRbStats(const SfnSf &sfnSf, uint8_t sym, const std::vector< int > rbUsed, uint16_t bwpId, uint16_t cellId)
Save the slot statistics.