# Path: biggraphite/metric.py
# _UTF8_CODEC = codecs.getencoder("utf8")
# _UUID_NAMESPACE = uuid.UUID("{00000000-1111-2222-3333-444444444444}")
# _NAN = float("nan")
# METADATA_INSTANCES_COUNT = prometheus_client.Gauge(
#     "bg_metadata_instances_count", "Number of metadata actively used"
# )
#     _STR_RE = re.compile(
#         r"^(?P<points>[\d]+)\*(?P<precision>[\d]+)s(?P<type>(_0|_aggr))?$"
#     )
#     _DEFAULT_AGGREGATOR = Aggregator.average
#     _DEFAULT_RETENTION = Retention.from_string("86400*1s:10080*60s")
#     _DEFAULT_XFILESFACTOR = 0.5
#     _XFILESFACTOR_PRECISION = 2
# class Error(Exception):
# class InvalidArgumentError(Error):
# class Metric(object):
# class Aggregator(enum.Enum):
# class Stage(object):
# class Retention(object):
# class MetricMetadata(object):
#     def __init__(
#         self, name, id, metadata, created_on=None, updated_on=None, read_on=None
#     ):
#     def as_string_dict(self):
#     def __getattr__(self, name):
#     def __dir__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# def encode_metric_name(name):
# def make_metric_with_defaults(
#     name, metadata, created_on=None, updated_on=None, read_on=None
# ):
# def make_metric(name, metadata, created_on, updated_on, read_on):
# def sanitize_metric_name(name):
# def _components_from_name(metric_name):
#     def __init__(self, carbon_name):
#     def merge(self, values=[], counts=[], newest_first=False):
#     def _merge_average(self, values, counts, values_newest_first):
#     def _merge_last(self, values, counts, values_newest_first):
#     def _merge_maximum(self, values, counts, values_newest_first):
#     def _merge_minimum(self, values, counts, values_newest_first):
#     def _merge_total(self, values, counts, values_newest_first):
#     def aggregate(self, values=[], counts=[], newest_first=False):
#     def _aggregate_average(self, values, counts, values_newest_first):
#     def _aggregate_last(self, values, counts, values_newest_first):
#     def _aggregate_maximum(self, values, counts, values_newest_first):
#     def _aggregate_minimum(self, values, counts, values_newest_first):
#     def _aggregate_total(self, values, counts, values_newest_first):
#     def from_carbon_name(cls, name):
#     def carbon_name(self):
#     def from_config_name(cls, name):
#     def from_name(cls, name):
#     def __sum_and_count(values, counts):
#     def __min_and_max(values):
#     def __init__(self, points, precision, stage0=False):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def as_string(self):
#     def as_full_string(self):
#     def duration_ms(self):
#     def epoch(self, timestamp):
#     def from_string(cls, s):
#     def precision_ms(self):
#     def round_down(self, timestamp):
#     def round_up(self, timestamp):
#     def step(self, timestamp):
#     def step_ms(self, timestamp_ms):
#     def aggregated(self):
#     def __init__(self, stages):
#     def __getitem__(self, n):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def as_string(self):
#     def from_string(cls, string):
#     def duration(self):
#     def stage0(self):
#     def downsampled_stages(self):
#     def from_carbon(cls, elem):
#     def find_stage_for_ts(self, searched, now):
#     def align_time_window(self, start_time, end_time, now, shift=False):
#     def points(self):
#     def __init__(self, aggregator=None, retention=None, carbon_xfilesfactor=None):
#     def __setattr__(self, name, value):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def as_json(self):
#     def as_string_dict(self):
#     def create(cls, aggregator=None, retention=None, carbon_xfilesfactor=None):
#     def get_metadata_instances_count(cls):
#     def from_json(cls, s):
#     def from_string_dict(cls, d):


import abc
import logging
import os
import random
import sys
import threading
import time
import uuid
import cachetools
import lmdb
import prometheus_client
import six
from os import path as os_path
from biggraphite import metric as bg_metric
    @abc.abstractmethod
    def repair(
        self,
        start_key=None,
        end_key=None,
        shard=0,
        nshards=1,
        callback_on_progress=None,
    ):
        """Remove spurious entries from the cache.

        During the repair the keyspace is split in nshards and
        this function will only take care of 1/n th of the data
        as specified by shard. This allows the caller to parallelize
        the repair if needed.

        Args:
          start_key: string, start at key >= start_key.
          end_key: string, stop at key < end_key.
          shard: int, shard to repair.
          nshards: int, number of shards.
          callback_on_progress: callback function to track progress.
        """
        pass

    def metadata_from_str(self, metadata_str):
        """Create a MetricMetadata from a json string."""
        with self._json_cache_lock:
            metadata = self._json_cache.get(metadata_str)
            if not metadata:

