Example usage for org.apache.hadoop.io DefaultStringifier store

List of usage examples for org.apache.hadoop.io DefaultStringifier store

Introduction

In this page you can find the example usage for org.apache.hadoop.io DefaultStringifier store.

Prototype

public static <K> void store(Configuration conf, K item, String keyName) throws IOException 

Source Link

Document

Stores the item in the configuration with the given keyName.

Usage

From source file:org.apache.sqoop.mapreduce.odps.HdfsOdpsImportJob.java

License:Apache License

private void configureGenericRecordExportInputFormat(Job job, String tableName) throws IOException {
    if (options.getOdpsTable() != null) {
        MapWritable columnTypes = new MapWritable();
        Map<String, OdpsType> colTypeMap = getColTypeMap();
        for (Map.Entry<String, OdpsType> e : colTypeMap.entrySet()) {
            String column = e.getKey();
            if (column != null) {
                Text columnName = new Text(column);
                Text columnType = new Text(toJavaType(e.getValue()));
                columnTypes.put(columnName, columnType);
            }/*ww w .ja v a 2  s  .co m*/
        }
        DefaultStringifier.store(job.getConfiguration(), columnTypes, AvroExportMapper.AVRO_COLUMN_TYPES_MAP);
        return;
    }
    ConnManager connManager = context.getConnManager();
    Map<String, Integer> columnTypeInts;
    if (options.getCall() == null) {
        columnTypeInts = connManager.getColumnTypes(tableName, options.getSqlQuery());
    } else {
        columnTypeInts = connManager.getColumnTypesForProcedure(options.getCall());
    }
    String[] specifiedColumns = options.getColumns();
    MapWritable columnTypes = new MapWritable();
    for (Map.Entry<String, Integer> e : columnTypeInts.entrySet()) {
        String column = e.getKey();
        column = (specifiedColumns == null) ? column : options.getColumnNameCaseInsensitive(column);
        if (column != null) {
            Text columnName = new Text(column);
            Text columnType = new Text(connManager.toJavaType(tableName, column, e.getValue()));
            columnTypes.put(columnName, columnType);
        }
    }
    DefaultStringifier.store(job.getConfiguration(), columnTypes, AvroExportMapper.AVRO_COLUMN_TYPES_MAP);
}

From source file:tachyon.hadoop.ConfUtils.java

License:Apache License

/**
 * Stores the source {@link tachyon.conf.TachyonConf} object to the target
 * Hadoop {@link org.apache.hadoop.conf.Configuration} object.
 *
 * @param source the {@link tachyon.conf.TachyonConf} to be stored
 * @param target the {@link org.apache.hadoop.conf.Configuration} target
 *//*w  ww. j ava2 s.c  o m*/
public static void storeToHadoopConfiguration(TachyonConf source, Configuration target) {
    // Need to set io.serializations key to prevent NPE when trying to get SerializationFactory.
    target.set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerialization,"
            + "org.apache.hadoop.io.serializer.WritableSerialization");
    Properties confProperties = source.getInternalProperties();
    try {
        DefaultStringifier.store(target, confProperties, Constants.TACHYON_CONF_SITE);
    } catch (IOException ex) {
        LOG.error("Unable to store TachyonConf in Hadoop configuration", ex);
        throw new RuntimeException(ex);
    }
}

From source file:tachyon.util.ConfUtils.java

License:Apache License

/**
 * Store the source {@link tachyon.conf.TachyonConf} object to the target
 * Hadoop {@link org.apache.hadoop.conf.Configuration} object.
 *
 * @param source the {@link tachyon.conf.TachyonConf} to be stored
 * @param target the {@link org.apache.hadoop.conf.Configuration} target
 *///from   w  w  w . j  a va 2  s.c  om
public static void storeToHadoopConfiguration(TachyonConf source, Configuration target) {
    // Need to set io.serializations key to prevent NPE when trying to get SerializationFactory.
    target.set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerialization,"
            + "org.apache.hadoop.io.serializer.WritableSerialization");
    Properties confProperties = source.getInternalProperties();
    try {
        DefaultStringifier.store(target, confProperties, Constants.TACHYON_CONF_SITE);
    } catch (IOException ex) {
        LOG.error("Unable to store TachyonConf in Haddop configuration", ex);
        throw new RuntimeException(ex);
    }
}