120 lines
4.8 KiB
C#
120 lines
4.8 KiB
C#
//using System;
|
|
//using System.Data;
|
|
//using System.Collections;
|
|
//using BCG.Utilities;
|
|
//using BCG.Utilities.General;
|
|
//namespace BCG
|
|
//{
|
|
// /// <summary>
|
|
// /// Provides a live stream of Union of 2 streams
|
|
// /// </summary>
|
|
// public abstract class UnionStream : ViewStream
|
|
// {
|
|
// protected UnionOperand myLeftOp, myRightOp;
|
|
// protected ViewStream myLeftVs, myRightVs;
|
|
// protected DataPacket myLastFiredPacket;
|
|
// protected IDictionary myLeftIndex = new Hashtable (), myRightIndex = new Hashtable ();
|
|
// protected int[] myLeftIndexToIndexMap, myRightIndexToIndexMap;
|
|
// protected int myIdCounter, myIdIndex;
|
|
|
|
// protected override void myOnFirstSubscriber()
|
|
// {
|
|
// myLeftOp = new UnionOperand (true, this);
|
|
// myRightOp = new UnionOperand (false, this);
|
|
// myLeftVs.onChange += new DataStream.ChangeDelegate (myLeftOp.myChangeHandler);
|
|
// myRightVs.onChange += new DataStream.ChangeDelegate (myRightOp.myChangeHandler);
|
|
// }
|
|
|
|
// protected override void myOnLastSubscriber ()
|
|
// {
|
|
// myInit ();
|
|
// myLeftVs.onChange -= new DataStream.ChangeDelegate (myLeftOp.myChangeHandler);
|
|
// myRightVs.onChange -= new DataStream.ChangeDelegate (myRightOp.myChangeHandler);
|
|
// }
|
|
|
|
// public void startSession ()
|
|
// {
|
|
// if (myLastFiredPacket == null)
|
|
// {
|
|
// myLastFiredPacket = new DataPacket ();
|
|
// if (myLeftOp.opSchema != null)//ie call back initiated by left operand
|
|
// {
|
|
// myLeftIndexToIndexMap = myInitIndexToIndex (myLeftOp.opSchema, myLeftOp.opSchema);
|
|
// myLastFiredPacket.newRows = new BlueTable (myLeftOp.opSchema);
|
|
// myIdIndex = myLeftOp.opSchema["id"].colNo;
|
|
// }
|
|
// else
|
|
// {
|
|
// myRightIndexToIndexMap = myInitIndexToIndex (myRightOp.opSchema, myRightOp.opSchema);
|
|
// myLastFiredPacket.newRows = new BlueTable (myRightOp.opSchema);
|
|
// myIdIndex = myRightOp.opSchema["id"].colNo;
|
|
// }
|
|
// }
|
|
// else if (myRightIndexToIndexMap == null && myRightOp.opSchema != null)
|
|
// myRightIndexToIndexMap = myInitIndexToIndex (myLeftOp.opSchema, myRightOp.opSchema);
|
|
// else if (myLeftIndexToIndexMap == null && myLeftOp.opSchema != null)
|
|
// myLeftIndexToIndexMap = myInitIndexToIndex (myRightOp.opSchema, myLeftOp.opSchema);
|
|
// myLastFiredPacket.addedRows = new BlueTable (myLastFiredPacket.newRows.schema);
|
|
// myLastFiredPacket.deletedRows = new BlueTable (myLastFiredPacket.newRows.schema);
|
|
// }
|
|
|
|
// private int[] myInitIndexToIndex (IBlueTableSchema sch1, IBlueTableSchema sch2)
|
|
// {
|
|
// //BlueEventLog.logAssert (sch1.columnNames.Length.Equals (sch2.columnNames.Length));
|
|
// //foreach (string colName in sch1.columnNames)
|
|
// // BlueEventLog.logAssert (sch2[colName] != null);
|
|
// if(!sch1.columnNames.Length.Equals(sch2.columnNames.Length))
|
|
// throw new BlueDataException("Union stream: different schemas");
|
|
// foreach(string colName in sch1.columnNames)
|
|
// {
|
|
// if(sch2[colName] == null)
|
|
// throw new BlueDataException("Union stream: can't find " + colName);
|
|
// }
|
|
// int[] retVal = new int[sch1.columnNames.Length];
|
|
// for (int i = 0; i < retVal.Length; i++)
|
|
// retVal[i] = sch2[sch1[i].colName].colNo;
|
|
// return retVal;
|
|
// }
|
|
|
|
// public virtual void endSession ()
|
|
// {
|
|
// myFireEvent (myLastFiredPacket.Clone ());
|
|
// }
|
|
|
|
// public abstract void add (IBlueRowCollection rows, bool isLeft);
|
|
|
|
// public abstract void delete (IBlueRowCollection rows, bool isLeft);
|
|
|
|
// public abstract void mergeChanges (IBlueRowCollection dels, IBlueRowCollection adds, bool isLeft);
|
|
|
|
// private void myInit ()
|
|
// {
|
|
// myLastFiredPacket = null;
|
|
// myLeftOp.init ();
|
|
// myRightOp.init ();
|
|
// myLeftIndex.Clear ();
|
|
// myRightIndex.Clear ();
|
|
// myIdCounter = myIdIndex = 0;
|
|
// myLeftIndexToIndexMap = myRightIndexToIndexMap = null;
|
|
// }
|
|
|
|
// /// <summary>
|
|
// /// Used for test purposes only. Users of this class specifically, should ignore it
|
|
// /// (too bad, the NUnit cant see the private methods)
|
|
// /// </summary>
|
|
// /// <param name="dp"></param>
|
|
// /// <param name="isLeft"></param>
|
|
// internal void receiveStream (DataPacket dp, bool isLeft)
|
|
// {
|
|
// if (isLeft)
|
|
// myLeftOp.myChangeHandler (dp);
|
|
// else
|
|
// myRightOp.myChangeHandler (dp);
|
|
// }
|
|
// public void receiveStreamTest(DataPacket dp, bool isLeft)
|
|
// {
|
|
// receiveStream(dp, isLeft);
|
|
// }
|
|
// }
|
|
//}
|