Ejemplo n.º 1
0
        private Func <int, bool> GetActiveCols(RoleMappedSchema schema)
        {
            Func <int, bool> pred = GetActiveColsCore(schema);
            var stratCols         = schema.GetColumns(MamlEvaluatorBase.Strat);
            var stratIndices      = Utils.Size(stratCols) > 0 ? new HashSet <int>(stratCols.Select(col => col.Index)) : new HashSet <int>();

            return(i => pred(i) || stratIndices.Contains(i));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// For each stratification column, get an aggregator dictionary.
        /// </summary>
        private AggregatorDictionaryBase[] GetAggregatorDictionaries(RoleMappedSchema schema)
        {
            var list      = new List <AggregatorDictionaryBase>();
            var stratCols = schema.GetColumns(MamlEvaluatorBase.Strat);

            if (Utils.Size(stratCols) > 0)
            {
                Func <string, TAgg> createAgg = stratName => GetAggregatorCore(schema, stratName);
                foreach (var stratCol in stratCols)
                {
                    list.Add(AggregatorDictionaryBase.Create(schema, stratCol.Name, stratCol.Type, createAgg));
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 3
0
        public static void GetSlotNames(RoleMappedSchema schema, RoleMappedSchema.ColumnRole role, int vectorSize, ref VBuffer <ReadOnlyMemory <char> > slotNames)
        {
            Contracts.CheckValueOrNull(schema);
            Contracts.CheckParam(vectorSize >= 0, nameof(vectorSize));

            IReadOnlyList <ColumnInfo> list;

            if ((list = schema?.GetColumns(role)) == null || list.Count != 1 || !schema.Schema.HasSlotNames(list[0].Index, vectorSize))
            {
                VBufferUtils.Resize(ref slotNames, vectorSize, 0);
            }
            else
            {
                schema.Schema.GetMetadata(Kinds.SlotNames, list[0].Index, ref slotNames);
            }
        }
Ejemplo n.º 4
0
        public static void GetSlotNames(RoleMappedSchema schema, RoleMappedSchema.ColumnRole role, int vectorSize, ref VBuffer <DvText> slotNames)
        {
            Contracts.CheckValueOrNull(schema);
            Contracts.CheckValue(role.Value, nameof(role));
            Contracts.CheckParam(vectorSize >= 0, nameof(vectorSize));

            IReadOnlyList <ColumnInfo> list;

            if ((list = schema?.GetColumns(role)) == null || list.Count != 1 || !schema.Schema.HasSlotNames(list[0].Index, vectorSize))
            {
                slotNames = new VBuffer <DvText>(vectorSize, 0, slotNames.Values, slotNames.Indices);
            }
            else
            {
                schema.Schema.GetMetadata(Kinds.SlotNames, list[0].Index, ref slotNames);
            }
        }