/** * @param current * @param type * @return * @throws IOException */ private File getProjectFile(File current, ProjectType type, String target_dir, String target_ext) throws IOException { boolean has_svn = false; for (File file : current.listFiles()) { if (file.getCanonicalPath().endsWith("files") && file.isDirectory()) { // Look for either a .<target_ext> or a .<target_ext>.gz file String file_name = type.name().toLowerCase() + target_ext; for (int i = 0; i < 2; i++) { if (i > 0) file_name += ".gz"; File target_file = new File(file + File.separator + target_dir + File.separator + file_name); if (target_file.exists() && target_file.isFile()) { return (target_file); } } // FOR assert (false) : "Unable to find '" + file_name + "' for '" + type + "' in directory '" + file + "'"; // Make sure that we don't go to far down... } else if (file.getCanonicalPath().endsWith("/.svn")) { has_svn = true; } } // FOR assert (has_svn) : "Unable to find files directory [last_dir=" + current.getAbsolutePath() + "]"; File next = new File(current.getCanonicalPath() + File.separator + ".."); return (this.getProjectFile(next, type, target_dir, target_ext)); }
@SuppressWarnings("unchecked") public static <T extends AbstractFixedEstimator> T factory( PartitionEstimator p_estimator, CatalogContext catalogContext) { AbstractFixedEstimator estimator = null; ProjectType ptype = ProjectType.get(catalogContext.database.getProject()); switch (ptype) { case TPCC: estimator = new FixedTPCCEstimator(p_estimator); break; case TM1: estimator = new FixedTM1Estimator(p_estimator); break; case SEATS: estimator = new FixedSEATSEstimator(p_estimator); break; case VOTER: estimator = new FixedVoterEstimator(p_estimator); break; default: estimator = new DefaultFixedEstimator(p_estimator); } // SWITCH return ((T) estimator); }