/** * (c) Copyright 2012 WibiData, Inc. * * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.kiji.mapreduce; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.kiji.annotations.ApiAudience; import org.kiji.annotations.ApiStability; import org.kiji.schema.KijiTable; import org.kiji.schema.impl.hbase.HBaseKijiTable; /** * Loads HFiles generated by a MapReduce job into a Kiji table. * * @see org.kiji.mapreduce.output.HFileMapReduceJobOutput * @see org.kiji.mapreduce.tools.KijiBulkLoad */ @ApiAudience.Public @ApiStability.Evolving public final class HFileLoader { private static final Logger LOG = LoggerFactory.getLogger(HFileLoader.class); private final Configuration mConf; /** * Creates a new <code>HFileLoader</code> instance. * * @param conf The Hadoop configuration. */ private HFileLoader(Configuration conf) { mConf = conf; } /** * Creates a new HFile loader. * * @param conf The configuration to be used by the new loader. * @return A new loader that can be used to add HFiles to HBase tables. */ public static HFileLoader create(Configuration conf) { return new HFileLoader(conf); } /** * Loads partitioned HFiles directly into the regions of a Kiji table. * * @param hfilePath The path to the HFiles generated by a bulk-import job. * @param table The target kiji table. * @throws IOException If there is an error. */ public void load(Path hfilePath, KijiTable table) throws IOException { HBaseKijiTable.downcast(table).bulkLoad(hfilePath); } }