2 #ifndef EPT_POPCON_POPCON_H
3 #define EPT_POPCON_POPCON_H
28 #include <tagcoll/diskindex/mmap.h>
52 Score(
float score) : offset(offset), score(score) {}
73 class Popcon :
public tagcoll::diskindex::MMap
75 struct GeneralInfo :
public tagcoll::diskindex::MMap
80 tagcoll::diskindex::MasterMMap mastermmap;
86 const Score* structByIndex(
size_t idx)
const
88 if (idx >= 0 && idx <
size())
89 return (
Score*)m_buf + idx;
100 bool hasData()
const {
return m_timestamp != 0; }
109 return ((
Score*)m_buf)->offset /
sizeof(
Score);
119 std::string
name(
size_t idx)
const
121 const Score* s = structByIndex(idx);
122 if (s == 0)
return std::string();
123 return std::string(m_buf + s->
offset);
129 const Score* s = structByIndex(idx);
float operator[](const std::string &name) const
Get the score structure by package name.
Definition: popcon.h:147
Definition: popconindexer.h:38
size_t submissions() const
Return the total number of popcon submissions.
Definition: popcon.h:103
Maps Packages to IDs and vice-versa.
Definition: popcon.h:73
size_t size() const
Get the number of packages in the index.
Definition: popcon.h:106
float scoreByName(const std::string &name) const
Get the score structure by package name.
Definition: popcon.cc:69
float scoreByIndex(size_t idx) const
Get the score by index.
Definition: popcon.h:127
Popcon()
Definition: popcon.cc:43
Score(float score)
Definition: popcon.h:52
bool hasData() const
Return true if this data source has data, false if it's empty.
Definition: popcon.h:100
float score
Definition: popcon.h:50
float score(size_t idx) const
Get the score by index.
Definition: popcon.h:138
float operator[](int idx) const
Get the score by index.
Definition: popcon.h:141
time_t timestamp() const
Get the timestamp of when the index was last updated.
Definition: popcon.h:97
unsigned offset
Definition: popcon.h:47
std::string name(size_t idx) const
Get a package name by index.
Definition: popcon.h:119
Store the score information in the popcon cache.
Definition: popcon.h:44
friend class PopconGenerator
Definition: popcon.h:56
float score(const std::string &name) const
Get the score by name.
Definition: popcon.h:144