Files
spark/src/DataStreamSuite/DataStream/Primitives/AddColumns/AddColumnsRow.cs
T
2023-09-04 16:25:40 -04:00

106 lines
3.1 KiB
C#

using System;
using System.Collections;
namespace BCG
{
internal class AddColumnsRow : IBlueRow
{
private IBlueTableSchema mySchema;
private IBlueRow myRow;
//private object[] myCachedValues;
#region Constructors
public AddColumnsRow (IBlueTableSchema schema, IBlueRow row)
{
mySchema = schema;
myRow = row;
//myCachedValues = new object[schema.columnNames.Length];
}
#endregion
#region IBlueRow members
public IBlueTableSchema schema{get{return mySchema;}}
#endregion
#region ICollection members
public int Count {get{return mySchema.columnNames.Length;}}
public bool IsSynchronized {get{return false;}}
public object SyncRoot {get{return this;}}
public void CopyTo (Array array, int index)
{
int i = index;
foreach (object o in this as IEnumerable)
array.SetValue (o, i++);
}
#endregion
#region IDictionary members
public bool IsFixedSize {get{return true;}}
public bool IsReadOnly {get{return true;}}
/// <summary>
/// The key can either be the string corrsponding to the column name or
/// the order of the column
/// </summary>
public object this [object key]
{
get
{
if (key is string)
return this[(string)key];
return this[(int)key];
}
set {throw new NotSupportedException ("The IBlueRow is readonly");}
}
public object this[int index]
{
get
{
//if (myCachedValues[index] == null)
// myCachedValues[index] = mySchema[index].isConstant ? mySchema[index].colValue : myRow[index];
//return myCachedValues[index];
return mySchema[index].isConstant ? mySchema[index].colValue : myRow[index];
}
}
public object this[string colName] {get{return this[mySchema[colName].colNo];}}
public ICollection Keys{get{return mySchema.columnNames;}}
public ICollection Values
{
get
{
object[] retVal = new object[mySchema.columnNames.Length];
CopyTo (retVal, 0);
return retVal;
}
}
public void Add (object key, object value) {throw new NotSupportedException ("The IBlueRow is readonly");}
public void Clear () {throw new NotSupportedException ("The IBlueRow is readonly");}
public bool Contains (object key){return mySchema[(string)key] != null;}
/// <summary>
/// Note, the default enumerator is the IDictionary's enumerator, so if user needs to
/// iterate through the values, typecast this into an IEnumerable
/// </summary>
/// <returns></returns>
public IDictionaryEnumerator GetEnumerator() {return new BlueRowDictionaryEnumerator(this);}
IEnumerator IEnumerable.GetEnumerator () {return new BlueRowEnumerator(this);}
public void Remove (object key) {throw new NotSupportedException ("The IBlueRow is readonly");}
#endregion
}
}