Exemple #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));
        }
        /// <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());
        }
        internal 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 <Schema.Column> list = schema?.GetColumns(role);

            if (list?.Count != 1 || !schema.Schema[list[0].Index].HasSlotNames(vectorSize))
            {
                VBufferUtils.Resize(ref slotNames, vectorSize, 0);
            }
            else
            {
                schema.Schema[list[0].Index].Metadata.GetValue(Kinds.SlotNames, ref slotNames);
            }
        }