Skip to content

Commit

Permalink
ref: delete some dead methods from tsdb
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Jan 7, 2025
1 parent 414306f commit 85b1cca
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 715 deletions.
89 changes: 0 additions & 89 deletions src/sentry/tsdb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ class BaseTSDB(Service):
"get_sums",
"get_distinct_counts_series",
"get_distinct_counts_totals",
"get_distinct_counts_union",
"get_most_frequent",
"get_most_frequent_series",
"get_frequency_series",
"get_frequency_totals",
"get_distinct_counts_totals_with_conditions",
]
)
Expand Down Expand Up @@ -574,22 +570,6 @@ def get_distinct_counts_totals_with_conditions(
"""
raise NotImplementedError

def get_distinct_counts_union(
self,
model: TSDBModel,
keys: list[int] | None,
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> int:
"""
Count the total number of distinct items across multiple counters
during a time range.
"""
raise NotImplementedError

def merge_distinct_counts(
self,
model: TSDBModel,
Expand Down Expand Up @@ -632,52 +612,6 @@ def record_frequency_multi(
"""
raise NotImplementedError

def get_most_frequent(
self,
model: TSDBModel,
keys: Sequence[TSDBKey],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
limit: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[TSDBKey, list[tuple[str, float]]]:
"""
Retrieve the most frequently seen items in a frequency table.
Results are returned as a mapping, where the key is the key requested
and the value is a list of ``(member, score)`` tuples, ordered by the
highest (most frequent) to lowest (least frequent) score. The maximum
number of items returned is ``index capacity * rollup intervals`` if no
``limit`` is provided.
"""
raise NotImplementedError

def get_most_frequent_series(
self,
model: TSDBModel,
keys: Iterable[str],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
limit: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[str, list[tuple[int, dict[str, float]]]]:
"""
Retrieve the most frequently seen items in a frequency table for each
interval in a series. (This is in contrast with ``get_most_frequent``,
which returns the most frequent items seen over the entire requested
range.)
Results are returned as a mapping, where the key is the key requested
and the value is a list of ``(timestamp, {item: score, ...})`` pairs
over the series. The maximum number of items returned for each interval
is the index capacity if no ``limit`` is provided.
"""
raise NotImplementedError

def get_frequency_series(
self,
model: TSDBModel,
Expand All @@ -701,29 +635,6 @@ def get_frequency_series(
"""
raise NotImplementedError

def get_frequency_totals(
self,
model: TSDBModel,
items: Mapping[TSDBKey, Sequence[TSDBItem]],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[TSDBKey, dict[TSDBItem, float]]:
"""
Retrieve the total frequency of known items in a table over time.
The items requested should be passed as a mapping, where the key is the
metric key, and the value is a sequence of members to retrieve scores
for.
Results are returned as a mapping, where the key is the key requested
and the value is a mapping of ``{item: score, ...}`` containing the
total score of items over the interval.
"""
raise NotImplementedError

def merge_frequencies(
self,
model: TSDBModel,
Expand Down
58 changes: 0 additions & 58 deletions src/sentry/tsdb/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@ def get_distinct_counts_totals_with_conditions(
self.validate_arguments([model], [environment_id])
return 0

def get_distinct_counts_union(
self,
model: TSDBModel,
keys: list[int] | None,
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> int:
self.validate_arguments([model], [environment_id])
return 0

def merge_distinct_counts(
self, model, destination, sources, timestamp=None, environment_ids=None
):
Expand All @@ -124,35 +111,6 @@ def record_frequency_multi(
):
self.validate_arguments([model for model, request in requests], [environment_id])

def get_most_frequent(
self,
model: TSDBModel,
keys: Sequence[TSDBKey],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
limit: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[TSDBKey, list[tuple[str, float]]]:
self.validate_arguments([model], [environment_id])
return {key: [] for key in keys}

def get_most_frequent_series(
self,
model: TSDBModel,
keys: Iterable[str],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
limit: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[str, list[tuple[int, dict[str, float]]]]:
self.validate_arguments([model], [environment_id])
rollup, series = self.get_optimal_rollup_series(start, end, rollup)
return {key: [(timestamp, {}) for timestamp in series] for key in keys}

def get_frequency_series(
self,
model: TSDBModel,
Expand All @@ -171,22 +129,6 @@ def get_frequency_series(
for key, members in items.items()
}

def get_frequency_totals(
self,
model: TSDBModel,
items: Mapping[TSDBKey, Sequence[TSDBItem]],
start: datetime,
end: datetime | None = None,
rollup: int | None = None,
environment_id: int | None = None,
tenant_ids: dict[str, str | int] | None = None,
) -> dict[TSDBKey, dict[TSDBItem, float]]:
self.validate_arguments([model], [environment_id])
results = {}
for key, members in items.items():
results[key] = {member: 0.0 for member in members}
return results

def merge_frequencies(
self,
model: TSDBModel,
Expand Down
Loading

0 comments on commit 85b1cca

Please sign in to comment.