Example usage for org.apache.hadoop.util Options prependOptions

List of usage examples for org.apache.hadoop.util Options prependOptions

Introduction

In this page you can find the example usage for org.apache.hadoop.util Options prependOptions.

Prototype

public static <T> T[] prependOptions(T[] oldOpts, T... newOpts) 

Source Link

Document

Prepend some new options to the old options

Usage

From source file:com.foursquare.twofishes.io.MapFileConcurrentReader.java

License:Apache License

protected synchronized void open(Path dir, WritableComparator comparator, final Configuration conf,
        final SequenceFile.Reader.Option... options) throws IOException {
    final Path dataFile = new Path(dir, MapFile.DATA_FILE_NAME);
    final Path indexFile = new Path(dir, MapFile.INDEX_FILE_NAME);

    // open the data
    this.data = new ThreadLocal<SequenceFile.Reader>() {
        protected SequenceFile.Reader initialValue() {
            try {
                SequenceFile.Reader r = createDataFileReader(dataFile, conf, options);
                LOG.info("opened new SequenceFile.Reader for " + dataFile);
                synchronized (this) {
                    allDataFiles.add(r);
                }/*from   w ww . j  av a2s  .com*/
                return r;
            } catch (IOException ioe) {
                throw new RuntimeException(ioe);
            }
        }
    };
    this.firstPosition = data.get().getPosition();

    this.comparator = WritableComparator.get(data.get().getKeyClass().asSubclass(WritableComparable.class));

    // open the index
    SequenceFile.Reader.Option[] indexOptions = Options.prependOptions(options,
            SequenceFile.Reader.file(indexFile));
    this.index = new SequenceFile.Reader(conf, indexOptions);
}

From source file:com.foursquare.twofishes.io.MapFileConcurrentReader.java

License:Apache License

/**
 * Override this method to specialize the type of
 * {@link SequenceFile.Reader} returned.
 *//*from  w  w w. j a  v a 2 s . c  o  m*/
protected SequenceFile.Reader createDataFileReader(Path dataFile, Configuration conf,
        SequenceFile.Reader.Option... options) throws IOException {
    SequenceFile.Reader.Option[] newOptions = Options.prependOptions(options,
            SequenceFile.Reader.file(dataFile));
    return new SequenceFile.Reader(conf, newOptions);
}

From source file:com.uber.hoodie.common.file.HoodieAppendLog.java

License:Apache License

/**
 * Create a new Writer with the given options.
 * @param conf the configuration to use/*from w w  w .j ava 2  s .c  o m*/
 * @param opts the options to create the file with
 * @return a new Writer
 * @throws IOException
 */
public static Writer createWriter(Configuration conf, Writer.Option... opts) throws IOException {
    Writer.CompressionOption compressionOption = Options.getOption(Writer.CompressionOption.class, opts);
    CompressionType kind;
    if (compressionOption != null) {
        kind = compressionOption.getValue();
    } else {
        kind = getDefaultCompressionType(conf);
        opts = Options.prependOptions(opts, Writer.compression(kind));
    }
    switch (kind) {
    default:
    case NONE:
        return new Writer(conf, opts);
    case RECORD:
        return new RecordCompressWriter(conf, opts);
    case BLOCK:
        return new BlockCompressWriter(conf, opts);
    }
}