001    /*
002     * $RCSfile: FileCatalog.java,v $
003     *
004     * Created on December 13, 2002, 12:54 PM
005     *
006     * This file is part of the STAR Scheduler.
007     * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory
008     *
009     * STAR Scheduler is free software; you can redistribute it and/or modify
010     * it under the terms of the GNU General Public License as published by
011     * the Free Software Foundation; either version 2 of the License, or
012     * (at your option) any later version.
013     *
014     * STAR Scheduler is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017     * GNU General Public License for more details.
018     *
019     * You should have received a copy of the GNU General Public License
020     * along with STAR Scheduler; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022     */
023    package gov.bnl.star.offline.scheduler.catalog;
024    
025    import gov.bnl.star.offline.scheduler.ComponentLibrary;
026    import java.util.Iterator;
027    import java.util.logging.Logger;
028    
029    
030    
031    /** @deprecated please see gov.bnl.star.offline.scheduler.dataset.* for replacements. 
032     * 
033     * Represent the file catalog interface. To make the scheduler interoperate with
034     * other file catalog, just implement this interface in a new class.
035     *
036     * @author  Gabriele Carcassi
037     * @version $Revision: 1.11 $ $Date: 2006/11/21 00:41:31 $
038     */
039    public abstract class FileCatalog {
040        static private Logger log = Logger.getLogger(FileCatalog.class.getName());
041        private static FileCatalog catalog;
042    
043        /** Gets the default file catalog Class.
044         * @return the file catalog
045         */
046        public static FileCatalog getCatalog() {
047            if (catalog == null) initCatalog();
048            // TODO: The catalog factory might need to be extend. Different catalog
049            // "hosts" might require different implementations.
050            return catalog;
051        }
052    
053        private static void initCatalog() {
054            catalog = ComponentLibrary.getInstance().getDefaultFileCatalog();
055        }
056        
057        static void initCatalog(FileCatalog catalog) {
058            FileCatalog.catalog = catalog;
059        }
060    
061        /** Executes the query and returns all the results.
062         * @param query the query to be executed
063         * @return a PhysicalFile iterator
064         */
065        public abstract Iterator executeQuery(String query);
066    
067        /** Executes the query with an estimate on the number of results. The catalog should
068         * be able to make some optimizations in this case.
069         * @param query the query to be executed
070         * @param nExpectedResults an estimate of input files that are required
071         * @return a PhysicalFile iterator
072         */
073        public abstract Iterator executeQuery(String query, int nExpectedResults);
074    
075        /** Executes the query with the star/limit syntax.
076         * @param query the query to be executed
077         * @param start the offset from which start to read
078         * @param limit the number of records returned
079         * @return a PhysicalFile iterator
080         */
081        public abstract Iterator executeQuery(String query, int start, int limit);
082    }