Esempio n. 1
0
        public string GetTemplate(CallExpression exp, DonutCodeContext ctx)
        {
            var            callParam        = exp.Parameters.FirstOrDefault();
            NameExpression dsName           = callParam.Value as NameExpression;
            var            targetExpression = ctx.Script.GetDatasetMember(dsName.Name);

            if (targetExpression != null)
            {
                return($"\"${targetExpression.Integration.DataTimestampColumn}\"");
            }
            else
            {
                throw new Exception("Integration not found");
            }
        }
Esempio n. 2
0
        public DonutCodeFeatureDefinition GetTemplate(CallExpression exp, DonutCodeContext ctx)
        {
            var rootIgn         = ctx.Script.GetRootIntegration();
            var expVisitor      = new DonutFeatureGeneratingExpressionVisitor(ctx.Script);
            var callParam       = exp.Parameters.FirstOrDefault();
            var parameterTarget = expVisitor.Visit(callParam);

            if (parameterTarget.ToString() == "document[\"\"]")
            {
                return(DonutCodeFeatureDefinition.Empty);
            }
            var    buffGather     = new StringBuilder();
            var    buffExtract    = new StringBuilder();
            var    paramHash      = HashAlgos.Adler32(callParam.ToString());
            string featureKey     = $"nu_{rootIgn.Name}_{paramHash}";
            var    categoryValue  = "groupKey"; //Use the group key generated from DonutScriptCodeGenerator..
            string ordered        = "true";
            string varCategory    = $"{featureKey}_cat";
            string varValue       = $"{featureKey}_val";
            string varCategoryVal = $"var {varCategory} = {categoryValue};";
            string varValueVal    = $"var {varValue} = {parameterTarget}.ToString();";

            buffGather.AppendLine(varCategoryVal);
            buffGather.AppendLine(varValueVal);
            buffGather.AppendLine($"Context.AddEntityMetaCategory(\"{featureKey}\", {varCategory}, {varValue}, {ordered});");

            buffExtract.AppendLine($"Context.GetSetSize(\"{featureKey}\")");
            var featureDef = new DonutCodeFeatureDefinition()
            {
                PrepareScript    = buffGather.ToString(),
                ExtractionScript = buffExtract.ToString()
            };

            //Feature value:
            //Context.GetSetSize()
            //
            //Define a nameOfTheResultCache, category, value
            //Set the value in the cache
            return(featureDef);

            /**
             * Example
             * //Extraction goes in here
             * var nuRomanianpm25Category = 1;
             * var nuRomanianpm25Value = intDoc["pm25"].ToString();
             * Context.AddEntityMetaCategory("nu_Romanian.pm25", nuRomanianpm25Category, nuRomanianpm25Value, true);
             */
        }