Files
spark/src/DataStreamSuite/DataStream/Primitives/Project/ProjectedRow.cs
T
John Colvin 56f7518186 chore: Uncomment DataStream Primitives code
It builds now that all the deps are in place
2023-09-21 23:48:57 -04:00

95 lines
2.6 KiB
C#

using System;
using System.Collections;
using BCG.Utilities;
namespace BCG
{
/// <summary>
/// Projected row just keeps a pointer to the original row its projecting and to the ProjectHelper
/// (which provided the projected schema and the mapping). All indexing to it, are redirected (though
/// the colMapper in ProjectHelper) to the original row
/// </summary>
internal class ProjectedRow : IBlueRow
{
private IBlueRow myRow;
private ProjectHelper myHelper;
internal ProjectedRow (IBlueRow row, ProjectHelper helper)
{
myRow = row;
myHelper = helper;
}
#region IBlueRow Members
public object this [string colName] {get {return this[myHelper.schema[colName].colNo];}}
public object this [int index] {get {return myRow[myHelper.colMap[index]];}}
public IBlueTableSchema schema {get {return myHelper.schema;}}
#endregion
#region IDictionary Members
public bool IsReadOnly {get {return true;}}
public IDictionaryEnumerator GetEnumerator() {return new BlueRowDictionaryEnumerator (this);}
object System.Collections.IDictionary.this[object key]
{
get {return key is int ? this[(int)key] : this[key as string];}
set {throw new ApplicationException ("Is read only");}
}
public void Remove(object key) {throw new ApplicationException ("Is read only");}
public bool Contains (object key) {return myHelper.schema [key as string] != null;}
public void Clear() {throw new ApplicationException ("Is read only");}
public ICollection Values
{
get
{
object[] retVal = new object[Count];
CopyTo (retVal, 0);
return retVal;
}
}
public void Add (object key, object value) {throw new ApplicationException ("Is read only");}
public ICollection Keys {get {return myHelper.schema.columnNames;}}
public bool IsFixedSize {get {return true;}}
#endregion
#region ICollection Members
public bool IsSynchronized {get {return false;}}
public int Count {get {return myHelper.schema.columnNames.Length;}}
public void CopyTo (Array array, int index)
{
foreach (ColumnInfo ci in myHelper.schema.columnInfo)
array.SetValue (this[ci.colNo], index ++);
}
public object SyncRoot {get {return null;}}
#endregion
#region IEnumerable Members
IEnumerator System.Collections.IEnumerable.GetEnumerator() {return new BlueRowEnumerator (this);}
#endregion
}
}