/// <summary> /// Get a row cursor. The <paramref name="columnNeeded"/> is the active column. /// The schema of the returned cursor will be the same as the schema of the IDataView, but getting /// a getter for the other, inactive columns will throw. /// </summary> /// <param name="columnNeeded">The column requested by this <see cref="RowCursor"/>, or as otherwise called, the active column.</param> /// <param name="dv">The <see cref="IDataView"/> containing the <paramref name="columnNeeded"/>.</param> public static RowCursor GetRowCursor(this IDataView dv, Schema.Column columnNeeded) { Contracts.Assert(dv.Schema[columnNeeded.Index].Equals(columnNeeded), $"The requested column named: {columnNeeded.Name}, with index: {columnNeeded.Index} and type: {columnNeeded.Type}" + $" is not present in the {nameof(IDataView)} where the {nameof(RowCursor)} is being requested."); return(dv.GetRowCursor(Enumerable.Repeat(columnNeeded, 1))); }
/// <summary> /// Returns true iff <paramref name="column"/> has IsNormalized metadata set to true. /// </summary> public static bool IsNormalized(this Schema.Column column) { var metaColumn = column.Metadata.Schema.GetColumnOrNull((Kinds.IsNormalized)); if (metaColumn == null || !metaColumn.Value.Type.IsBool) { return(false); } bool value = default; column.Metadata.GetValue(Kinds.IsNormalized, ref value); return(value); }
internal static bool HasKeyValues(this Schema.Column column, int keyCount) { if (keyCount == 0) { return(false); } var metaColumn = column.Metadata.Schema.GetColumnOrNull(Kinds.KeyValues); return (metaColumn != null && metaColumn.Value.Type.IsVector && metaColumn.Value.Type.VectorSize == keyCount && metaColumn.Value.Type.ItemType.IsText); }
internal static bool HasSlotNames(this Schema.Column column, int vectorSize) { if (vectorSize == 0) { return(false); } var metaColumn = column.Metadata.Schema.GetColumnOrNull(Kinds.SlotNames); return (metaColumn != null && metaColumn.Value.Type.IsVector && metaColumn.Value.Type.VectorSize == vectorSize && metaColumn.Value.Type.ItemType.IsText); }
internal ColumnInfo(Schema.Column column, object[] values) { Column = column; Values = values; }
public static void GetSlotNames(this Schema.Column column, ref VBuffer <ReadOnlyMemory <char> > slotNames) => column.Metadata.GetValue(Kinds.SlotNames, ref slotNames);
/// <summary> /// Returns <c>true</c> if the specified column: /// * is a vector of length N /// * has a SlotNames metadata /// * metadata type is VBuffer<ReadOnlyMemory<char>> of length N /// </summary> public static bool HasSlotNames(this Schema.Column column) => column.Type.IsKnownSizeVector && column.HasSlotNames(column.Type.VectorSize);
/// <summary> /// Returns <c>true</c> if the specified column: /// * is a vector of length N /// * has a SlotNames metadata /// * metadata type is VBuffer<ReadOnlyMemory<char>> of length N /// </summary> public static bool HasSlotNames(this Schema.Column column) => column.Type is VectorType vectorType &&
private static void Add(Dictionary <string, List <Schema.Column> > map, ColumnRole role, Schema.Column column) { Contracts.AssertValue(map); Contracts.AssertNonEmpty(role.Value); if (!map.TryGetValue(role.Value, out var list)) { list = new List <Schema.Column>(); map.Add(role.Value, list); } list.Add(column); }