Example usage for org.apache.hadoop.mapreduce.lib.db DBConfiguration setOutputFieldNames

List of usage examples for org.apache.hadoop.mapreduce.lib.db DBConfiguration setOutputFieldNames

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.lib.db DBConfiguration setOutputFieldNames.

Prototype

public void setOutputFieldNames(String... fieldNames) 

Source Link

Usage

From source file:com.cloudera.sqoop.mapreduce.db.DBOutputFormat.java

License:Apache License

/**
 * Initializes the reduce-part of the job with
 * the appropriate output settings.//from ww  w  . j a v a2 s. c om
 *
 * @param job The job
 * @param tableName The table to insert data into
 * @param fieldNames The field names in the table.
 */
public static void setOutput(Job job, String tableName, String... fieldNames) throws IOException {
    if (fieldNames.length > 0 && fieldNames[0] != null) {
        DBConfiguration dbConf = setOutput(job, tableName);
        dbConf.setOutputFieldNames(fieldNames);
    } else {
        if (fieldNames.length > 0) {
            setOutput(job, tableName, fieldNames.length);
        } else {
            throw new IllegalArgumentException("Field names must be greater than 0");
        }
    }
}

From source file:link.neolink.datamonster.DBUpdateOutputFormat.java

License:Apache License

/**
 * Initializes the reduce-part of the job with
 * the appropriate output settings./*from   ww  w .ja  v  a 2 s.c o  m*/
 *
 * @param job
 *    The job.
 * @param tableName
 *    The table to insert data into.
 * @param fieldNames
 *    The field names in the table.
 */
public static void setOutput(Job job, String tableName, String... fieldNames) throws IOException {
    if (fieldNames.length > 0 && fieldNames[0] != null) {
        DBConfiguration dbConf = setOutput(job, tableName);
        dbConf.setOutputFieldNames(fieldNames);
    } else if (fieldNames.length > 0) {
        setOutput(job, tableName, fieldNames.length);
    } else {
        throw new IllegalArgumentException("Field names must be greater than 0");
    }
}

From source file:link.neolink.datamonster.DBUpdateOutputFormat.java

License:Apache License

/**
 * Initializes the reduce-part of the job with
 * the appropriate output settings./*from   w w w.j  ava2 s  .  c om*/
 *
 * @param job
 *    The job.
 * @param tableName
 *    The table to insert data into.
 * @param fieldNames
 *    The field names in the table (as SET field = ?).
 * @param conditionalFields
 *    The conditional fields (as WHERE field = ?).
 */
public static void setOutput(Job job, String tableName, String[] fieldNames, String[] conditionalFields)
        throws IOException {
    String[] fields = new String[fieldNames.length + conditionalFields.length + 1];
    Integer i = 0;
    for (String fieldName : fieldNames) {
        fields[i++] = fieldName;
    }
    fields[i++] = "/";
    for (String conditionalField : conditionalFields) {
        fields[i++] = conditionalField;
    }

    if (fields.length > 0 && fields[0] != null) {
        DBConfiguration dbConf = setOutput(job, tableName);
        dbConf.setOutputFieldNames(fields);
    } else if (fieldNames.length > 0) {
        setOutput(job, tableName, fields.length);
    } else {
        throw new IllegalArgumentException("Field names must be greater than 0");
    }
}