List of usage examples for org.apache.hadoop.io DoubleWritable DoubleWritable
public DoubleWritable(double value)
From source file:hadoop.twitter.mapreduce.UserWritable.java
public UserWritable(Double pageRank, String followee) { this.pageRank = new DoubleWritable(pageRank); this.followee = new Text(followee); }
From source file:hadoop.twitter.mapreduce.UserWritable.java
public void setPageRank(Double pageRank) { this.pageRank = new DoubleWritable(pageRank); }
From source file:hadoop.twitter.mapreduce.UserWritable.java
public void set(Double pageRank, Text follower) { this.pageRank = new DoubleWritable(pageRank); this.followee = follower; }
From source file:Hama_MMMAS.HAMA_TEST.java
@Override public void bsp(BSPPeer<NullWritable, NullWritable, Text, DoubleWritable, DoubleTwoDArrayWritable> peer) throws IOException, SyncException, InterruptedException { //superstep -1 :?The_DistanceThe_Distance_Beta // getInitialDistanceALPHA(peer); getInitialDistanceBETA(peer);//from ww w . ja va2 s . c om // superstep 0 :get initial matrix getInitialMatrix(peer); //Need a "peer.sync()"here? maybe no int iterations = 0; while (true) { if (iterations > maxIterations) break; //superstep 1 : calculate the Matrix in parallel double[][] localMatrix; localMatrix = calculateLocalMatrix(); //The Matrix is sent and aggregated by each broadcastMatrix(peer, localMatrix); peer.sync(); //superstep 2 :aggregate Matrix calculation double[][] newMatrix = new double[localMatrix.length][localMatrix[0].length]; newMatrix = aggregateTheMatrix(peer, newMatrix); //update The_Matrix updateTheta(peer, newMatrix); if (log.isDebugEnabled()) { log.debug("{}: new matrix is {}", new Object[] { peer.getPeerName(), newMatrix }); } if (master) { peer.write(new Text("Now The Best IS "), new DoubleWritable(mmas.GlobalBestAnt.TourLength)); } peer.sync(); iterations++; } }
From source file:Hama_MMMAS.HAMA_TEST.java
@Override public void cleanup(BSPPeer<NullWritable, NullWritable, Text, DoubleWritable, DoubleTwoDArrayWritable> peer) throws IOException { //still need to finish this part //here,write(k2,v2),k2&v2 means key of output and value of output,they should be same with the third & forth //master writes down the final outputIOException, SyncException, InterruptedException{ //still need to finish this part //here,write(k2,v2),k2&v2 means key of output and value of output,they should be same with the third & forth //master writes down the final output if (master) { peer.write(new Text("The Final is "), new DoubleWritable(mmas.GlobalBestAnt.TourLength)); // if (log.isInfoEnabled()) { // log.info("{}:computation finished with cost {} and theta {}", new Object[]{peer.getPeerName(), cost, theta}); }//from w ww .ja va2 s .co m // } }
From source file:Hama_MMMAS.HAMA_TEST.java
private void broadcastMatrix( BSPPeer<NullWritable, NullWritable, Text, DoubleWritable, DoubleTwoDArrayWritable> peer, double[][] Matrix) throws IOException { int col, row; col = Matrix.length;/* w w w . jav a 2 s.c o m*/ row = Matrix[0].length; DoubleTwoDArrayWritable Send_Matrix = new DoubleTwoDArrayWritable(); DoubleWritable[][] Recieve_Matrix = new DoubleWritable[col][row]; for (int k1 = 0; k1 < col; k1++) { for (int j1 = 0; j1 < row; j1++) { Recieve_Matrix[k1][j1] = new DoubleWritable(Matrix[k1][j1]); } } Send_Matrix.set(Recieve_Matrix); for (String peerName : peer.getAllPeerNames()) { if (!peerName.equals(peer.getPeerName())) { // avoid sending to oneself peer.send(peerName, Send_Matrix); } } }
From source file:hbasemath.AbstractVector.java
License:Apache License
public void initMap(Result rs) { this.entries = new MapWritable(); NavigableMap<byte[], byte[]> map = rs.getFamilyMap(Constants.COLUMNFAMILY); for (Map.Entry<byte[], byte[]> e : map.entrySet()) { if (e != null) { this.entries.put(new IntWritable(BytesUtil.bytesToInt(e.getKey())), new DoubleWritable(Bytes.toDouble(e.getValue()))); }/* www . jav a 2 s. co m*/ } }
From source file:hbasemath.SparseVector.java
License:Apache License
@Override public Vector add(double alpha, Vector v) { if (alpha == 0) return this; for (Map.Entry<Writable, Writable> e : v.getEntries().entrySet()) { if (this.entries.containsKey(e.getKey())) { // add double value = alpha * ((DoubleWritable) e.getValue()).get() + this.get(((IntWritable) e.getKey()).get()); this.entries.put(e.getKey(), new DoubleWritable(value)); } else {/*www .j a v a 2 s . co m*/ // put double value = alpha * ((DoubleWritable) e.getValue()).get(); this.entries.put(e.getKey(), new DoubleWritable(value)); } } return this; }
From source file:hbasemath.SparseVector.java
License:Apache License
/** * v = alpha*v/*from w w w.ja v a2s . co m*/ * * @param alpha * @return v = alpha*v */ public SparseVector scale(double alpha) { for (Map.Entry<Writable, Writable> e : this.entries.entrySet()) { this.entries.put(e.getKey(), new DoubleWritable(((DoubleWritable) e.getValue()).get() * alpha)); } return this; }
From source file:hbasemath.SparseVector.java
License:Apache License
/** * Sets the value of index// w w w. ja v a 2s. c om * * @param index * @param value */ public void set(int index, double value) { // If entries are null, create new object if (this.entries == null) { this.entries = new MapWritable(); } if (value != 0) // only stores non-zero element this.entries.put(new IntWritable(index), new DoubleWritable(value)); }