Ejemplo n.º 1
0
        public DataTable HandleSelectSqlQuery()
        {
            DataTable result             = new DataTable();
            var       evaluationStrategy = _query.Strategy;

            switch (evaluationStrategy)
            {
            case EvaluationStrategy.Lazy:
            case EvaluationStrategy.Default:
                List <string> tables = _query.GetRevelentTables();
                PrepareReleventTables(tables);
                underlineDatabase.DropTableIfExist(answerTableName);
                OrderedSetIterator iterator = new OrderedSetIterator(tables, underlineDatabase);
                while (iterator.HasNext())
                {
                    var worldNoTuple = iterator.NextSetOfWorldNo();
                    var worldNo      = worldNoTuple.Item1;
                    var probability  = worldNoTuple.Item2;
                    for (int i = 0; i < worldNo.Count; i++)
                    {
                        ConvertWorldToTable(tables[i], worldNo[i]);
                    }
                    //TODO: need to get rid of strategy in ProSQL for execution on DB, or utilise default strategy
                    var a = underlineDatabase.ExecuteSqlWithResult(_query.Sql);
                    WriteResultToAnswerTable(iterator.GetIndex(), a, probability);
                }
                result = NormalisingTableByAttributes(answerTableName);
                return(result);

            case EvaluationStrategy.Naive:
                result = HandleSelectSqlQuery(false);
                return(result);

            case EvaluationStrategy.Extensional:
                var treeWalker = new ExtensionalTreeWalker(_query.QueryTree, underlineDatabase);
                var sql        = treeWalker.GetSql();
                result = underlineDatabase.ExecuteSqlWithResult(sql);
                return(result);
            }
            return(result);

            //   return HandleSelectSqlQuery(false);
        }
        public DataTable HandleSelectSqlQuery()
        {
            DataTable result = new DataTable();
            var evaluationStrategy = _query.Strategy;
            switch (evaluationStrategy)
            {
                case EvaluationStrategy.Lazy:
                case EvaluationStrategy.Default:
                    List<string> tables = _query.GetRevelentTables();
                    PrepareReleventTables(tables);
                    underlineDatabase.DropTableIfExist(answerTableName);
                    OrderedSetIterator iterator = new OrderedSetIterator(tables, underlineDatabase);
                    while (iterator.HasNext())
                    {
                        var worldNoTuple = iterator.NextSetOfWorldNo();
                        var worldNo = worldNoTuple.Item1;
                        var probability = worldNoTuple.Item2;
                        for (int i = 0; i < worldNo.Count; i++ )
                        {
                            ConvertWorldToTable(tables[i], worldNo[i]);
                        }
                        //TODO: need to get rid of strategy in ProSQL for execution on DB, or utilise default strategy
                        var a = underlineDatabase.ExecuteSqlWithResult(_query.Sql);
                        WriteResultToAnswerTable(iterator.GetIndex(),a,probability);
                    }
                    result = NormalisingTableByAttributes(answerTableName);
                    return result;
                case EvaluationStrategy.Naive:
                    result = HandleSelectSqlQuery(false);
                    return result;

                case EvaluationStrategy.Extensional:
                    var treeWalker = new ExtensionalTreeWalker(_query.QueryTree,underlineDatabase);
                    var sql = treeWalker.GetSql();
                    result=underlineDatabase.ExecuteSqlWithResult(sql);
                    return result;
            }
            return result;

             //   return HandleSelectSqlQuery(false);
        }