Example usage for org.apache.hadoop.mapred.join TupleWritable get

List of usage examples for org.apache.hadoop.mapred.join TupleWritable get

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred.join TupleWritable get.

Prototype

public Writable get(int i) 

Source Link

Document

Get ith Writable from Tuple.

Usage

From source file:org.apache.mahout.clustering.lda.cvb.CVB0PriorMapper.java

License:Apache License

@Override
public void map(IntWritable docId, TupleWritable tuple, OutputCollector<IntWritable, VectorWritable> out,
        Reporter reporter) throws IOException {
    if (this.reporter == null || this.out == null) {
        this.reporter = reporter;
        this.out = out;
    }// w  ww  .j  a  va2s. com
    VectorWritable document = (VectorWritable) tuple.get(0);
    VectorWritable docTopicPrior = tuple.size() > 1 ? (VectorWritable) tuple.get(1)
            : new VectorWritable(new DenseVector(numTopics).assign(1.0 / numTopics));

    TopicModel model = modelTrainer.getReadModel();
    Matrix docTopicModel = new SparseRowMatrix(numTopics, document.get().size(), true);
    // iterate one step on p(topic | doc)
    model.trainDocTopicModel(document.get(), docTopicPrior.get(), docTopicModel);
    // update the model
    model.update(docTopicModel);
    // emit the updated p(topic | doc)
    multipleOutputs.getCollector(DOCTOPIC_OUT, reporter).collect(docId, docTopicPrior);
}