cleanup: Fix more build warnings in DataStreamSuite
Alot more
This commit is contained in:
1 parent
989d103eef
commit
bcd207f89e
118 files changed
+1812
-1597
No files matched your search
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System.Collections;
|
||||
|
||||
namespace BCG
|
||||
@@ -10,14 +10,7 @@ namespace BCG
|
||||
public class BlueRowDictionaryEnumerator : BlueRowEnumerator, IDictionaryEnumerator
|
||||
{
|
||||
public BlueRowDictionaryEnumerator (IBlueRow row) : base (row) {}
|
||||
public override object Current {get{return Entry;}}
|
||||
|
||||
#region IDictionaryEnumerator members
|
||||
public object Key {get{return myRow.schema[myPos].colName;}}
|
||||
|
||||
public object Value {get{return myRow[myPos];}}
|
||||
|
||||
public DictionaryEntry Entry {get{return new DictionaryEntry (Key, Value);}}
|
||||
#endregion
|
||||
public override object? Current => Entry;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BCG.Utilities.General;
|
||||
|
||||
using Spark.Core.Collections;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BCG {
|
||||
/// <summary>
|
||||
/// The BlueTableSchema is an immutable schema holder. Once created it cannot be modified. It can be created
|
||||
@@ -117,7 +118,7 @@ namespace BCG {
|
||||
// }
|
||||
}
|
||||
|
||||
protected Hashtable myIndexByColName = new Hashtable();
|
||||
protected Dictionary<string, ColumnInfo> myIndexByColName = new();
|
||||
protected ColumnInfo[] myIndexByColOrder;
|
||||
private string[] myTableColNames;
|
||||
protected string myTableName;
|
||||
@@ -187,18 +188,8 @@ namespace BCG {
|
||||
/// <summary>
|
||||
/// The returned Array is sorted according to the Column No
|
||||
/// </summary>
|
||||
public string[] columnNames {
|
||||
get {
|
||||
if (myTableColNames == null) {
|
||||
myTableColNames = new string[myIndexByColName.Count];
|
||||
foreach (DictionaryEntry de in myIndexByColName) {
|
||||
ColumnInfo temp = (ColumnInfo)de.Value;
|
||||
myTableColNames[temp.colNo] = temp.colName;
|
||||
}
|
||||
}
|
||||
return myTableColNames;
|
||||
}
|
||||
}
|
||||
public string[] columnNames =>
|
||||
myTableColNames ??= myIndexByColName.Values.ToIndexedArray(c => (c.colNo, c.colName));
|
||||
|
||||
/// <summary>
|
||||
/// The returned Array is sorted according to the Column No
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -6,10 +7,10 @@ namespace BCG {
|
||||
/// Resprsents information about a column schema, ie its ordinal, the type, the name and constant value or expression. where applicable
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ColumnInfo : IComparable {
|
||||
public class ColumnInfo : IComparable<ColumnInfo>, IComparable, IEquatable<ColumnInfo> {
|
||||
|
||||
//the default column info does not cach values in a lookup table, therefore it is in group 0
|
||||
public ColumnInfo(string colName, int colNo, Type colType, object colValue = null) {
|
||||
public ColumnInfo(string colName, int colNo, Type colType, object? colValue = null) {
|
||||
myColName = colName;
|
||||
myColNo = colNo;
|
||||
myColType = colType;
|
||||
@@ -27,8 +28,14 @@ namespace BCG {
|
||||
type == typeof(string) ||
|
||||
type == typeof(DateTime);
|
||||
|
||||
public int CompareTo(object obj) {
|
||||
int otherColNo = ((ColumnInfo)(obj)).colNo;
|
||||
public int CompareTo(object? obj) =>
|
||||
CompareTo(obj as ColumnInfo);
|
||||
|
||||
public int CompareTo(ColumnInfo? other) {
|
||||
if (other is null) {
|
||||
return 1;
|
||||
}
|
||||
int otherColNo = other.colNo;
|
||||
if (myColNo < otherColNo)
|
||||
return -1;
|
||||
else if (myColNo > otherColNo)
|
||||
@@ -36,18 +43,21 @@ namespace BCG {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
if (obj is ColumnInfo) {
|
||||
ColumnInfo other = obj as ColumnInfo;
|
||||
return (colNo == other.colNo) && (colName == other.colName) && (colType == other.colType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public override bool Equals(object? obj) =>
|
||||
Equals(obj as ColumnInfo);
|
||||
|
||||
public bool Equals(ColumnInfo? other) =>
|
||||
other is not null
|
||||
&& colNo == other.colNo
|
||||
&& colName == other.colName
|
||||
&& colType == other.colType;
|
||||
|
||||
public override string ToString() {
|
||||
return colName + " " + colNo + " " + colType;
|
||||
}
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(colNo, colName, colType);
|
||||
|
||||
// for backwards compatibility to allow build
|
||||
public bool isConstant {get{return myColValue != null;}}
|
||||
@@ -55,7 +65,7 @@ namespace BCG {
|
||||
private int myColNo;
|
||||
private string myColName;
|
||||
private Type myColType;
|
||||
private object myColValue;
|
||||
private object? myColValue;
|
||||
|
||||
[JsonPropertyName("colNo")]
|
||||
public int colNo { get { return myColNo; } }
|
||||
@@ -67,6 +77,6 @@ namespace BCG {
|
||||
public Type colType { get { return myColType; } }
|
||||
|
||||
[JsonIgnore]
|
||||
public object colValue {get{return myColValue;}}
|
||||
public object? colValue {get{return myColValue;}}
|
||||
}
|
||||
}
|
||||
+53
-42
@@ -1,24 +1,39 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using BCG;
|
||||
using System.Collections;
|
||||
|
||||
using Spark.Core.Collections;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
// common place for all serialization interfaces
|
||||
|
||||
namespace bts {
|
||||
// this is the data that is sent across the write for stream IO
|
||||
public class StreamIOMessage {
|
||||
public class StreamIOMessage : IEquatable<StreamIOMessage> {
|
||||
public enum StreamOp {
|
||||
CREATE = 0,
|
||||
// removes and adds multiple rows
|
||||
// other operations can be expressed with this
|
||||
MULTIPLE_REMOVE_ADD = 1,
|
||||
}
|
||||
public class CreateMessage {
|
||||
|
||||
public class CreateMessage : IEquatable<CreateMessage> {
|
||||
public IBlueRowCollection rows;
|
||||
public CreateMessage(IBlueRowCollection rows_) {
|
||||
rows = rows_;
|
||||
}
|
||||
|
||||
public bool Equals(CreateMessage? other) =>
|
||||
other is not null
|
||||
&& BlueDataUtility.compute_equality(rows, other.rows);
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
Equals(obj as CreateMessage);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
rows.Count;
|
||||
|
||||
public override string ToString() {
|
||||
string rv = "Create message ";
|
||||
if (rows == null) {
|
||||
@@ -30,21 +45,27 @@ namespace bts {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public override bool Equals(object obj) {
|
||||
if (obj != null && obj is CreateMessage) {
|
||||
var other = obj as CreateMessage;
|
||||
return BlueDataUtility.compute_equality(rows, other.rows);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public class MultipleRemoveAddMessage {
|
||||
|
||||
public class MultipleRemoveAddMessage : IEquatable<MultipleRemoveAddMessage> {
|
||||
public IBlueRowCollection removed_rows;
|
||||
public IBlueRowCollection added_rows;
|
||||
public MultipleRemoveAddMessage(IBlueRowCollection removed_rows_, IBlueRowCollection added_rows_) {
|
||||
removed_rows = removed_rows_;
|
||||
added_rows = added_rows_;
|
||||
}
|
||||
|
||||
public bool Equals(MultipleRemoveAddMessage? other) =>
|
||||
other is not null
|
||||
&& BlueDataUtility.compute_equality(removed_rows, other.removed_rows)
|
||||
&& BlueDataUtility.compute_equality(added_rows, other.added_rows);
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
Equals(obj as MultipleRemoveAddMessage);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(removed_rows.Count, added_rows.Count);
|
||||
|
||||
public override string ToString() {
|
||||
string rv = "MultipleRemoveAdd removed: ";
|
||||
foreach (IBlueRow r in removed_rows) {
|
||||
@@ -56,56 +77,46 @@ namespace bts {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public override bool Equals(object obj) {
|
||||
if (obj != null && obj is MultipleRemoveAddMessage) {
|
||||
MultipleRemoveAddMessage other = obj as MultipleRemoveAddMessage;
|
||||
return BlueDataUtility.compute_equality(removed_rows, other.removed_rows) &&
|
||||
BlueDataUtility.compute_equality(added_rows, other.added_rows);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public StreamOp op;
|
||||
public readonly CreateMessage create_message = null;
|
||||
public readonly MultipleRemoveAddMessage multiple_remove_add_message = null;
|
||||
public readonly CreateMessage? create_message;
|
||||
public readonly MultipleRemoveAddMessage? multiple_remove_add_message;
|
||||
|
||||
public StreamIOMessage(CreateMessage create_message_) {
|
||||
op = StreamOp.CREATE;
|
||||
create_message = create_message_;
|
||||
multiple_remove_add_message = null;
|
||||
}
|
||||
|
||||
public StreamIOMessage(MultipleRemoveAddMessage multiple_remove_add_message_) {
|
||||
op = StreamOp.MULTIPLE_REMOVE_ADD;
|
||||
create_message = null;
|
||||
multiple_remove_add_message = multiple_remove_add_message_;
|
||||
}
|
||||
|
||||
public bool Equals(StreamIOMessage? other) =>
|
||||
other is not null
|
||||
&& op == other.op
|
||||
&& op switch {
|
||||
StreamOp.CREATE => NullCheckEqualityComparer.Equals(create_message, other.create_message),
|
||||
StreamOp.MULTIPLE_REMOVE_ADD => NullCheckEqualityComparer.Equals(multiple_remove_add_message, other.multiple_remove_add_message),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
Equals(obj as StreamIOMessage);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(op, create_message, multiple_remove_add_message);
|
||||
|
||||
public override string ToString() {
|
||||
switch (op) {
|
||||
case StreamIOMessage.StreamOp.CREATE:
|
||||
return create_message.ToString();
|
||||
return create_message?.ToString() ?? string.Empty;
|
||||
case StreamIOMessage.StreamOp.MULTIPLE_REMOVE_ADD:
|
||||
return multiple_remove_add_message.ToString();
|
||||
return multiple_remove_add_message?.ToString() ?? string.Empty;
|
||||
}
|
||||
bts.Log.assert(false);
|
||||
return String.Empty;
|
||||
}
|
||||
public override bool Equals(object obj) {
|
||||
if (obj != null && obj is StreamIOMessage) {
|
||||
StreamIOMessage other = obj as StreamIOMessage;
|
||||
if (op == other.op) {
|
||||
switch (op) {
|
||||
case StreamOp.CREATE:
|
||||
return create_message.Equals(other.create_message);
|
||||
case StreamOp.MULTIPLE_REMOVE_ADD:
|
||||
return multiple_remove_add_message.Equals(other.multiple_remove_add_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#region serialization
|
||||
// This helps putting stream callbacks (op + data) on the wire, to send it to the pubsubserver.
|
||||
@@ -134,4 +145,4 @@ namespace bts {
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
+15
-10
@@ -1,12 +1,10 @@
|
||||
#nullable enable
|
||||
namespace bts {
|
||||
using BCG;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
|
||||
public static class StreamSerializationUtils {
|
||||
@@ -122,17 +120,24 @@ namespace bts {
|
||||
}
|
||||
|
||||
public static object deserialize_column(ref BinaryReader br, Type t) {
|
||||
Func<BinaryReader, object> reader_func;
|
||||
Log.assert(_col_deser_map.TryGetValue(t, out reader_func));
|
||||
return reader_func(br);
|
||||
if (_col_deser_map.TryGetValue(t, out var deserialize)) {
|
||||
return deserialize(br);
|
||||
}
|
||||
var msg = $"Deserialization function not defined for type '{t}'";
|
||||
Log.assert(false, msg);
|
||||
throw new ArgumentException(msg, nameof(t));
|
||||
}
|
||||
|
||||
public static void serialize_row_column(BinaryWriter bw, IBlueRow r, int col_no) {
|
||||
var ci = r.schema.columnInfo[col_no];
|
||||
var type = ci.colType;
|
||||
Action<BinaryWriter, IBlueRow, int> ser_action;
|
||||
Log.assert(_col_ser_map.TryGetValue(type, out ser_action));
|
||||
ser_action(bw, r, col_no);
|
||||
if (_col_ser_map.TryGetValue(type, out var serialize)) {
|
||||
serialize(bw, r, col_no);
|
||||
return;
|
||||
}
|
||||
var msg = $"Serialization function not defined for type '{type}' (failed on column '{ci.colName}')";
|
||||
Log.assert(false, msg);
|
||||
throw new ArgumentException(msg, nameof(r));
|
||||
}
|
||||
|
||||
public static ColumnInfo deserialize_column_info(ref BinaryReader br) {
|
||||
@@ -226,4 +231,4 @@ namespace bts {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user