Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AggregateNode.cs
Go to the documentation of this file.
3
4namespace System.Data;
5
6internal sealed class AggregateNode : ExpressionNode
7{
8 private readonly AggregateType _type;
9
10 private readonly Aggregate _aggregate;
11
12 private readonly bool _local;
13
14 private readonly string _relationName;
15
16 private readonly string _columnName;
17
19
21
23
28
30 : base(table)
31 {
33 switch (aggregateType)
34 {
35 case FunctionId.Sum:
36 _type = AggregateType.Sum;
37 break;
38 case FunctionId.Avg:
39 _type = AggregateType.Mean;
40 break;
41 case FunctionId.Min:
42 _type = AggregateType.Min;
43 break;
44 case FunctionId.Max:
45 _type = AggregateType.Max;
46 break;
47 case FunctionId.Count:
48 _type = AggregateType.Count;
49 break;
50 case FunctionId.Var:
51 _type = AggregateType.Var;
52 break;
53 case FunctionId.StDev:
54 _type = AggregateType.StDev;
55 break;
56 default:
58 }
59 _local = local;
62 }
63
64 internal override void Bind(DataTable table, List<DataColumn> list)
65 {
67 if (table == null)
68 {
70 }
71 if (_local)
72 {
73 _relation = null;
74 }
75 else
76 {
78 if (_relationName == null)
79 {
80 if (childRelations.Count > 1)
81 {
83 }
84 if (childRelations.Count != 1)
85 {
87 }
89 }
90 else
91 {
93 }
94 }
97 if (_column == null)
98 {
100 }
101 int i;
102 for (i = 0; i < list.Count; i++)
103 {
105 if (_column == dataColumn)
106 {
107 break;
108 }
109 }
110 if (i >= list.Count)
111 {
113 }
115 }
116
118 {
119 if (relation == null)
120 {
121 return;
122 }
123 DataColumn[] childColumnsReference = relation.ChildColumnsReference;
125 {
126 if (!list.Contains(item))
127 {
128 list.Add(item);
129 }
130 }
131 DataColumn[] parentColumnsReference = relation.ParentColumnsReference;
133 {
134 if (!list.Contains(item2))
135 {
136 list.Add(item2);
137 }
138 }
139 }
140
141 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
142 internal override object Eval()
143 {
144 return Eval(null, DataRowVersion.Default);
145 }
146
147 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
148 internal override object Eval(DataRow row, DataRowVersion version)
149 {
150 if (_childTable == null)
151 {
153 }
154 DataRow[] array;
155 if (_local)
156 {
159 }
160 else
161 {
162 if (row == null)
163 {
165 }
166 if (_relation == null)
167 {
169 }
170 array = row.GetChildRows(_relation, version);
171 }
172 if (version == DataRowVersion.Proposed)
173 {
174 version = DataRowVersion.Default;
175 }
176 List<int> list = new List<int>();
177 for (int i = 0; i < array.Length; i++)
178 {
179 if (array[i].RowState == DataRowState.Deleted)
180 {
181 if (DataRowAction.Rollback != array[i]._action)
182 {
183 continue;
184 }
185 version = DataRowVersion.Original;
186 }
187 else if (DataRowAction.Rollback == array[i]._action && array[i].RowState == DataRowState.Added)
188 {
189 continue;
190 }
191 if (version != DataRowVersion.Original || array[i]._oldRecord != -1)
192 {
193 list.Add(array[i].GetRecordFromVersion(version));
194 }
195 }
196 int[] records = list.ToArray();
198 }
199
200 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
201 internal override object Eval(int[] records)
202 {
203 if (_childTable == null)
204 {
206 }
207 if (!_local)
208 {
210 }
212 }
213
214 internal override bool IsConstant()
215 {
216 return false;
217 }
218
219 internal override bool IsTableConstant()
220 {
221 return _local;
222 }
223
224 internal override bool HasLocalAggregate()
225 {
226 return _local;
227 }
228
229 internal override bool HasRemoteAggregate()
230 {
231 return !_local;
232 }
233
234 internal override bool DependsOn(DataColumn column)
235 {
236 if (_column == column)
237 {
238 return true;
239 }
240 if (_column.Computed)
241 {
243 }
244 return false;
245 }
246
247 internal override ExpressionNode Optimize()
248 {
249 return this;
250 }
251}
void Add(TKey key, TValue value)
readonly Aggregate _aggregate
override bool HasLocalAggregate()
readonly string _relationName
override bool HasRemoteAggregate()
override bool IsTableConstant()
override ExpressionNode Optimize()
override bool DependsOn(DataColumn column)
static void Bind(DataRelation relation, List< DataColumn > list)
override object Eval(DataRow row, DataRowVersion version)
readonly string _columnName
override object Eval(int[] records)
readonly AggregateType _type
AggregateNode(DataTable table, FunctionId aggregateType, string columnName, bool local, string relationName)
AggregateNode(DataTable table, FunctionId aggregateType, string columnName)
override void Bind(DataTable table, List< DataColumn > list)
object GetAggregateValue(int[] records, AggregateType kind)
DataExpression? DataExpression
bool DependsOn(DataColumn column)
virtual DataTable ChildTable
override void CopyTo(Array ar, int index)
DataRowCollection Rows
Definition DataTable.cs:701
DataColumnCollection Columns
Definition DataTable.cs:327
DataRelationCollection ChildRelations
Definition DataTable.cs:324
static Exception UnresolvedRelation(string name, string expr)
static Exception UnboundName(string name)
static Exception ComputeNotAggregate(string expr)
static Exception UndefinedFunction(string name)
static Exception EvalNoContext()
static Exception AggregateUnbound(string expr)
void BindTable(DataTable table)
static string[] s_functionName
Definition Function.cs:19