public Task AppendAsync(DateTime timestamp, TValues value, string tag = null) { if (value is ICollection <double> doubles) { return(AppendAsyncInternal(timestamp, doubles, tag)); } var values = TimeSeriesValuesHelper.GetValues(value).ToArray(); return(AppendAsyncInternal(timestamp, values, tag)); }
public void Append <TValues>(DateTime timestamp, TValues value, string tag = null) { if (value is IEnumerable <double> doubles) { Append(timestamp, doubles, tag); return; } var values = TimeSeriesValuesHelper.GetValues(value); Append(timestamp, values, tag); }
/// <summary> /// Register value names of a time-series /// </summary> /// <typeparam name="TCollection">Collection type</typeparam> /// <typeparam name="TTimeSeriesEntry">Time-series type</typeparam> public Task RegisterAsync <TCollection, TTimeSeriesEntry>(string name = null) { name ??= GetTimeSeriesName <TTimeSeriesEntry>(_store.Conventions); var mapping = TimeSeriesValuesHelper.GetMembersMapping(typeof(TTimeSeriesEntry)); if (mapping == null) { throw new InvalidOperationException($"{typeof(TTimeSeriesEntry).Name} must contain {nameof(TimeSeriesValueAttribute)}."); } var collection = _store.Conventions.FindCollectionName(typeof(TCollection)); return(RegisterAsync(collection, name, mapping.Values.Select(f => f.Name).ToArray())); }
internal async Task <TimeSeriesEntry <TEntry>[]> GetTypedFromCache <TEntry>(DateTime?from, DateTime?to, Action <ITimeSeriesIncludeBuilder> includes, int start, int pageSize, CancellationToken token = default) where TEntry : new() { // RavenDB-16060 // Typed TimeSeries results need special handling when served from cache // since we cache the results untyped var resultToUser = await ServeFromCache(from ?? DateTime.MinValue, to ?? DateTime.MaxValue, start, pageSize, includes, token) .ConfigureAwait(false); var asList = resultToUser.ToList(); if (asList.Count == 0) { return(Array.Empty <TimeSeriesEntry <TEntry> >()); } var result = new TimeSeriesEntry <TEntry> [asList.Count]; for (var index = 0; index < asList.Count; index++) { var timeSeriesEntry = new TimeSeriesEntry <TEntry>(); var item = asList[index]; timeSeriesEntry.IsRollup = item.IsRollup; timeSeriesEntry.Timestamp = item.Timestamp; timeSeriesEntry.Tag = item.Tag; timeSeriesEntry.Value = TimeSeriesValuesHelper.SetMembers <TEntry>(item.Values, item.IsRollup); timeSeriesEntry.Values = item.Values; result[index] = timeSeriesEntry; } return(result); }