Example usage for org.apache.commons.lang.mutable MutableFloat setValue

List of usage examples for org.apache.commons.lang.mutable MutableFloat setValue

Introduction

In this page you can find the example usage for org.apache.commons.lang.mutable MutableFloat setValue.

Prototype

public void setValue(Object value) 

Source Link

Document

Sets the value from any Number instance.

Usage

From source file:com.ritesh.idea.plugin.reviewboard.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));
    }/* ww  w .j  a  va  2 s.com*/

    progress.progress("Making review public", progressF.floatValue());
    client.updateReviewApi(reviewRequest.id, String.valueOf(review.review.id), true, reviewComment, null);
    progress.progress("Review Completed", 1);
}

From source file:com.ritesh.idea.plugin.reviewboard.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;/* w w w .  java  2  s .c o m*/
            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;
}

From source file:com.linkedin.mlease.regression.jobs.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());
        }/* w  w  w . j  av  a  2s. c  om*/
    }
    testRecordWriter.close();
}