Example usage for org.apache.hadoop.io DoubleWritable DoubleWritable

List of usage examples for org.apache.hadoop.io DoubleWritable DoubleWritable

Introduction

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

Prototype

public DoubleWritable() 

Source Link

Usage

From source file:com.linkedin.cubert.io.CompactWritablesDeserializer.java

License:Open Source License

private static final WritableComparable<?> createWritable(DataType type) {
    switch (type) {
    case BOOLEAN:
        return new BooleanWritable();
    case BYTE://from w w w. j a v a2  s.c o  m
        return new ByteWritable();
    case INT:
        return new IntWritable();
    case LONG:
        return new LongWritable();
    case FLOAT:
        return new FloatWritable();
    case DOUBLE:
        return new DoubleWritable();
    case STRING:
        return new Text();
    default:
        return null;
    }
}

From source file:com.marcolotz.MRComponents.SerializerConverter.java

License:Creative Commons License

/***
 * Reads a double from the input/*from   www  . jav  a 2s.c  o m*/
 * @param datainput
 * @return the double readen
 * @throws IOException
 */
public static double readDouble(DataInput datainput) throws IOException {
    DoubleWritable readenDouble = new DoubleWritable();
    readenDouble.readFields(datainput);
    return readenDouble.get();
}

From source file:com.mongodb.hadoop.examples.lolmatches.LOLMatchesdMapper.java

License:Apache License

public LOLMatchesdMapper() {
    super();
    keyInt = new IntWritable();
    valueDouble = new DoubleWritable();
}

From source file:com.moz.fiji.mapreduce.lib.reduce.DoubleSumReducer.java

License:Apache License

/** {@inheritDoc} */
@Override//from  www  .ja  va  2 s  .c  om
protected void setup(Context context) throws IOException, InterruptedException {
    super.setup(context);
    mValue = new DoubleWritable();
}

From source file:com.mozilla.grouperfish.mahout.clustering.display.lda.DisplayLDATopics.java

License:Apache License

public static Map<Integer, PriorityQueue<Pair<Double, String>>> getTopWordsByTopics(String stateDirPath,
        Map<Integer, String> featureIndex, int numWordsToPrint) {
    Map<Integer, Double> expSums = new HashMap<Integer, Double>();
    Map<Integer, PriorityQueue<Pair<Double, String>>> queues = new HashMap<Integer, PriorityQueue<Pair<Double, String>>>();
    SequenceFileDirectoryReader reader = null;
    try {// w  w w  .  j  ava 2  s .  c  om
        IntPairWritable k = new IntPairWritable();
        DoubleWritable v = new DoubleWritable();
        reader = new SequenceFileDirectoryReader(new Path(stateDirPath));
        while (reader.next(k, v)) {
            int topic = k.getFirst();
            int featureId = k.getSecond();
            if (featureId >= 0 && topic >= 0) {
                double score = v.get();
                Double curSum = expSums.get(topic);
                if (curSum == null) {
                    curSum = 0.0;
                }
                expSums.put(topic, curSum + Math.exp(score));
                String feature = featureIndex.get(featureId);

                PriorityQueue<Pair<Double, String>> q = queues.get(topic);
                if (q == null) {
                    q = new PriorityQueue<Pair<Double, String>>(numWordsToPrint);
                }
                enqueue(q, feature, score, numWordsToPrint);
                queues.put(topic, q);
            }
        }
    } catch (IOException e) {
        LOG.error("Error reading LDA state dir", e);
    } finally {
        if (reader != null) {
            reader.close();
        }
    }

    for (Map.Entry<Integer, PriorityQueue<Pair<Double, String>>> entry : queues.entrySet()) {
        int topic = entry.getKey();
        for (Pair<Double, String> p : entry.getValue()) {
            double score = p.getFirst();
            p.setFirst(Math.exp(score) / expSums.get(topic));
        }
    }

    return queues;
}

From source file:de.kp.core.spade.hadoop.ExtEquivalenceClassListWritable.java

License:Open Source License

public ExtEquivalenceClassListWritable() {

    this.sequences = new IntWritable();
    this.size = new IntWritable();

    this.minsupp = new DoubleWritable();
    this.eqClasList = new EquivalenceClassListWritable();

}

From source file:edu.cuhk.hccl.data.NounPhrase.java

License:Apache License

public NounPhrase() {
    setAdjective(new Text());
    setNoun(new Text());
    setAspect(new Text());
    setRating(new IntWritable());
    setSimilarity(new DoubleWritable());
}

From source file:edu.ub.ahstfg.kmeans.document.DocumentCentroid.java

License:Open Source License

@Override
public void readFields(DataInput in) throws IOException {
    ArrayWritable k = new ArrayWritable(IntWritable.class);
    k.readFields(in);//from  w ww .j  a  v  a2s .c  o m
    keywordVector = WritableConverter.arrayWritable2ShortArray(k);
    ArrayWritable t = new ArrayWritable(IntWritable.class);
    t.readFields(in);
    termVector = WritableConverter.arrayWritable2ShortArray(t);
    DoubleWritable dist = new DoubleWritable();
    dist.readFields(in);
    distance = dist.get();
}

From source file:edu.uci.ics.hivesterix.serde.lazy.LazyDouble.java

License:Apache License

public LazyDouble(LazyDoubleObjectInspector oi) {
    super(oi);
    data = new DoubleWritable();
}

From source file:edu.uci.ics.pregelix.example.converter.VLongIdInputVertexConverter.java

License:Apache License

private void initializeVertexValue(ATypeTag typeTag) {
    switch (typeTag) {
    case INT8:/*from   www.java 2  s. c o  m*/
    case INT16:
    case INT32:
    case INT64: {
        vertexValue = new VLongWritable();
        break;
    }
    case BOOLEAN: {
        vertexValue = new BooleanWritable();
        break;
    }
    case FLOAT: {
        vertexValue = new FloatWritable();
        break;
    }
    case DOUBLE: {
        vertexValue = new DoubleWritable();
        break;
    }
    case STRING: {
        vertexValue = new Text();
        break;
    }
    default: {
        throw new NotImplementedException("Not able to deal with AsterixDB type " + typeTag);
    }
    }
}