public virtual Serie PointToSerie(Point point) { var serie = new Serie { Name = point.Name }; foreach (var key in point.Tags.Keys.ToList()) { serie.Tags.Add(key, point.Tags[key].ToString()); } var sortedFields = point.Fields.OrderBy(k => k.Key).ToDictionary(x => x.Key, x => x.Value); serie.Columns = new string[] { "time" }.Concat(sortedFields.Keys).ToArray(); serie.Values = new object[][] { new object[] { point.Timestamp }.Concat(sortedFields.Values).ToArray() }; return serie; }
private void CleanUpSensorSerial(Serie serie) { serie.Name = serie.Name.Substring(serie.Name.LastIndexOf('.') + 1); }
public async Task<IList<Serie>> Query(Serie expected) { // 0.9.3 need 'group by' to retrieve tags as tags when using select * var result = await this.Sut.Client.QueryAsync(this.DbName, String.Format("select * from \"{0}\" group by *", expected.Name)); result.Should().NotBeNull(); result.Count().Should().Be(1); var actual = result.Single(); actual.Name.Should().Be(expected.Name); actual.Tags.Count.Should().Be(expected.Tags.Count); actual.Tags.ShouldAllBeEquivalentTo(expected.Tags); actual.Columns.ShouldAllBeEquivalentTo(expected.Columns); actual.Columns.Count().Should().Be(expected.Columns.Count()); actual.Values[0].Count().Should().Be(expected.Values[0].Count()); ((DateTime)actual.Values[0][0]).ToUnixTime().Should().Be(((DateTime)expected.Values[0][0]).ToUnixTime()); return result; }