# Path: biggraphite/metric.py
# _UTF8_CODEC = codecs.getencoder("utf8")
# _UUID_NAMESPACE = uuid.UUID("{00000000-1111-2222-3333-444444444444}")
# _NAN = float("nan")
# METADATA_INSTANCES_COUNT = prometheus_client.Gauge(
#     "bg_metadata_instances_count", "Number of metadata actively used"
# )
#     _STR_RE = re.compile(
#         r"^(?P<points>[\d]+)\*(?P<precision>[\d]+)s(?P<type>(_0|_aggr))?$"
#     )
#     _DEFAULT_AGGREGATOR = Aggregator.average
#     _DEFAULT_RETENTION = Retention.from_string("86400*1s:10080*60s")
#     _DEFAULT_XFILESFACTOR = 0.5
#     _XFILESFACTOR_PRECISION = 2
# class Error(Exception):
# class InvalidArgumentError(Error):
# class Metric(object):
# class Aggregator(enum.Enum):
# class Stage(object):
# class Retention(object):
# class MetricMetadata(object):
#     def __init__(
#         self, name, id, metadata, created_on=None, updated_on=None, read_on=None
#     ):
#     def as_string_dict(self):
#     def __getattr__(self, name):
#     def __dir__(self):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# def encode_metric_name(name):
# def make_metric_with_defaults(
#     name, metadata, created_on=None, updated_on=None, read_on=None
# ):
# def make_metric(name, metadata, created_on, updated_on, read_on):
# def sanitize_metric_name(name):
# def _components_from_name(metric_name):
#     def __init__(self, carbon_name):
#     def merge(self, values=[], counts=[], newest_first=False):
#     def _merge_average(self, values, counts, values_newest_first):
#     def _merge_last(self, values, counts, values_newest_first):
#     def _merge_maximum(self, values, counts, values_newest_first):
#     def _merge_minimum(self, values, counts, values_newest_first):
#     def _merge_total(self, values, counts, values_newest_first):
#     def aggregate(self, values=[], counts=[], newest_first=False):
#     def _aggregate_average(self, values, counts, values_newest_first):
#     def _aggregate_last(self, values, counts, values_newest_first):
#     def _aggregate_maximum(self, values, counts, values_newest_first):
#     def _aggregate_minimum(self, values, counts, values_newest_first):
#     def _aggregate_total(self, values, counts, values_newest_first):
#     def from_carbon_name(cls, name):
#     def carbon_name(self):
#     def from_config_name(cls, name):
#     def from_name(cls, name):
#     def __sum_and_count(values, counts):
#     def __min_and_max(values):
#     def __init__(self, points, precision, stage0=False):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def as_string(self):
#     def as_full_string(self):
#     def duration_ms(self):
#     def epoch(self, timestamp):
#     def from_string(cls, s):
#     def precision_ms(self):
#     def round_down(self, timestamp):
#     def round_up(self, timestamp):
#     def step(self, timestamp):
#     def step_ms(self, timestamp_ms):
#     def aggregated(self):
#     def __init__(self, stages):
#     def __getitem__(self, n):
#     def __hash__(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def as_string(self):
#     def from_string(cls, string):
#     def duration(self):
#     def stage0(self):
#     def downsampled_stages(self):
#     def from_carbon(cls, elem):
#     def find_stage_for_ts(self, searched, now):
#     def align_time_window(self, start_time, end_time, now, shift=False):
#     def points(self):
#     def __init__(self, aggregator=None, retention=None, carbon_xfilesfactor=None):
#     def __setattr__(self, name, value):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def as_json(self):
#     def as_string_dict(self):
#     def create(cls, aggregator=None, retention=None, carbon_xfilesfactor=None):
#     def get_metadata_instances_count(cls):
#     def from_json(cls, s):
#     def from_string_dict(cls, d):


# Path: biggraphite/metadata_cache.py
import abc
import logging
import os
import random
import sys
import threading
import time
import uuid
import cachetools
import lmdb
import prometheus_client
import six
from os import path as os_path
from biggraphite import metric as bg_metric

    @abc.abstractmethod
    def repair(
        self,
        start_key=None,
        end_key=None,
        shard=0,
        nshards=1,
        callback_on_progress=None,
    ):
        """Remove spurious entries from the cache.

        During the repair the keyspace is split in nshards and
        this function will only take care of 1/n th of the data
        as specified by shard. This allows the caller to parallelize
        the repair if needed.

        Args:
          start_key: string, start at key >= start_key.
          end_key: string, stop at key < end_key.
          shard: int, shard to repair.
          nshards: int, number of shards.
          callback_on_progress: callback function to track progress.
        """
        pass

    def metadata_from_str(self, metadata_str):
        """Create a MetricMetadata from a json string."""
        with self._json_cache_lock:
            metadata = self._json_cache.get(metadata_str)
            if not metadata:

                metadata = bg_metric.MetricMetadata.from_json(metadata_str)