下面列出了org.apache.commons.lang.mutable.MutableFloat#setValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void createReview(final Review reviewRequest, final List<Review.File.Comment> comments, String reviewComment,
final Progress progress) throws Exception {
final RBReview review = client.createReviewApi(reviewRequest.id, null);
final MutableFloat progressF = new MutableFloat(0f);
for (final Review.File.Comment comment : comments) {
progress.progress("Updating comment", progressF.floatValue());
client.createDiffComment(reviewRequest.id, String.valueOf(review.review.id),
comment.file.fileId, comment.firstLine, comment.numberOfLines, comment.text, comment.issueOpened);
progressF.setValue(progressF.floatValue() + 1.0f / (comments.size() - 1));
}
progress.progress("Making review public", progressF.floatValue());
client.updateReviewApi(reviewRequest.id, String.valueOf(review.review.id), true, reviewComment, null);
progress.progress("Review Completed", 1);
}
private static Pair<String, String> consensusSeq(String s1, String s2, String qual1, String qual2, int maxMismatches,
MutableFloat mismatchFrac) {
StringBuffer consensus = new StringBuffer();
StringBuffer consensusQual = new StringBuffer();
int numMismatches = 0;
for (int i=0; i<s1.length(); i++) {
if (s1.charAt(i) != s2.charAt(i)) {
numMismatches += 1;
if (numMismatches > maxMismatches) {
return null;
} else {
if (qual1.charAt(i) >= qual2.charAt(i) + 10) {
consensus.append(s1.charAt(i));
consensusQual.append(qual1.charAt(i));
} else if (qual2.charAt(i) >= qual1.charAt(i) + 10) {
consensus.append(s2.charAt(i));
consensusQual.append(qual2.charAt(i));
} else {
consensus.append('N');
consensusQual.append('!');
}
}
} else {
consensus.append(s1.charAt(i));
consensusQual.append((char) Math.max(qual1.charAt(i), qual2.charAt(i)));
}
}
mismatchFrac.setValue((float) numMismatches / (float) s1.length());
return new Pair<String,String>(consensus.toString(), consensusQual.toString());
}
private void updateLogLikBestModel(JobConf conf, int niter, Map<String, LinearModel> z, String testPath,
boolean ignoreValue, MutableFloat bestTestLoglik, String outBasePath,
int numClickReplicates) throws IOException
{
Map<String, Double> loglik;
loglik = testloglik(conf, z, testPath, 1, ignoreValue);
AvroHdfsFileWriter<GenericRecord> writer =
new AvroHdfsFileWriter<GenericRecord>(conf, outBasePath
+ "/sample-test-loglik/iteration-"+niter +".avro", SampleTestLoglik.SCHEMA$);
DataFileWriter<GenericRecord> testRecordWriter = writer.get();
for (String k : z.keySet())
{
GenericData.Record valuemap = new GenericData.Record(SampleTestLoglik.SCHEMA$);
valuemap.put("iter", niter);
valuemap.put("testLoglik", loglik.get(k).floatValue());
valuemap.put("lambda", k);
testRecordWriter.append(valuemap);
_logger.info("Sample test loglik for lambda=" + k + " is: "
+ String.valueOf(loglik.get(k)));
// output best model up to now
if (loglik.get(k) > bestTestLoglik.floatValue() && niter>0)
{
String bestModelPath = outBasePath + "/best-model/best-iteration-" + niter + ".avro";
FileSystem fs = FileSystem.get(conf);
fs.delete(new Path(outBasePath + "/best-model"), true);
LinearModelUtils.writeLinearModel(conf, bestModelPath, z.get(k), k);
bestTestLoglik.setValue(loglik.get(k).floatValue());
}
}
testRecordWriter.close();
}