refactor: Replace DataPacket w/ IDataPacket in stream handlers

This commit also renames BlueTableSchemaAdaptor to BlueTableSchemaAdapter,
and makes it implement IBlueTableSchema.
This commit is contained in:
John Colvin committed 2025-11-19 00:36:56 -05:00
1 parent 770e14752a
commit 5080960b97
12 files changed
+461 -194

No files matched your search

@@ -1,12 +1,10 @@
using Spark.Core.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using BCG.Utilities.General;
using Bts.DataStreamCore;
namespace BCG {
[Serializable]
public class DataPacket : ICloneable, IDataPacket {
@@ -45,12 +43,20 @@ namespace BCG {
public IBlueRowCollection newRows, addedRows, deletedRows;
public IDictionary<string, object> meta_data = null;
public DataPacket() { }
public DataPacket(IBlueRowCollection newRows, IBlueRowCollection addedRows, IBlueRowCollection deletedRows) {
public DataPacket(IBlueTableSchema schema)
: this(new BlueTable(schema), new BlueTable(schema), new BlueTable(schema)) { }
public DataPacket (IBlueRowCollection newRows, IBlueRowCollection addedRows, IBlueRowCollection deletedRows) {
this.newRows = newRows;
this.addedRows = addedRows;
this.deletedRows = deletedRows;
}
IBlueRowCollection IDataPacket.newRows => newRows;
IBlueRowCollection IDataPacket.addedRows => addedRows;
IBlueRowCollection IDataPacket.deletedRows => deletedRows;
public void get_new_added_deleted(out ICollection new_rows, out ICollection added_rows, out ICollection deleted_rows) {
new_rows = newRows;
added_rows = addedRows;
@@ -282,23 +288,30 @@ namespace BCG {
}
}
public class DataPacket<T> : IDataPacket<T> where T : IBlueRow {
public DataPacket(IBlueRowCollection<T> newRows, IBlueRowCollection<T> addedRows, IBlueRowCollection<T> deletedRows) {
this.newRows = newRows;
this.addedRows = addedRows;
this.deletedRows = deletedRows;
}
// public class DataPacket<T> : IDataPacket<T> where T : IBlueRow {
// public DataPacket(
// IBlueRowCollection<T> newRows,
// IBlueRowCollection<T> addedRows,
// IBlueRowCollection<T> deletedRows,
// IReadOnlyDictionary<string, object> metadata = null
// ) {
// this.newRows = newRows;
// this.addedRows = addedRows;
// this.deletedRows = deletedRows;
// Metadata = metadata ?? DictionaryHelper.empty<string, object>();
// }
public IBlueRowCollection<T> newRows { get; }
public IBlueRowCollection<T> addedRows { get; }
public IBlueRowCollection<T> deletedRows { get; }
// public IBlueRowCollection<T> newRows { get; }
// public IBlueRowCollection<T> addedRows { get; }
// public IBlueRowCollection<T> deletedRows { get; }
// public IReadOnlyDictionary<string, object> Metadata { get; }
public static DataPacket<T> Empty(IBlueTableSchema schema) =>
new(
new BlueTableImmutable<T>(schema),
new BlueTableImmutable<T>(schema),
new BlueTableImmutable<T>(schema));
}
// public static DataPacket<T> Empty(IBlueTableSchema schema) =>
// new(
// new BlueTableImmutable<T>(schema),
// new BlueTableImmutable<T>(schema),
// new BlueTableImmutable<T>(schema));
// }
public static class DataPacketExtensions {
public static bool HasChanges(this DataPacket dataPacket) =>