コード例 #1
0
ファイル: pip.go プロジェクト: missinglink/go-whosonfirst-pip
func (p WOFPointInPolygon) LoadPolygonsForFeature(feature *geojson.WOFFeature) ([]*geojson.WOFPolygon, error) {

	id := feature.Id()

	polygons := feature.GeomToPolygons()
	var points int

	for _, pl := range polygons {
		points += pl.CountPoints()
	}

	p.Logger.Debug("%d has %d points", id, points)

	if points >= p.CacheTrigger {

		p.Logger.Debug("caching %d because it has E_EXCESSIVE_POINTS (%d)", id, points)

		var c metrics.Counter
		c = *p.Metrics.CountCacheSet

		evicted := p.Cache.Add(id, polygons)

		if evicted == true {

			cache_size := p.CacheSize
			cache_set := c.Count()

			p.Logger.Warning("starting to push thing out of the cache %d sets on a cache size of %d", cache_set, cache_size)
		}

		go c.Inc(1)
	}

	return polygons, nil
}
コード例 #2
0
func dumpCounter(name string, metric gometrics.Counter) {
	logger.WithFields(logrus.Fields{
		"name":  name,
		"count": metric.Count(),
	}).Info()
}
コード例 #3
0
func (r *reporter) reportCounter(name string, val metrics.Counter) {
	r.reportMetric(name, Int, val.Count())
}