public HaystackGrid() { Meta = new HaystackDictionary(); _columns = new List <HaystackColumn>(); _rows = new List <HaystackRow>(); _columnsByName = new Dictionary <string, HaystackColumn>(); }
public HaystackHistoryItem(HaystackDictionary dictionary) { if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); } TimeStamp = (HaystackDateTime)dictionary["ts"]; Value = dictionary.ContainsKey("val") ? dictionary["val"] : null; }
public HaystackGrid(HaystackDictionary[] rows, HaystackDictionary meta = null) { var columnNames = rows .SelectMany(row => row.Keys) .Distinct() .ToArray(); _columns = columnNames .Select((name, idx) => new HaystackColumn(idx, name)) .ToList(); _columnsByName = _columns.ToDictionary(col => col.Name); _rows = rows .Select(row => new HaystackRow(this, columnNames.Select(col => row.ContainsKey(col) ? row[col] : null).ToArray())) .ToList(); Meta = meta ?? new HaystackDictionary(); }
public static HDict Map(HaystackDictionary value) { return(new HDict(value)); }
public HaystackGrid(HaystackHistoryItem[] historyItems, HaystackDictionary meta = null) { _columns = new[] { new HaystackColumn(0, "ts"), new HaystackColumn(1, "val") }.ToList(); _rows = historyItems.Select(item => new HaystackRow(this, item.TimeStamp, item.Value)).ToList(); Meta = meta ?? new HaystackDictionary(); }
public HaystackGrid(List <HaystackColumn> columns, List <HaystackValue[]> rowData, HaystackDictionary meta = null) { var duplicates = columns .GroupBy(col => col.Name) .Where(grp => grp.Count() > 1) .Select(grp => grp.Key) .ToArray(); if (duplicates.Any()) { throw new ArgumentException($"Detected duplicate column(s): {string.Join(", ", duplicates)}"); } _columns = columns; _columnsByName = _columns.ToDictionary(col => col.Name); _rows = rowData.Select(row => new HaystackRow(this, row)).ToList(); Meta = meta ?? new HaystackDictionary(); }
public HDict(HaystackDictionary source) { Source = source; }
public HDict(IDictionary <string, HVal> map) { Source = new HaystackDictionary(map.ToDictionary(kv => kv.Key, kv => M.Map(kv.Value))); }