public void Save (AggregatedValue val)
        {
            MongoCollection<BsonDocument> items = MongoDb.GetCollection("countersData");
            UpdateBuilder updateBuilder = new UpdateBuilder();
            if (val.Count.HasValue)
                updateBuilder.Inc("data.Count", val.Count.Value);
            if (val.Sum.HasValue)
                updateBuilder.Inc("data.Sum", val.Sum.Value);
            if (val.Min.HasValue)
                updateBuilder.Push("data.Min", val.Min.Value);
            if (val.Max.HasValue)
                updateBuilder.Push("data.Max", val.Max.Value);
            if (val.Avg.HasValue)
                updateBuilder.Push("data.Avg", val.Avg.Value);
            if (val.Percentiles!=null || val.DistributionGroups!=null)
                updateBuilder.PushAll("data.Raw", val.RawValues.Select(v =>new BsonDouble(v)));

            IMongoQuery q = Query.And(Query.EQ("date", val.Date), Query.EQ("props.pCnt", val.Props.Count));
            foreach (var prop in val.Props)
            {
                q = Query.And(q, Query.EQ("props."+prop.Key, prop.Value));
            }
            items.Update(q, updateBuilder,UpdateFlags.Upsert,SafeMode.True);
        }