Пример #1
0
            /// <summary>
            /// Get the value of the metadata, by metadata kind (aka column name).
            /// </summary>
            public void GetValue <TValue>(string kind, ref TValue value)
            {
                var column = Schema.GetColumnOrNull(kind);

                if (column == null)
                {
                    throw MetadataUtils.ExceptGetMetadata();
                }
                GetGetter <TValue>(column.Value.Index)(ref value);
            }
Пример #2
0
            /// <summary>
            /// Get a getter delegate for one value of the metadata row.
            /// </summary>
            public ValueGetter <TValue> GetGetter <TValue>(int col)
            {
                Contracts.CheckParam(0 <= col && col < Schema.Count, nameof(col));
                var typedGetter = Getters[col] as ValueGetter <TValue>;

                if (typedGetter == null)
                {
                    Contracts.Assert(Getters[col] != null);
                    throw MetadataUtils.ExceptGetMetadata();
                }
                return(typedGetter);
            }
 public void GetMetadata <TValue>(string kind, int col, ref TValue value)
 {
     _ectx.CheckParam(col == 0, nameof(col));
     if (kind == MetadataUtils.Kinds.SlotNames && _hasSlotNames)
     {
         _parentSchema[_featureCol].Metadata.GetValue(kind, ref value);
     }
     else
     {
         throw MetadataUtils.ExceptGetMetadata();
     }
 }
Пример #4
0
        protected override void GetMetadataCore <TValue>(string kind, int iinfo, ref TValue value)
        {
            Contracts.Assert(0 <= iinfo && iinfo < InfoCount);
            switch (kind)
            {
            case MetadataUtils.Kinds.ScoreColumnSetId:
                _getScoreColumnSetId.Marshal(iinfo, ref value);
                break;

            default:
                if (iinfo < DerivedColumnCount)
                {
                    throw MetadataUtils.ExceptGetMetadata();
                }
                Mapper.OutputSchema[iinfo - DerivedColumnCount].Metadata.GetValue(kind, ref value);
                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Assumes all columns have ScoreColumnKind and ScoreValueKind.
        /// </summary>
        public virtual void GetMetadata <TValue>(string kind, int col, ref TValue value)
        {
            Contracts.CheckNonEmpty(kind, nameof(kind));
            Contracts.CheckParam(0 <= col && col < ColumnCount, nameof(col));
            switch (kind)
            {
            case MetadataUtils.Kinds.ScoreColumnKind:
                ScoreColumnKindGetter.Marshal(col, ref value);
                break;

            case MetadataUtils.Kinds.ScoreValueKind:
                ScoreValueKindGetter.Marshal(col, ref value);
                break;

            default:
                throw MetadataUtils.ExceptGetMetadata();
            }
        }
Пример #6
0
 protected virtual void GetMetadataCore <TValue>(string kind, int iinfo, ref TValue value)
 {
     Contracts.AssertNonEmpty(kind);
     Contracts.Assert(0 <= iinfo && iinfo < InfoCount);
     throw MetadataUtils.ExceptGetMetadata();
 }