Exemple #1
0
 private void ExtractFunctionName(PrefSQLParser.SkylinePreferenceUdfContext context, UdfModel model)
 {
     model.SchemaName   = GetSchemaName(context.GetChild(0));
     model.FunctionName = GetFunctionName(context.GetChild(0));
     //model.FullFunctionName = $"{model.SchemaName}.{model.FunctionName}";
     model.FullFunctionName = model.SchemaName + "." + model.FunctionName;
 }
Exemple #2
0
        private void ExtractLevelingData(PrefSQLParser.SkylinePreferenceUdfContext context, UdfModel model)
        {
            // set defaults
            model.IsLevelStepEqual       = true;
            model.LevelStep              = string.Empty;
            model.LevelAdd               = string.Empty;
            model.LevelMinus             = string.Empty;
            model.IsComparable           = true;
            model.HasIncomparableTuples  = false;
            model.ContainsOpenPreference = false;

            // no STEP operator
            if (context.ChildCount != 4)
            {
                return;
            }

            //If a third parameter is given, it is the Level Step  (i.e. LOW price 1000 means prices divided through 1000)
            //The user doesn't care about a price difference of 1000
            //This results in a smaller skyline
            model.LevelStep  = " / " + context.GetChild(2).GetText();
            model.LevelAdd   = " + " + context.GetChild(2).GetText();
            model.LevelMinus = " - " + context.GetChild(2).GetText();

            //
            if (context.GetChild(3).GetText().Equals("EQUAL"))
            {
                return;
            }
            model.IsLevelStepEqual      = false;
            model.IsComparable          = false;
            model.HasIncomparableTuples = true;
            //Some algorithms cannot handle this incomparable preference --> It is like a categorical preference without explicit OTHERS
            model.ContainsOpenPreference = true;
        }
Exemple #3
0
        public override PrefSQLModel VisitSkylinePreferenceUdf(PrefSQLParser.SkylinePreferenceUdfContext context)
        {
            // extract data
            var udfModel = new SqlUdfVisitor().VisitSkylinePreferenceUdf(context);

            // set global flags
            _hasIncomparableTuples  = _hasIncomparableTuples || udfModel.HasIncomparableTuples;
            _containsOpenPreference = _containsOpenPreference || udfModel.ContainsOpenPreference;

            // create preference and add to list
            var sub = new SqlUdfBuilder(udfModel, InnerTableSuffix);

            return(AddSkyline(new AttributeModel(sub.CreateRankingExpr(), sub.CreateInnerExpr(), udfModel.FullFunctionName, "", udfModel.IsComparable, sub.CreateIncomporableAttribute(), false, "", 0, 0, sub.CreateExpression())));
        }
Exemple #4
0
        public override UdfModel VisitSkylinePreferenceUdf(PrefSQLParser.SkylinePreferenceUdfContext context)
        {
            // extract schema and function
            var model = new UdfModel();

            ExtractFunctionName(context, model);

            // extract parameter
            ExtractParameterList(context.exprUdfParam(), model);

            // extract leveling
            ExtractLevelingData(context, model);

            ExtractHighLowData(context, model);

            return(model);
        }
Exemple #5
0
        private void ExtractHighLowData(PrefSQLParser.SkylinePreferenceUdfContext context, UdfModel model)
        {
            // set defaults
            model.OppositeOperator = string.Empty;

            // operators not found
            model.HasHighLowOperator = (context.op.Type == PrefSQLParser.K_LOW || context.op.Type == PrefSQLParser.K_HIGH);
            if (!model.HasHighLowOperator)
            {
                return;
            }

            // mode HIGH
            model.LevelAdditionaly = model.LevelAdd;
            if (context.op.Type == PrefSQLParser.K_HIGH)
            {
                model.LevelAdditionaly = model.LevelMinus;
                //Multiply with -1 (result: every value can be minimized!)
                model.OppositeOperator = " * -1";
            }
        }