Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Nov 7, 2022
1 parent a1271e2 commit e61e7b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ def _translate_data(
)

else:
[data_point for data_point in metric.data.data_points]
_logger.warning(
"unsupported data type %s",
metric.data.__class__.__name__,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
from abc import ABC, abstractmethod


class BucketsBacking(ABC):
class Backing(ABC):
@abstractmethod
def size(self) -> int:
"""
Returns the physical size of the backing array, which is
>= buckets.Len() the number allocated.
Returns the physical size of
"""

@abstractmethod
def grow_to(
def grow(
self, new_size: int, old_positive_limit: int, new_positive_limit: int
) -> None:
"""
Expand Down Expand Up @@ -63,7 +62,7 @@ def reset(self) -> None:
"""


class BucketsVarWidth(BucketsBacking):
class VariableWidthBacking(Backing):
def __init__(self):

self._counts = [0]
Expand All @@ -75,16 +74,13 @@ def size(self) -> int:
"""
return len(self._counts)

def grow_to(
def grow(
self, new_size: int, old_positive_limit: int, new_positive_limit: int
) -> None:
"""
Grows the backing array into a new size and copies old entries into
their correct new positions.
"""
# FIXME this follows Go implementation maybe too closely. Since we
# don't need to request memory for a larger list, maybe this can be
# implemented in a more pythonical way.
tmp = [0] * new_size
tmp[new_positive_limit:] = self._counts[old_positive_limit:]
tmp[0:old_positive_limit] = self._counts[0:old_positive_limit]
Expand Down Expand Up @@ -132,7 +128,7 @@ def reset(self) -> None:

class Buckets:
def __init__(self):
self._backing = BucketsVarWidth()
self._backing = VariableWidthBacking()

# The term "index" refers to the number of the
# histogram bucket used to determine its boundaries.
Expand Down

0 comments on commit e61e7b9

Please sign in to comment.