Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbbe371add | ||
|
|
6eaacdbf17 |
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user