/
IndexedGroupingSetsResultMulti.cs
66 lines (53 loc) · 2.47 KB
/
IndexedGroupingSetsResultMulti.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
namespace Explorer.Common
{
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text.Json;
using Diffix;
using Explorer.JsonExtensions;
public class IndexedGroupingSetsResultMulti<TIndex> : CountableRow
{
internal IndexedGroupingSetsResultMulti(ref Utf8JsonReader reader, ImmutableArray<TIndex> groupingLabels)
{
int groupingId;
(groupingId, Values) = reader.ParseMultiGroupingSet(groupingLabels.Length);
Count = reader.ParseCount();
CountNoise = reader.ParseCountNoise();
AllGroupingLabels = groupingLabels;
ColumnGrouping = new ColumnGrouping(groupingLabels.Length, groupingId);
}
public int GroupingId => ColumnGrouping.GroupingId;
public ImmutableArray<DValue<JsonElement>> Values { get; }
public long Count { get; }
public double? CountNoise { get; }
public IEnumerable<TIndex> GroupingLabels => ColumnGrouping.Indices.Select(i => AllGroupingLabels[i]);
public ImmutableArray<int> GroupingIndices => ColumnGrouping.Indices;
public ColumnGrouping ColumnGrouping { get; }
/// <summary>
/// Gets a value indicating whether the row should be considered `null`. The row is considered null if *all*
/// columns are null.
/// <para>
/// Rationale:
/// Null is like nothing.
/// If all columns have nothing, then the row has nothing.
/// But if any column has something (not null) then the row has something.
/// </para>
/// </summary>
/// <returns><c>true</c> if all columns are null, otherwise <c>false</c>.</returns>
public bool IsNull => Values.All(v => v.IsNull);
/// <summary>
/// Gets a value indicating whether the row should be considered suppressed. The row is considered suppressed
/// if *any* column is suppressed.
/// <para>
/// Rationale:
/// Suppressed values are uncertain.
/// If any column is uncertain than that makes the row uncertain.
/// Only if all columns are certain (not suppressed) can the row be considered certain.
/// </para>
/// </summary>
/// <returns><c>true</c> if any column is suppressed, otherwise <c>false</c>.</returns>
public bool IsSuppressed => Values.Any(v => v.IsSuppressed);
private ImmutableArray<TIndex> AllGroupingLabels { get; }
}
}