'Handle a sample, converting if necessary.'

def handle_sample(self, s):

    key = (s.name + s.resource_id)
    prev = self.cache.get(key)
    timestamp = timeutils.parse_isotime(s.timestamp)
    self.cache[key] = (s.volume, timestamp)
    if prev:
        prev_volume = prev[0]
        prev_timestamp = prev[1]
        time_delta = timeutils.delta_seconds(prev_timestamp, timestamp)
        if (time_delta < 0):
            LOG.warning('Dropping    out    of    time    order    sample:    %s', (s,))
            self.cache[key] = prev
            return None
        volume_delta = (s.volume - prev_volume)
        if (self.growth_only and (volume_delta < 0)):
            LOG.warning('Negative    delta    detected,    dropping    value')
            s = None
        else:
            s = self._convert(s, volume_delta)
            LOG.debug('Converted    to:    %s', s)
    else:
        LOG.warning('Dropping    sample    with    no    predecessor:    %s', (s,))
        s = None
    return s
