예제 #1
0
        public XaTableMapper(IDimension dimension, string tableName = null,
            string dimensionTableName = null, bool hashKey = false,
            string keyName = null, string labelName = null, ILabelProvider labelProvider = null,            
            IEnumerable<IFieldMapper> additionalFields = null, FactTypes factTypes = FactTypes.All)
        {
            var defintion = new TableDefinition(tableName);

            Dimension = dimension;

            labelName = labelName ?? dimension.GetType().Name + "Label";            
            
            defintion.FieldMappers.Add(new FieldMapperSet(dimensionTableName, dimensionTableName == null,
                new[]
                {
                    new LabeledFieldMapper(new XaDimensionDataMapper(dimension, !hashKey, keyName), labelName, labelProvider, friendlyName: XaFieldMapper.SuggestFriendlyLabelName(labelName))
                }));

            defintion.FieldMappers.Add(new XaFacts(factTypes: factTypes));

            if (additionalFields != null)
            {
                foreach (var f in additionalFields)
                {
                    defintion.FieldMappers.Add(f);
                }
            }
            
            TableDefinitions.Add(defintion);
        }
        public XaTableMapper(IDimension dimension, string tableName = null,
                             string dimensionTableName = null, bool hashKey     = false,
                             string keyName            = null, string labelName = null, ILabelProvider labelProvider = null,
                             IEnumerable <IFieldMapper> additionalFields = null, FactTypes factTypes = FactTypes.All)
        {
            var defintion = new TableDefinition(tableName);

            Dimension = dimension;

            labelName = labelName ?? dimension.GetType().Name + "Label";

            defintion.FieldMappers.Add(new FieldMapperSet(dimensionTableName, dimensionTableName == null,
                                                          new[]
            {
                new LabeledFieldMapper(new XaDimensionDataMapper(dimension, !hashKey, keyName), labelName, labelProvider, friendlyName: XaFieldMapper.SuggestFriendlyLabelName(labelName))
            }));

            defintion.FieldMappers.Add(new XaFacts(factTypes: factTypes));

            if (additionalFields != null)
            {
                foreach (var f in additionalFields)
                {
                    defintion.FieldMappers.Add(f);
                }
            }

            TableDefinitions.Add(defintion);
        }
예제 #3
0
        /// <summary>
        /// Find the converter functor from source to target
        /// </summary>
        /// <param name="source">Dimension to convert from</param>
        /// <param name="target">Dimension to concert to</param>
        /// <param name="power"></param>
        /// <returns>A functor to convert from source into target</returns>
        public static Func<double, double> From(IDimension source, IDistance target, int power)
        {
            var dispatcher = new VisitorDispatcher("Convert");

            var result = dispatcher.Accept(source.GetType(), new DistanceConverter(), source, target, power);

            return (Func<double, double>)result;
        }
예제 #4
0
        /// <summary>
        /// Find the converter functor from source to target
        /// </summary>
        /// <param name="source">Dimension to convert from</param>
        /// <param name="target">Dimension to concert to</param>
        /// <param name="power"></param>
        /// <returns>A functor to convert from source into target</returns>
        public static Func <double, double> From(IDimension source, IDistance target, int power)
        {
            var dispatcher = new VisitorDispatcher("Convert");

            var result = dispatcher.Accept(source.GetType(), new DistanceConverter(), source, target, power);

            return((Func <double, double>)result);
        }
예제 #5
0
        public XaFieldMapper(IDimension dimension,
                             bool primaryKey = false,
                             string keyName  = null, string friendlyName = null)
        {
            Dimension = dimension;

            _keyName      = keyName ?? dimension.GetType().Name + "Key";
            _primaryKey   = primaryKey;
            _friendlyName = friendlyName ?? SuggestFriendlyKeyName(_keyName);
        }
예제 #6
0
        public XaFieldMapper(IDimension dimension,
            bool primaryKey = false,
            string keyName = null, string friendlyName = null)
        {
            Dimension = dimension;

            _keyName = keyName ?? dimension.GetType().Name + "Key";
            _primaryKey = primaryKey;
            _friendlyName = friendlyName ?? SuggestFriendlyKeyName(_keyName);
        }
예제 #7
0
		///<summary>
		/// Check if the current instance equals another instance of this class.
		///</summary>
		///<param name="obj">The instance to compare the current instance with.</param>
		///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
		public bool Equals(IDimension obj) 
		{
			if (obj == null || GetType() != obj.GetType()) 
			 return false;
			Dimension d = (Dimension) obj;
			for (int i=0;i<(int)DimensionBase.NUM_BASE_DIMENSIONS;i++) 
			{
				if (_count[i]!=d._count[i])
					return false;
			}
			return true;
		}
예제 #8
0
        ///<summary>
        /// Check if the current instance equals another instance of this class.
        ///</summary>
        ///<param name="obj">The instance to compare the current instance with.</param>
        ///<returns><code>true</code> if the instances are the same instance or have the same content.</returns>
        public bool Equals(IDimension obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            Dimension d = (Dimension)obj;

            for (int i = 0; i < (int)DimensionBase.NUM_BASE_DIMENSIONS; i++)
            {
                if (_count[i] != d._count[i])
                {
                    return(false);
                }
            }
            return(true);
        }
 public static OptimizerService.Dimension EncodeDimension(IDimension dimension)
 {
     // C# Syntax equivalent to
     // if(dimension is EmptyDimension) {
     //      var emptyDimension = (EmptyDimension) dimension; ..
     // }
     if (dimension is EmptyDimension emptyDimension)
     {
         return(new OptimizerService.Dimension
         {
             EmptyDimension = EncodeEmptyDimension(emptyDimension),
         });
     }
     else if (dimension is ContinuousDimension continuousDimension)
     {
         return(new OptimizerService.Dimension
         {
             ContinuousDimension = EncodeContinuousDimension(continuousDimension),
         });
     }
     else if (dimension is DiscreteDimension discreteDimension)
     {
         return(new OptimizerService.Dimension
         {
             DiscreteDimension = EncodeDiscreteDimension(discreteDimension),
         });
     }
     else if (dimension is OrdinalDimension ordinalDimension)
     {
         return(new OptimizerService.Dimension
         {
             OrdinalDimension = EncodeOrdinalDimension(ordinalDimension),
         });
     }
     else if (dimension is CategoricalDimension categoricalDimension)
     {
         return(new OptimizerService.Dimension
         {
             CategoricalDimension = EncodeCategoricalDimension(categoricalDimension),
         });
     }
     else if (dimension is CompositeDimension compositeDimension)
     {
         return(new OptimizerService.Dimension
         {
             CompositeDimension = EncodeCompositeDimension(compositeDimension),
         });
     }
     else
     {
         throw new System.ArgumentException("Invalid dimension type provided to OptimizerServiceEncoderDecoder.Encoder.EncodeDimension(..). Type: " + dimension.GetType());
     }
 }