List of usage examples for org.apache.mahout.math VectorWritable write
@Override public void write(DataOutput out) throws IOException
From source file:Vectors.java
License:Apache License
public static void write(Vector vector, Path path, Configuration conf, boolean laxPrecision) throws IOException { FileSystem fs = FileSystem.get(path.toUri(), conf); FSDataOutputStream out = fs.create(path); try {/*from w w w . jav a 2s . c o m*/ VectorWritable vectorWritable = new VectorWritable(vector); vectorWritable.setWritesLaxPrecision(laxPrecision); vectorWritable.write(out); } finally { Closeables.closeQuietly(out); } }
From source file:org.gpfvic.mahout.cf.taste.hadoop.item.PrefAndSimilarityColumnWritable.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { out.writeFloat(prefValue);// w w w . j a v a 2s . co m VectorWritable vw = new VectorWritable(similarityColumn); vw.setWritesLaxPrecision(true); vw.write(out); }
From source file:org.gpfvic.mahout.cf.taste.hadoop.item.VectorAndPrefsWritable.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { VectorWritable vw = new VectorWritable(vector); vw.setWritesLaxPrecision(true);// w w w . ja v a2 s . c o m vw.write(out); Varint.writeUnsignedVarInt(userIDs.size(), out); for (int i = 0; i < userIDs.size(); i++) { Varint.writeSignedVarLong(userIDs.get(i), out); out.writeFloat(values.get(i)); } }
From source file:org.gpfvic.mahout.cf.taste.hadoop.item.VectorOrPrefWritable.java
License:Apache License
@Override public void write(DataOutput out) throws IOException { if (vector == null) { out.writeBoolean(false);//w ww. j av a 2 s. co m Varint.writeSignedVarLong(userID, out); out.writeFloat(value); } else { out.writeBoolean(true); VectorWritable vw = new VectorWritable(vector); vw.setWritesLaxPrecision(true); vw.write(out); } }