Compare commits

..
Author SHA1 Message Date
John Colvin fbbe371add cleanup: Remove unnecessary using from MongSchemaAdaptor 2024-05-25 14:23:32 -04:00
John Colvin 6eaacdbf17 fix build: Add IBlueRowFactory, and HasChanges ext
The recently added MongoCollectionStream dependend on these items. It
has been a while since I've looked at this branch, so I'm not sure what
happened, but the referenced members were no where to be found.
2024-05-25 14:23:22 -04:00
5 changed files with 30 additions and 4 deletions

No files matched your search

@@ -1,7 +1,5 @@
namespace Bts.DataStream;
using BCG;
using bts;
using MongoDB.Bson;
@@ -9,7 +9,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
public class BlueTableSchemaAdaptor<T> {
public class BlueTableSchemaAdaptor<T> : IMutableBlueRowFactory<T> {
readonly string name;
readonly List<ColumnAdaptor> columns = [];
BlueTableSchema? schema;
@@ -60,7 +60,10 @@ public class BlueTableSchemaAdaptor<T> {
columns.Add(new ColumnAdaptor(new(name, columns.Count, dataType), r => getValue(r)));
}
public IBlueRow GetBlueRow(T item) {
public IBlueRow GetBlueRow(T item) =>
GetMutableBlueRow(item);
public MutableBlueRow GetMutableBlueRow(T item) {
var mbr = new MutableBlueRow(Schema);
foreach (var col in columns) {
mbr.setValue(col.Info.colNo, col.GetValue(item));
@@ -0,0 +1,9 @@
#nullable enable
namespace Bts.DataStream;
using BCG;
public interface IBlueRowFactory<T> {
IBlueTableSchema Schema { get; }
IBlueRow GetBlueRow(T item);
}
@@ -0,0 +1,11 @@
#nullable enable
namespace Bts.DataStream;
using BCG;
public interface IMutableBlueRowFactory<T> : IBlueRowFactory<T> {
MutableBlueRow GetMutableBlueRow(T item);
IBlueRow IBlueRowFactory<T>.GetBlueRow(T item) =>
GetMutableBlueRow(item);
}
@@ -313,4 +313,9 @@ namespace BCG
return String.Format("DataPacket, schema {0} n {1} d {2} a {3}", schema.tableName, newRows.Count, deletedRows.Count, addedRows.Count);
}
}
public static class DataPacketExtensions {
public static bool HasChanges(this DataPacket dataPacket) =>
dataPacket.addedRows.Count > 0 || dataPacket.deletedRows.Count > 0;
}
}