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

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

Introduction

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

Prototype

public int size() 

Source Link

Document

The number of children in this 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;
    }/*from ww w . java2 s  .c  o m*/
    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);
}