/** * Initialize with default profile ID using Configuration and output * description passsed in. * @param conf Configuration to use * @param outputDesc HiveOutputDescription * @throws TException Hive Metastore issues */ public static void initDefaultProfile(Configuration conf, HiveOutputDescription outputDesc) throws TException, IOException { initProfile(conf, outputDesc, DEFAULT_PROFILE_ID); }
/** * Initialize using object's profile ID with Configuration and output * description passed in. * @param conf Configuration to use * @param outputDesc HiveOutputDescription * @throws TException Hive Metastore issues */ public void init(Configuration conf, HiveOutputDescription outputDesc) throws TException, IOException { initProfile(conf, outputDesc, myProfileId); }
/** * Initialize this output format * * @param outputDescription Output description * @param profileId Profile id * @param conf Configuration */ public void initialize(HiveOutputDescription outputDescription, String profileId, Configuration conf) { checkNotNull(outputDescription, "inputDescription is null"); checkNotNull(profileId, "profileId is null"); checkNotNull(conf, "conf is null"); try { setMyProfileId(profileId); initProfile(conf, outputDescription, profileId); HiveTableSchemas.initTableSchema(conf, profileId, outputDescription.getTableDesc()); } catch (IOException e) { throw new IllegalStateException("initialize: IOException occurred", e); } }
/** * Setup the job * * @param conf Configuration * @throws IOException */ public static void setupJob(Configuration conf) throws IOException { HiveOutputDescription outputDesc = new HiveOutputDescription(); outputDesc.setTableDesc(getHiveTableName()); Map<String, String> partitionValues = ImmutableMap.of("ds", "2013-04-01"); outputDesc.setPartitionValues(partitionValues); LOG.info("Writing to {}", outputDesc); try { HiveApiOutputFormat.initProfile(conf, outputDesc, SampleOutputFormat.SAMPLE_PROFILE_ID); } catch (IOException e) { LOG.error("Failed to initialize profile {}", outputDesc); throw e; } }
conf.set("mapred.task.id", taskAttemptIdStr); HiveApiOutputFormat.initProfile(conf, outputDesc, profile);