Created
February 7, 2019 20:43
-
-
Save eerhardt/eff7e207673e1fde40a5696eb07ba273 to your computer and use it in GitHub Desktop.
DataView Proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Microsoft.Data.DataView { | |
public sealed class BooleanDataViewType : PrimitiveDataViewType { | |
public static BooleanDataViewType Instance { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public abstract class DataViewRow : IDisposable { | |
protected DataViewRow(); | |
public abstract long Batch { get; } | |
public abstract long Position { get; } | |
public abstract DataViewSchema Schema { get; } | |
public void Dispose(); | |
protected virtual void Dispose(bool disposing); | |
public abstract ValueGetter<TValue> GetGetter<TValue>(int col); | |
public abstract ValueGetter<DataViewRowId> GetIdGetter(); | |
public abstract bool IsColumnActive(int col); | |
} | |
public abstract class DataViewRowCursor : DataViewRow { | |
protected DataViewRowCursor(); | |
public abstract bool MoveNext(); | |
} | |
public readonly struct DataViewRowId : IComparable<DataViewRowId>, IEquatable<DataViewRowId> { | |
public readonly ulong High; | |
public readonly ulong Low; | |
public DataViewRowId(ulong low, ulong high); | |
public DataViewRowId Combine(DataViewRowId other); | |
public int CompareTo(DataViewRowId other); | |
public bool Equals(DataViewRowId other); | |
public override bool Equals(object obj); | |
public DataViewRowId Fork(); | |
public override int GetHashCode(); | |
public DataViewRowId Next(); | |
public static DataViewRowId operator +(DataViewRowId first, ulong second); | |
public static bool operator ==(DataViewRowId first, ulong second); | |
public static explicit operator double (DataViewRowId x); | |
public static bool operator >(DataViewRowId first, ulong second); | |
public static bool operator >=(DataViewRowId first, ulong second); | |
public static bool operator !=(DataViewRowId first, ulong second); | |
public static bool operator <(DataViewRowId first, ulong second); | |
public static bool operator <=(DataViewRowId first, ulong second); | |
public static DataViewRowId operator -(DataViewRowId first, ulong second); | |
public override string ToString(); | |
} | |
public sealed class DataViewSchema : IEnumerable, IEnumerable<DataViewSchema.Column>, IReadOnlyCollection<DataViewSchema.Column>, IReadOnlyList<DataViewSchema.Column> { | |
public int Count { get; } | |
public DataViewSchema.Column this[int columnIndex] { get; } | |
public DataViewSchema.Column this[string name] { get; } | |
public Nullable<DataViewSchema.Column> GetColumnOrNull(string name); | |
public IEnumerator<DataViewSchema.Column> GetEnumerator(); | |
IEnumerator System.Collections.IEnumerable.GetEnumerator(); | |
public override string ToString(); | |
public sealed class Annotations { | |
public static DataViewSchema.Annotations Empty { get; } | |
public DataViewSchema Schema { get; } | |
public ValueGetter<TValue> GetGetter<TValue>(int col); | |
public void GetValue<TValue>(string kind, ref TValue value); | |
public override string ToString(); | |
public sealed class Builder { | |
public Builder(); | |
public void Add(DataViewSchema.Annotations annotations, Func<string, bool> selector); | |
public void Add(string name, DataViewType type, Delegate getter, DataViewSchema.Annotations annotations = null); | |
public void Add<TValue>(string name, DataViewType type, ValueGetter<TValue> getter, DataViewSchema.Annotations annotations = null); | |
public void AddPrimitiveValue<TValue>(string name, PrimitiveDataViewType type, TValue value, DataViewSchema.Annotations annotations = null); | |
public DataViewSchema.Annotations GetAnnotations(); | |
} | |
} | |
public sealed class Builder { | |
public Builder(); | |
public void AddColumn(string name, DataViewType type, DataViewSchema.Annotations annotations = null); | |
public void AddColumns(IEnumerable<DataViewSchema.Column> source); | |
public void AddColumns(IEnumerable<DataViewSchema.DetachedColumn> source); | |
public DataViewSchema GetSchema(); | |
} | |
public struct Column { | |
public DataViewSchema.Annotations Annotations { get; } | |
public int Index { get; } | |
public bool IsHidden { get; } | |
public string Name { get; } | |
public DataViewType Type { get; } | |
public override string ToString(); | |
} | |
public struct DetachedColumn { | |
public DetachedColumn(DataViewSchema.Column column); | |
public DetachedColumn(string name, DataViewType type, DataViewSchema.Annotations annotations = null); | |
public DataViewSchema.Annotations Annotations { get; } | |
public string Name { get; } | |
public DataViewType Type { get; } | |
} | |
} | |
public abstract class DataViewType : IEquatable<DataViewType> { | |
public Type RawType { get; } | |
public abstract bool Equals(DataViewType other); | |
} | |
public sealed class DateTimeDataViewType : PrimitiveDataViewType { | |
public static DateTimeDataViewType Instance { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public sealed class DateTimeOffsetDataViewType : PrimitiveDataViewType { | |
public static DateTimeOffsetDataViewType Instance { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public interface IDataView { | |
bool CanShuffle { get; } | |
DataViewSchema Schema { get; } | |
Nullable<long> GetRowCount(); | |
DataViewRowCursor GetRowCursor(IEnumerable<DataViewSchema.Column> columnsNeeded, Random rand = null); | |
DataViewRowCursor[] GetRowCursorSet(IEnumerable<DataViewSchema.Column> columnsNeeded, int n, Random rand = null); | |
} | |
public sealed class NumberDataViewType : PrimitiveDataViewType { | |
public static NumberDataViewType Byte { get; } | |
public static NumberDataViewType DataViewRowId { get; } | |
public static NumberDataViewType Double { get; } | |
public static NumberDataViewType Int16 { get; } | |
public static NumberDataViewType Int32 { get; } | |
public static NumberDataViewType Int64 { get; } | |
public static NumberDataViewType SByte { get; } | |
public static NumberDataViewType Single { get; } | |
public static NumberDataViewType UInt16 { get; } | |
public static NumberDataViewType UInt32 { get; } | |
public static NumberDataViewType UInt64 { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public abstract class PrimitiveDataViewType : DataViewType { | |
protected PrimitiveDataViewType(Type rawType); | |
} | |
public abstract class StructuredDataViewType : DataViewType { | |
protected StructuredDataViewType(Type rawType); | |
} | |
public sealed class TextDataViewType : PrimitiveDataViewType { | |
public static TextDataViewType Instance { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public sealed class TimeSpanDataViewType : PrimitiveDataViewType { | |
public static TimeSpanDataViewType Instance { get; } | |
public override bool Equals(DataViewType other); | |
public override string ToString(); | |
} | |
public delegate void ValueGetter<TValue>(ref TValue value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment