001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package org.apache.hadoop.mapreduce.lib.db;
020    
021    import java.sql.ResultSet;
022    import java.sql.SQLException;
023    import java.util.List;
024    
025    import org.apache.hadoop.classification.InterfaceAudience;
026    import org.apache.hadoop.classification.InterfaceStability;
027    import org.apache.hadoop.conf.Configuration;
028    import org.apache.hadoop.mapreduce.InputSplit;
029    
030    /**
031     * DBSplitter will generate DBInputSplits to use with DataDrivenDBInputFormat.
032     * DataDrivenDBInputFormat needs to interpolate between two values that
033     * represent the lowest and highest valued records to import. Depending
034     * on the data-type of the column, this requires different behavior.
035     * DBSplitter implementations should perform this for a data type or family
036     * of data types.
037     */
038    @InterfaceAudience.Public
039    @InterfaceStability.Evolving
040    public interface DBSplitter {
041      /**
042       * Given a ResultSet containing one record (and already advanced to that record)
043       * with two columns (a low value, and a high value, both of the same type), determine
044       * a set of splits that span the given values.
045       */
046      List<InputSplit> split(Configuration conf, ResultSet results, String colName) throws SQLException;
047    }