alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (WordFreqAccumulator.java)

This example Java source code file (WordFreqAccumulator.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

accumulatorparam, counter, override, wordfreqaccumulator

The WordFreqAccumulator.java Java example source code

package org.deeplearning4j.spark.text.accumulators;

import org.apache.spark.AccumulatorParam;
import org.deeplearning4j.berkeley.Counter;

/**
 * @author jeffreytang
 */
public class WordFreqAccumulator implements AccumulatorParam<Counter {

    @Override
    public Counter<String> addInPlace(Counter c1, Counter c2) {
        c1.incrementAll(c2);
        return c1;
    }
    @Override
    public Counter<String> zero(Counter initialCounter) {
        return new Counter<>();
    }

    @Override
    public Counter<String> addAccumulator(Counter c1, Counter c2) {
        if (c1 == null) {
            return new Counter<>();
        }
        addInPlace(c1, c2);
        return c1;
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java WordFreqAccumulator.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.