Java 类org.apache.commons.lang.mutable.MutableFloat 实例源码
项目:review-board-idea-plugin
文件:ReviewDataProvider.java
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);
}
项目:abra2
文件:SAMRecordUtils.java
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());
}
项目:ml-ease
文件:RegressionAdmmTrain.java
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();
}
项目:review-board-idea-plugin
文件:ReviewDataProvider.java
public List<Review.File> files(final Review review, final Progress progress) throws Exception {
List<Review.File> result = new ArrayList<>();
final List<Future> futures = new CopyOnWriteArrayList<>();
final MutableFloat progressF = new MutableFloat(0f);
final RBDiffList diffList = client.diffListApi(review.id);
if (diffList.total_results > 0) {
final String revision = String.valueOf(diffList.diffs[0].revision);
RBFileDiff fileDiff = client.fileDiffApi(review.id, revision);
for (final RBFileDiff.File file : fileDiff.files) {
final Review.File diffFile = new Review.File();
diffFile.fileId = file.id;
diffFile.srcFileName = file.source_file;
diffFile.dstFileName = file.dest_file;
diffFile.sourceRevision = file.source_revision;
diffFile.revision = revision;
futures.add(ApplicationManager.getApplication().executeOnPooledThread(
new Runnable() {
@Override
public void run() {
progress.progress("Loading file contents "
+ Paths.get(diffFile.srcFileName).getFileName(), progressF.floatValue());
diffFile.srcFileContents = client.contents(file.links.original_file.href);
progressF.setValue(progressF.floatValue() + 1.0f / diffList.total_results);
progress.progress("Completed loading contents", progressF.floatValue());
}
}
));
futures.add(ApplicationManager.getApplication().executeOnPooledThread(
new Runnable() {
@Override
public void run() {
progress.progress("Loading file contents "
+ Paths.get(diffFile.dstFileName).getFileName(), progressF.floatValue());
diffFile.dstFileContents = client.contents(file.links.patched_file.href);
progressF.setValue(progressF.floatValue() + 1.0f / diffList.total_results);
progress.progress("Completed loading contents", progressF.floatValue());
}
}
));
result.add(diffFile);
}
}
for (Future future : futures) future.get();
return result;
}