refactor: Replace DataPacket w/ IDataPacket in many places

This commit is contained in:
John Colvin committed 2026-01-11 11:20:40 -05:00
1 parent 49a952fb32
commit 03a8f4e9c0
64 files changed
+191 -200

No files matched your search

@@ -288,14 +288,17 @@ namespace BCG {
}
}
public static DataPacket build_dp(IBlueRowCollection new_rows, DataPacket last_fired_dp) {
public static DataPacket build_dp(IBlueRowCollection new_rows, IDataPacket last_fired_dp) {
IBlueRowCollection added_rows = new_rows;
IBlueRowCollection deleted_rows = last_fired_dp == null ? new BlueTable(new_rows.schema) : last_fired_dp.newRows;
return new DataPacket(new_rows, added_rows, deleted_rows);
}
public static DataPacket build_dp_inc(IBlueRowCollection new_rows, DataPacket last_fired_dp, bool deep_row_comapre = false) {
if (last_fired_dp == null) {
public static DataPacket build_dp_inc(IBlueRowCollection new_rows, IDataPacket last_fired_dp, bool deep_row_comapre = false) =>
build_dp_inc(new_rows, last_fired_dp.newRows, deep_row_comapre);
public static DataPacket build_dp_inc(IBlueRowCollection new_rows, IBlueRowCollection lastRows, bool deep_row_comapre = false) {
if (lastRows is null) {
IBlueRowCollection added_rows = new_rows;
IBlueRowCollection deleted_rows = new BlueTable(new_rows.schema);
return new DataPacket(new_rows, added_rows, deleted_rows);
@@ -303,9 +306,9 @@ namespace BCG {
IBlueRowCollection added_rows = null;
IBlueRowCollection deleted_rows = null;
if (deep_row_comapre)
compute_differences_fast(new_rows, last_fired_dp.newRows, out deleted_rows, out added_rows);
compute_differences_fast(new_rows, lastRows, out deleted_rows, out added_rows);
else
compute_differences_id_based(new_rows, last_fired_dp.newRows, out deleted_rows, out added_rows);
compute_differences_id_based(new_rows, lastRows, out deleted_rows, out added_rows);
return new DataPacket(new_rows, added_rows, deleted_rows);
}
}
@@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
public class DataPacketEqualityComparer : IEqualityComparer<DataPacket?> {
public class DataPacketEqualityComparer : IEqualityComparer<IDataPacket?> {
readonly IEqualityComparer<IBlueRowCollection> rowCollectionComparer;
public DataPacketEqualityComparer(IEqualityComparer<IBlueRowCollection>? rowCollectionComparer = null) =>
@@ -16,20 +16,20 @@ public class DataPacketEqualityComparer : IEqualityComparer<DataPacket?> {
public static DataPacketEqualityComparer Instance { get; } = new();
public bool Equals(DataPacket? x, DataPacket? y) {
public bool Equals(IDataPacket? x, IDataPacket? y) {
if (x is null) {
return y is null;
}
return y is not null
&& x.schema.columnInfo.SequenceEqual(y.schema.columnInfo)
&& x.Schema.columnInfo.SequenceEqual(y.Schema.columnInfo)
&& rowCollectionComparer.Equals(x.addedRows, y.addedRows)
&& rowCollectionComparer.Equals(x.deletedRows, y.deletedRows)
&& rowCollectionComparer.Equals(x.newRows, y.newRows);
}
public int GetHashCode([DisallowNull] DataPacket obj) {
public int GetHashCode([DisallowNull] IDataPacket obj) {
var hash = new HashCode();
hash.Add(obj.schema.columnNames.Length);
hash.Add(obj.Schema.columnNames.Length);
hash.Add(obj.addedRows.Count);
hash.Add(obj.deletedRows.Count);
return hash.ToHashCode();
@@ -219,15 +219,15 @@ namespace BCG {
BlueTable at = null;
IBlueRowCollection nt = null;
foreach (DataPacket dp in packets) {
foreach (IDataPacket dp in packets) {
ArrayList oldDeleted = deleted;
ArrayList oldAdded = added;
added = new ArrayList();
deleted = new ArrayList();
if (dt == null) {
dt = new BlueTable(dp.schema);
at = new BlueTable(dp.schema);
dt = new BlueTable(dp.Schema);
at = new BlueTable(dp.Schema);
}
deleted.AddRange(oldDeleted);
@@ -331,7 +331,7 @@ namespace BCG {
// }
public static class DataPacketExtensions {
public static bool HasChanges(this DataPacket dataPacket) =>
public static bool HasChanges(this IDataPacket dataPacket) =>
dataPacket.addedRows.Count > 0 || dataPacket.deletedRows.Count > 0;
}
}
@@ -38,10 +38,8 @@ namespace BCG
return null;
else
{
return new DataPacket(
(myLastValue as DataPacket).newRows,
(myLastValue as DataPacket).newRows,
new BlueTable((myLastValue as DataPacket).newRows.schema));
var rows = ((IDataPacket)myLastValue).newRows;
return new DataPacket(rows, rows, new BlueTable(rows.schema));
}
}