Example usage for org.apache.hadoop.conf Configuration getFloat

List of usage examples for org.apache.hadoop.conf Configuration getFloat

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration getFloat.

Prototype

public float getFloat(String name, float defaultValue) 

Source Link

Document

Get the value of the name property as a float.

Usage

From source file:org.mrgeo.ingest.IngestImageReducer.java

License:Apache License

@Override
@SuppressWarnings("rawtypes")
public void setup(final Reducer.Context context) {
    totalTiles = context.getCounter("Ingest Reducer", "Reducer Tiles Processed");
    duplicateTiles = context.getCounter("Ingest Reducer", "Overlapping Tiles");
    storedTiles = context.getCounter("Ingest Reducer", "Stored Tiles");

    Configuration conf = context.getConfiguration();

    double nd = conf.getFloat("nodata", Float.NaN);
    bands = conf.getInt("bands", 1);

    nodata = new double[bands];
    for (int i = 0; i < bands; i++) {
        nodata[i] = nd;// ww  w.  j av a 2 s  . c  o  m
    }
    // Initialize ImageStats array
    stats = ImageStats.initializeStatsArray(bands);
}

From source file:org.mrgeo.mapreduce.formats.EmptyTileInputFormat.java

License:Apache License

@Override
public List<InputSplit> getSplits(final JobContext context) throws IOException, InterruptedException {
    final List<InputSplit> splits = new LinkedList<InputSplit>();

    final Configuration conf = context.getConfiguration();

    final LongRectangle tilebounds = LongRectangle.fromDelimitedString(conf.get(TILE_BOUNDS));

    final int zoom = conf.getInt(ZOOMLEVEL, 0);
    final int tilesize = conf.getInt(TILESIZE, Integer.valueOf(MrGeoProperties.getInstance()
            .getProperty(MrGeoConstants.MRGEO_MRS_TILESIZE, MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT)));
    final int bands = conf.getInt(BANDS, 1);
    final int datatype = conf.getInt(DATATYPE, DataBuffer.TYPE_DOUBLE);
    final double nodata = conf.getFloat(NODATA, Float.NaN);

    final long maxSplits = conf.getInt("mapred.map.tasks", 1);
    final long totalTiles = tilebounds.getWidth() * tilebounds.getHeight();

    long tilesPerSplit = totalTiles / maxSplits;

    if (tilesPerSplit < minTilesPerSplit) {
        tilesPerSplit = minTilesPerSplit;
    }/*  w  w  w  . j ava2s .  c  o m*/

    int cnt = 0;
    List<TileIdWritable> tiles = new LinkedList<TileIdWritable>();

    for (long ty = tilebounds.getMinY(); ty <= tilebounds.getMaxY(); ty++) {
        for (long tx = tilebounds.getMinX(); tx <= tilebounds.getMaxX(); tx++) {
            tiles.add(new TileIdWritable(TMSUtils.tileid(tx, ty, zoom)));
            if (cnt++ > tilesPerSplit) {
                final EmptyTileSplit split = new EmptyTileSplit(zoom, tiles, tilesize, bands, datatype, nodata);
                splits.add(split);

                tiles = new LinkedList<TileIdWritable>();

                cnt = 0;
            }
        }
    }

    if (tiles.size() > 0) {
        final EmptyTileSplit split = new EmptyTileSplit(zoom, tiles, tilesize, bands, datatype, nodata);
        splits.add(split);
    }

    return splits;
}

From source file:reducers.MatrixBlockAddReducer.java

License:Apache License

public void reduce(Text key, Iterable<MatrixBlock> values, Context context)
        throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();
    String name = conf.get("RESNAME");
    String lName = conf.get("LEFTNAME");
    double alpha = (double) conf.getFloat("ALPHA", 1);
    double beta = (double) conf.getFloat("BETA", 1);

    boolean first = false;
    boolean left = false;

    for (MatrixBlock val : values) {
        if (!first) {
            outVal.set(val);

            if (val.name.equals(lName))
                left = true;/*from  w w w.  j a v a  2  s.com*/
            first = true;
        } else {
            if (left)
                outVal.simpleAddIP(val, alpha, beta);
            else
                outVal.simpleAddIP(val, beta, alpha);
        }
    }

    outVal.name = name;

    String[] parts = key.toString().split(",");
    outKey.set(outVal.name + "," + parts[1] + "," + parts[2]);

    context.write(outKey, outVal);
}

From source file:reducers.MatrixBlockMultReducer.java

License:Apache License

public void reduce(Text key, Iterable<MatrixBlock> values, Context context)
        throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();

    String lName = conf.get("LEFTNAME");
    String rName = conf.get("RIGHTNAME");
    String resName = conf.get("RESNAME");

    boolean lTrans = conf.getBoolean("LTRANS", false);
    boolean rTrans = conf.getBoolean("RTRANS", false);

    double scalar = conf.getFloat("SCALAR", 1);

    for (MatrixBlock val : values) {

        if (val.name.equals(lName)) {
            left.set(val);
        } else if (val.name.equals(rName)) {
            right.set(val);
        }//from  w  w  w  .j  av a2  s .c  om
    }

    String[] parts = key.toString().split(",");
    String out = resName + "," + parts[0] + "," + parts[1];
    outKey.set(out);

    //context.write(outKey,left.simpleMult(right,scalar, lTrans,rTrans, resName));
    context.write(outKey, left.dGemm(right, scalar, lTrans, rTrans, resName));
}

From source file:reducers.SquareMatrixBlockTraceMultReducer.java

License:Apache License

public void reduce(Text key, Iterable<MatrixBlock> values, Context context)
        throws IOException, InterruptedException {
    Configuration conf = context.getConfiguration();

    String lName = conf.get("LEFTNAME");
    String rName = conf.get("RIGHTNAME");
    String resName = conf.get("RESNAME");

    boolean lTrans = conf.getBoolean("LTRANS", false);
    boolean rTrans = conf.getBoolean("RTRANS", false);

    double scalar = conf.getFloat("SCALAR", 1);

    for (MatrixBlock val : values) {

        if (val.name.equals(lName)) {
            left.set(val);
        } else if (val.name.equals(rName)) {
            right.set(val);
        }//  w  ww. ja  va 2  s .c  o  m
    }

    outVal.set(left.SquareTraceMult(right, scalar, lTrans, rTrans));
    context.write(NullWritable.get(), outVal);
}

From source file:smile.wide.algorithms.SMILEBSMapper.java

License:Apache License

/** Initializes class parameters*/
@Override// w w  w  . j a v a2 s .c  om
protected void setup(Context context) {
    Configuration conf = context.getConfiguration();
    trainfile = conf.get("trainfile");
    iterationCount = conf.getInt("iterationCount", 20);
    linkProbability = conf.getFloat("linkProbability", 0.01f);
    maxParents = conf.getInt("maxParents", 8);
    maxSearchTime = conf.getInt("maxSearchTime", 0);
    priorLinkProbability = conf.getFloat("priorLinkProbability", 0.001f);
    priorSampleSize = conf.getInt("priorSampleSize", 50);
    randSeed = 0;
    ds.readFile(trainfile);
}