Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c80374579e | ||
|
|
81cc0892f2 | ||
|
|
88714bb4b5 | ||
|
|
f39f1784a8 | ||
|
|
b7c8e72a07 | ||
|
|
eea4af1f9b | ||
|
|
6a244fee35 | ||
|
|
d6a744e5ab | ||
|
|
6f86b41f02 |
No files matched your search
@@ -14,11 +14,8 @@ public class ObservableViewStream : ViewStream, IObservable<DataPacket>, IDispos
|
||||
this.source = source;
|
||||
|
||||
public void Dispose() {
|
||||
GC.SuppressFinalize(this);
|
||||
if (subscription is not null) {
|
||||
subscription.Dispose();
|
||||
subscription = null;
|
||||
}
|
||||
subscription?.Dispose();
|
||||
subscription = null;
|
||||
}
|
||||
|
||||
protected override void myOnFirstSubscriber() {
|
||||
|
||||
@@ -188,7 +188,7 @@ public class MongoCollectionStream : ViewStream, IObservable<DataPacket> {
|
||||
collection = database.GetCollection<BsonDocument>(collectionName);
|
||||
var cursor = collection.Find(Builders<BsonDocument>.Filter.Empty).ToCursor();
|
||||
var docList = await cursor.ToListAsync();
|
||||
rowFactory ??= getRowFactory(docList);
|
||||
rowFactory ??= MongoSchemaAdaptor.InferSchema(docList);
|
||||
var firstTable = new BlueTableImmutable(rowFactory.Schema).ToDataPacketBuilder();
|
||||
foreach (var doc in docList) {
|
||||
var row = rowFactory.GetBlueRow(doc);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace Bts.DataStream;
|
||||
|
||||
using BCG;
|
||||
|
||||
using bts;
|
||||
|
||||
using MongoDB.Bson;
|
||||
|
||||
@@ -9,16 +9,16 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class BlueTableSchemaAdaptor<T> : IMutableBlueRowFactory<T> {
|
||||
public class BlueTableSchemaAdaptor<T> {
|
||||
readonly string name;
|
||||
readonly List<ColumnAdaptor> columns = new();
|
||||
readonly List<ColumnAdaptor> columns = [];
|
||||
BlueTableSchema? schema;
|
||||
|
||||
public BlueTableSchemaAdaptor(string name) =>
|
||||
this.name = name;
|
||||
|
||||
public IBlueTableSchema Schema =>
|
||||
schema ??= new BlueTableSchema(columns.WrapSelectorRO(c => c.Info).ToArray(), name);
|
||||
schema ??= new BlueTableSchema([.. columns.WrapSelectorRO(c => c.Info)], name);
|
||||
|
||||
public bool Contains(string name) =>
|
||||
columns.Any(c => c.Info.colName == name);
|
||||
@@ -60,10 +60,7 @@ public class BlueTableSchemaAdaptor<T> : IMutableBlueRowFactory<T> {
|
||||
columns.Add(new ColumnAdaptor(new(name, columns.Count, dataType), r => getValue(r)));
|
||||
}
|
||||
|
||||
public IBlueRow GetBlueRow(T item) =>
|
||||
GetMutableBlueRow(item);
|
||||
|
||||
public MutableBlueRow GetMutableBlueRow(T item) {
|
||||
public IBlueRow GetBlueRow(T item) {
|
||||
var mbr = new MutableBlueRow(Schema);
|
||||
foreach (var col in columns) {
|
||||
mbr.setValue(col.Info.colNo, col.GetValue(item));
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#nullable enable
|
||||
namespace Bts.DataStream;
|
||||
|
||||
using BCG;
|
||||
|
||||
public interface IBlueRowFactory<T> {
|
||||
IBlueTableSchema Schema { get; }
|
||||
IBlueRow GetBlueRow(T item);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#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,9 +313,4 @@ 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