Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UInt64Storage.cs
Go to the documentation of this file.
3using System.Xml;
4
5namespace System.Data.Common;
6
7internal sealed class UInt64Storage : DataStorage
8{
9 private ulong[] _values;
10
13 {
14 }
15
16 public override object Aggregate(int[] records, AggregateType kind)
17 {
18 bool flag = false;
19 try
20 {
21 switch (kind)
22 {
23 case AggregateType.Sum:
24 {
25 ulong num15 = 0uL;
26 foreach (int num16 in records)
27 {
28 if (HasValue(num16))
29 {
31 flag = true;
32 }
33 }
34 if (flag)
35 {
36 return num15;
37 }
38 return _nullValue;
39 }
40 case AggregateType.Mean:
41 {
42 decimal num7 = default(decimal);
43 int num8 = 0;
44 foreach (int num9 in records)
45 {
46 if (HasValue(num9))
47 {
48 num7 += (decimal)_values[num9];
49 num8++;
50 flag = true;
51 }
52 }
53 if (flag)
54 {
55 ulong num10 = (ulong)(num7 / (decimal)num8);
56 return num10;
57 }
58 return _nullValue;
59 }
60 case AggregateType.Var:
61 case AggregateType.StDev:
62 {
63 int num = 0;
64 double num2 = 0.0;
65 double num3 = 0.0;
66 double num4 = 0.0;
67 double num5 = 0.0;
68 foreach (int num6 in records)
69 {
70 if (HasValue(num6))
71 {
72 num4 += (double)_values[num6];
73 num5 += (double)_values[num6] * (double)_values[num6];
74 num++;
75 }
76 }
77 if (num > 1)
78 {
79 num2 = (double)num * num5 - num4 * num4;
80 num3 = num2 / (num4 * num4);
81 num2 = ((!(num3 < 1E-15) && !(num2 < 0.0)) ? (num2 / (double)(num * (num - 1))) : 0.0);
82 if (kind == AggregateType.StDev)
83 {
84 return Math.Sqrt(num2);
85 }
86 return num2;
87 }
88 return _nullValue;
89 }
90 case AggregateType.Min:
91 {
92 ulong num13 = ulong.MaxValue;
93 foreach (int num14 in records)
94 {
95 if (HasValue(num14))
96 {
98 flag = true;
99 }
100 }
101 if (flag)
102 {
103 return num13;
104 }
105 return _nullValue;
106 }
107 case AggregateType.Max:
108 {
109 ulong num11 = 0uL;
110 foreach (int num12 in records)
111 {
112 if (HasValue(num12))
113 {
115 flag = true;
116 }
117 }
118 if (flag)
119 {
120 return num11;
121 }
122 return _nullValue;
123 }
124 case AggregateType.First:
125 if (records.Length != 0)
126 {
127 return _values[records[0]];
128 }
129 return null;
130 case AggregateType.Count:
131 return base.Aggregate(records, kind);
132 }
133 }
134 catch (OverflowException)
135 {
136 throw ExprException.Overflow(typeof(ulong));
137 }
139 }
140
141 public override int Compare(int recordNo1, int recordNo2)
142 {
143 ulong num = _values[recordNo1];
144 ulong num2 = _values[recordNo2];
145 if (num.Equals(0uL) || num2.Equals(0uL))
146 {
148 if (num3 != 0)
149 {
150 return num3;
151 }
152 }
153 if (num >= num2)
154 {
155 if (num <= num2)
156 {
157 return 0;
158 }
159 return 1;
160 }
161 return -1;
162 }
163
164 public override int CompareValueTo(int recordNo, object value)
165 {
166 if (_nullValue == value)
167 {
168 if (!HasValue(recordNo))
169 {
170 return 0;
171 }
172 return 1;
173 }
174 ulong num = _values[recordNo];
175 if (num == 0L && !HasValue(recordNo))
176 {
177 return -1;
178 }
179 return num.CompareTo((ulong)value);
180 }
181
182 public override object ConvertValue(object value)
183 {
184 if (_nullValue != value)
185 {
186 value = ((value == null) ? _nullValue : ((object)((IConvertible)value).ToUInt64(base.FormatProvider)));
187 }
188 return value;
189 }
190
191 public override void Copy(int recordNo1, int recordNo2)
192 {
195 }
196
197 public override object Get(int record)
198 {
199 ulong num = _values[record];
200 if (!num.Equals(0uL))
201 {
202 return num;
203 }
204 return GetBits(record);
205 }
206
207 public override void Set(int record, object value)
208 {
209 if (_nullValue == value)
210 {
211 _values[record] = 0uL;
212 SetNullBit(record, flag: true);
213 }
214 else
215 {
216 _values[record] = ((IConvertible)value).ToUInt64(base.FormatProvider);
217 SetNullBit(record, flag: false);
218 }
219 }
220
221 public override void SetCapacity(int capacity)
222 {
223 ulong[] array = new ulong[capacity];
224 if (_values != null)
225 {
227 }
228 _values = array;
229 base.SetCapacity(capacity);
230 }
231
232 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
233 public override object ConvertXmlToObject(string s)
234 {
235 return XmlConvert.ToUInt64(s);
236 }
237
238 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
239 public override string ConvertObjectToXml(object value)
240 {
241 return XmlConvert.ToString((ulong)value);
242 }
243
244 protected override object GetEmptyStorage(int recordCount)
245 {
246 return new ulong[recordCount];
247 }
248
249 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
250 {
251 ulong[] array = (ulong[])store;
254 }
255
256 protected override void SetStorage(object store, BitArray nullbits)
257 {
258 _values = (ulong[])store;
260 }
261}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void SetNullStorage(BitArray nullbits)
int CompareBits(int recordNo1, int recordNo2)
bool HasValue(int recordNo)
void SetNullBit(int recordNo, bool flag)
void CopyBits(int srcRecordNo, int dstRecordNo)
object GetBits(int recordNo)
override int CompareValueTo(int recordNo, object value)
override string ConvertObjectToXml(object value)
override object GetEmptyStorage(int recordCount)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override void Set(int record, object value)
override object ConvertValue(object value)
override object ConvertXmlToObject(string s)
override void Copy(int recordNo1, int recordNo2)
override int Compare(int recordNo1, int recordNo2)
override void SetCapacity(int capacity)
override void SetStorage(object store, BitArray nullbits)
override object Aggregate(int[] records, AggregateType kind)
override object Get(int record)
static Exception AggregateException(AggregateType aggregateType, Type type)
static Exception Overflow(Type type)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sqrt(double d)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static string ToString(bool value)
static ulong ToUInt64(string s)