ml.shifu.guagua.example.kmeans
类 KMeansWorker

java.lang.Object
  继承者 ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>>
      继承者 ml.shifu.guagua.example.kmeans.KMeansWorker
所有已实现的接口:
ml.shifu.guagua.worker.WorkerComputable<KMeansMasterParams,KMeansWorkerParams>

public class KMeansWorker
extends ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>>

KMeansWorker re-computes each record tagged with new category.

To calculate new k centers in master, KMeansWorker also help to accumulate worker info for new k centers by using sum list and count list.


构造方法摘要
KMeansWorker()
           
 
方法摘要
 KMeansWorkerParams doCompute(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
          Using the new k centers to tag each record with index denoting the record belongs to which category.
 void init(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
           
 void initRecordReader(ml.shifu.guagua.io.GuaguaFileSplit fileSplit)
          Reading input line by line
 void load(GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable> currentKey, GuaguaWritableAdapter<org.apache.hadoop.io.Text> currentValue, ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> workerContext)
          Loading data into memory. any invalid data will be set to null.
protected  void postLoad(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
           
 
从类 ml.shifu.guagua.worker.AbstractWorkerComputable 继承的方法
compute, getRecordReader, preLoad, setRecordReader
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

KMeansWorker

public KMeansWorker()
方法详细信息

initRecordReader

public void initRecordReader(ml.shifu.guagua.io.GuaguaFileSplit fileSplit)
                      throws IOException
Reading input line by line

指定者:
ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>> 中的 initRecordReader
抛出:
IOException

init

public void init(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
指定者:
ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>> 中的 init

doCompute

public KMeansWorkerParams doCompute(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
Using the new k centers to tag each record with index denoting the record belongs to which category.

指定者:
ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>> 中的 doCompute

postLoad

protected void postLoad(ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> context)
覆盖:
ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>> 中的 postLoad

load

public void load(GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable> currentKey,
                 GuaguaWritableAdapter<org.apache.hadoop.io.Text> currentValue,
                 ml.shifu.guagua.worker.WorkerContext<KMeansMasterParams,KMeansWorkerParams> workerContext)
Loading data into memory. any invalid data will be set to null.

指定者:
ml.shifu.guagua.worker.AbstractWorkerComputable<KMeansMasterParams,KMeansWorkerParams,GuaguaWritableAdapter<org.apache.hadoop.io.LongWritable>,GuaguaWritableAdapter<org.apache.hadoop.io.Text>> 中的 load


Copyright © 2015. All Rights Reserved.