Example #1
0
        public void predictForTier(String configPredictionPath, int tier)
        {
            //predict runtimes using training and testing
            ProcessStartInfo info = new ProcessStartInfo("java");

            info.WindowStyle            = ProcessWindowStyle.Hidden;
            info.UseShellExecute        = false;
            info.RedirectStandardOutput = true;

            var predictCommand = String.Format("-classpath \"{0}\" weka.classifiers.rules.M5Rules -M 4.0 -t \"{1}\" -T {2} -p 0 -classifications \"weka.classifiers.evaluation.output.prediction.PlainText  -suppress -file {3}\"",
                                               Path.GetFullPath(configurationFolderPath + @"/predictions_for_tiers/weka.jar"),
                                               Path.GetFullPath(configPredictionPath + "/TRAINING.arff"),
                                               Path.GetFullPath(configPredictionPath + "/TESTING.arff"),
                                               Path.GetFullPath(configPredictionPath + "/results.txt"));


            info.Arguments = predictCommand;
            Process.Start(info).WaitForExit();

            //parse prediction results
            FileReaderUtils.parsePredictionResults(configPredictionPath, tier);
        }
Example #2
0
        /*
         * Given a schema, load information about the dataset and generate queries
         */
        public void dataQueryGeneration()
        {
            //finding number of tiers
            FileReaderUtils.readTiers(configurationFolderPath, tierFile);
            Console.WriteLine("Number of Tiers found: " + tiers.Count());

            //read the data schema
            Console.WriteLine("Reading the Data Schema from " + schemaFile + "...");
            FileReaderUtils.readDataSchema(configurationFolderPath, schemaFile);

            int queryID = 1;

            //first generate single table queries
            foreach (var currentSingleTable in listOfTables)
            {
                List <String> selectionattributesForTables = currentSingleTable.tableSelectivityList;
                for (int i = 1; i <= currentSingleTable.tableAttributeList.Count(); i++)   //possible projections
                {
                    int counter = 0;
                    List <Attribute> projectingAttributes = (from a in currentSingleTable.tableAttributeList
                                                             orderby a.attributeSize descending
                                                             select a).Take(i).ToList();
                    foreach (var currentCoverage in selectionattributesForTables)   //possible selectivities
                    {
                        foreach (var currentTier in tiers)
                        {
                            listOfQueries.Add(new SingleTableQuery(queryID, projectingAttributes, new List <Table> {
                                currentSingleTable
                            },
                                                                   currentSingleTable.tablePrimaryKey, currentCoverage, selectivities[counter],
                                                                   currentSingleTable, currentTier));
                        }
                        queryID++;
                        counter++;
                    }
                }
            }

            //generate join queries
            List <Table> totalDimensions = (from a in listOfTables
                                            where a is Dimension
                                            orderby a.tableSize descending
                                            select a).ToList();

            for (int i = 1; i < listOfTables.Count(); i++)
            {
                List <Table> tablesToJoin = (totalDimensions).Take(i).ToList();
                tablesToJoin.Add(factTable);

                //attributes from fact
                List <Attribute> completeAttributeList = new List <Attribute>();
                foreach (var currentAttribute in factTable.tableAttributeList.ToList())
                {
                    completeAttributeList.Add(new Attribute(currentAttribute.attributeName, currentAttribute.attributeSize, factTable));
                }

                //attributes from the dimension tables
                foreach (var currentTable in tablesToJoin.Where(x => !(x is Fact)))
                {
                    foreach (var currentAttr in currentTable.tableAttributeList)
                    {
                        if (!completeAttributeList.Contains(currentAttr))
                        {
                            completeAttributeList.Add(new Attribute(currentAttr.attributeName, currentAttr.attributeSize, currentTable));
                        }
                    }
                }

                List <String> selectionattributesForTables = tablesToJoin.Contains(factTable) ?
                                                             factTable.tableSelectivityList : tablesToJoin.First().tableSelectivityList;


                for (int j = 1; j <= completeAttributeList.Count(); j++)
                {
                    int counter = 0;
                    List <Attribute> projectingAttributes = (from a in completeAttributeList
                                                             orderby a.attributeSize descending
                                                             select a).Take(j).ToList();


                    foreach (var currentCoverage in selectionattributesForTables)
                    {
                        foreach (var currentTiers in tiers)
                        {
                            listOfQueries.Add(new JoinQuery(queryID, projectingAttributes, new Attribute(factTable.tablePrimaryKey.attributeName,
                                                                                                         factTable.tablePrimaryKey.attributeSize, factTable),
                                                            currentCoverage, selectivities[counter], tablesToJoin, factTable, currentTiers));
                        }
                        queryID++;
                        counter++;
                    }
                }
            }

            //output queries
            StreamWriter queryOutput = new StreamWriter(Path.Combine(configurationFolderPath, "SQLQueries-Generated.txt"));

            foreach (var currentQuery in listOfQueries.Where(l => l.queryTier == 1))
            {
                queryOutput.WriteLine(currentQuery.ToString());
            }
            queryOutput.Close();
        }