Skip to content

Commit f9f02bb

Browse files
committed
[CHORE] refactor telemetry code
remove unneeded telemetry::Sink rename IDs file to Registry (easy to understand)
1 parent a4d0c6b commit f9f02bb

11 files changed

Lines changed: 33 additions & 69 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,9 @@ set(INLIMBO_CORE_SOURCES
213213
src/taglib/source/MP3.cc
214214
src/taglib/source/FLAC.cc
215215
src/mpris/Service.cc
216-
src/telemetry/Sink.cc
217216
src/telemetry/Analysis.cc
218217
src/telemetry/Store.cc
219-
src/telemetry/IDs.cc
218+
src/telemetry/Registry.cc
220219
src/query/SongMap.cc
221220
src/query/sort/Engine.cc
222221
src/query/sort/Stats.cc

include/inlimbo/telemetry/Context.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "IDs.hpp"
3+
#include "Registry.hpp"
44
#include "Store.hpp"
55

66
namespace telemetry

include/inlimbo/telemetry/Event.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "IDs.hpp"
3+
#include "Registry.hpp"
44
#include <cereal/types/vector.hpp>
55

66
namespace telemetry

include/inlimbo/telemetry/Sink.hpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

include/inlimbo/telemetry/Stats.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "IDs.hpp"
3+
#include "Registry.hpp"
44

55
namespace telemetry
66
{

include/inlimbo/telemetry/Store.hpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
namespace telemetry
1212
{
1313

14+
/// a generic map that corresponds to T -> key && Stats -> value
15+
///
16+
/// ex: StatsMap<SongID> -> for each song id we have a corresponding stat struct
17+
/// describing about the song (like no of plays, total playtime, last played, etc.)
18+
template <typename T>
19+
using StatsMap = ankerl::unordered_dense::map<T, Stats>;
20+
1421
class Store
1522
{
1623
public:
@@ -27,10 +34,10 @@ class Store
2734
[[nodiscard]] auto album(AlbumID id) const -> const Stats*;
2835
[[nodiscard]] auto genre(GenreID id) const -> const Stats*;
2936

30-
[[nodiscard]] auto songs() const -> const ankerl::unordered_dense::map<SongID, Stats>&;
31-
[[nodiscard]] auto artists() const -> const ankerl::unordered_dense::map<ArtistID, Stats>&;
32-
[[nodiscard]] auto albums() const -> const ankerl::unordered_dense::map<AlbumID, Stats>&;
33-
[[nodiscard]] auto genres() const -> const ankerl::unordered_dense::map<GenreID, Stats>&;
37+
[[nodiscard]] auto songs() const -> const StatsMap<SongID>&;
38+
[[nodiscard]] auto artists() const -> const StatsMap<ArtistID>&;
39+
[[nodiscard]] auto albums() const -> const StatsMap<AlbumID>&;
40+
[[nodiscard]] auto genres() const -> const StatsMap<GenreID>&;
3441

3542
// Disk API
3643
[[nodiscard]] auto save(const std::string& path) const -> bool;
@@ -45,10 +52,10 @@ class Store
4552
std::vector<Event> events;
4653
double minPlaySec = 30.0;
4754

48-
ankerl::unordered_dense::map<SongID, Stats> songStats;
49-
ankerl::unordered_dense::map<ArtistID, Stats> artistStats;
50-
ankerl::unordered_dense::map<AlbumID, Stats> albumStats;
51-
ankerl::unordered_dense::map<GenreID, Stats> genreStats;
55+
StatsMap<SongID> songStats;
56+
StatsMap<ArtistID> artistStats;
57+
StatsMap<AlbumID> albumStats;
58+
StatsMap<GenreID> genreStats;
5259

5360
static auto find(const auto& map, auto id) -> const Stats*;
5461

include/inlimbo/utils/string/Table.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
namespace utils::string
99
{
1010

11+
/// a generic class that is meant to contain a ID, STRING relation
12+
///
13+
/// ex: id1 --- "hi", id2 --- "hello", etc.
14+
///
15+
/// class ensures that the relation is completely retrievable via
16+
/// 2 relation maps (id -> str) and (str -> id) for lookups.
17+
///
18+
/// there could be more memory efficient way to store this, but
19+
/// this works for now.
1120
template <typename ID>
1221
class StringTable
1322
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "telemetry/IDs.hpp"
1+
#include "telemetry/Registry.hpp"
22
#include <cereal/archives/binary.hpp>
33
#include <cereal/types/vector.hpp>
44
#include <fstream>

src/telemetry/Sink.cc

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)