Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility classes should not have public constructors #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
*/
public class SparkAnagram {

public static void main(String[] args) throws Exception {
private SparkAnagram() {
}

public static void main(String[] args) throws Exception {

// STEP-1: handle input parameters
if (args.length != 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*/
public class TestCartesian {

static JavaSparkContext createJavaSparkContext() throws Exception {
private TestCartesian() {
}

static JavaSparkContext createJavaSparkContext() throws Exception {
SparkConf conf = new SparkConf();
conf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer");
//JavaSparkContext ctx = new JavaSparkContext("yarn-cluster", "mytestprogram", conf); // yarn-specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
*
*/
public class CharCount {


private CharCount() {
}

static void printArguments(String[] args) {
if ((args == null) || (args.length == 0)) {
System.out.println("no arguments passed...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
public class CharCountInMapperCombiner {

private CharCountInMapperCombiner() {
}

public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: SparkCharCount <input> <output>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
public class CharCountLocalAggregation {

private CharCountLocalAggregation() {
}

public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: SparkCharCount <input> <output>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
*/
public class SparkFriendRecommendation {

/**
private SparkFriendRecommendation() {
}

/**
* Build a pair of Longs(x,y) where x <= y
*/
private static Tuple2<Long,Long> buildSortedPairOfLongs(long a, long b) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
public class SubmitSparkJobToYARNFromJavaCode {

private SubmitSparkJobToYARNFromJavaCode() {
}

public static void main(String[] arguments) throws Exception {

// prepare arguments to be passed to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public class SparkLogQuery {
"10.20.30.42,u400,700,query2"
);

// tokens = [<ip-address><user-id><number-of-bytes><query>]
private SparkLogQuery() {
}

// tokens = [<ip-address><user-id><number-of-bytes><query>]
public static Tuple3<String, String, String> createKey(String[] tokens) {
String userID = tokens[1];
if (userID.equals("-")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
public class OutlierDetection {

private static final Logger THE_LOGGER = Logger.getLogger(OutlierDetection.class);



private OutlierDetection() {
}


static class TupleComparatorAscending
implements Comparator<Tuple2<String,Double>>, Serializable {
final static TupleComparatorAscending INSTANCE = new TupleComparatorAscending();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
*/

public final class PerKeyAverage {


private PerKeyAverage() {
}

static final List<Tuple2<String, Double>> getSampleInput() {
List<Tuple2<String, Double>> input = new ArrayList<Tuple2<String, Double>>();
// key: "zebra"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class SparkRankProductUsingCombineByKey {

private static final Logger THE_LOGGER = Logger.getLogger(SparkRankProductUsingCombineByKey.class);

private SparkRankProductUsingCombineByKey() {
}

/**
* AverageCount is used by combineByKey() to hold
* the total values and their count.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
public class SparkRankProductUsingGroupByKey {

private static final Logger THE_LOGGER = Logger.getLogger(SparkRankProductUsingGroupByKey.class);


private SparkRankProductUsingGroupByKey() {
}

static void debug(String[] args) {
for (int i=0; i < args.length; i++){
THE_LOGGER.info("***debug*** args["+i+"]="+args[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
public class Util {

private static final Logger THE_LOGGER = Logger.getLogger(Util.class);


private Util() {
}

static JavaSparkContext createJavaSparkContext(boolean useYARN) {
JavaSparkContext context;
if (useYARN) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
public class SparkSortedWordCount {

private SparkSortedWordCount() {
}

public static void main(String[] args) throws Exception {
if (args.length != 4) {
System.err.println("Usage: SparkSortedWordCount <N> <input> <output> <orderBy>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
*/
public class SparkWordCount {

public static void main(String[] args) throws Exception {
private SparkWordCount() {
}

public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.err.println("Usage: SparkWordCount <N> <input> <output>");
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
*
*/
public class SparkSecondarySort {
public static void main(String[] args) throws Exception {
private SparkSecondarySort() {
}

public static void main(String[] args) throws Exception {

// STEP-1: read input parameters and validate them
if (args.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
public class SecondarySortDriver {

private SecondarySortDriver() {
}

public static void main(String[] args) throws Exception {

Configuration conf = new Configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
public class SequenceFileWriterForTopN {

private SequenceFileWriterForTopN() {
}

public static void main(String[] args) throws IOException {
if (args.length != 2) {
throw new IOException("usage: java org.dataalgorithms.chap03.mapreduce.SequenceFileWriterForTopN <hdfs-path> <number-of-entries>");
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/dataalgorithms/chap03/spark/Top10.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
*/
public class Top10 {

public static void main(String[] args) throws Exception {
private Top10() {
}

public static void main(String[] args) throws Exception {

// STEP-1: handle input parameters
if (args.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
*/
public class Top10NonUnique {

public static void main(String[] args) throws Exception {
private Top10NonUnique() {
}

public static void main(String[] args) throws Exception {
// STEP-1: handle input parameters
if (args.length < 2) {
System.err.println("Usage: Top10 <input-path> <topN>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
*
*/
public class LeftJoinDriver {

public static void main( String[] args ) throws Exception {

private LeftJoinDriver() {
}

public static void main(String[] args ) throws Exception {
Path transactions = new Path(args[0]); // input
Path users = new Path(args[1]); // input
Path output = new Path(args[2]); // output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
*/
public class LocationCountDriver {

public static void main( String[] args ) throws Exception {
private LocationCountDriver() {
}

public static void main(String[] args ) throws Exception {
Path input = new Path(args[0]);
Path output = new Path(args[1]);
Configuration conf = new Configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
*/
public class SparkLeftOuterJoin {

public static void main(String[] args) throws Exception {
private SparkLeftOuterJoin() {
}

public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: SparkLeftOuterJoin <users> <transactions>");
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
*
*/
public class SortInMemory_MovingAverageDriver {

public static void main(String[] args) throws Exception {

private SortInMemory_MovingAverageDriver() {
}

public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class TestSimpleMovingAverage {

private static final Logger THE_LOGGER = Logger.getLogger(TestSimpleMovingAverage.class);

private TestSimpleMovingAverage() {
}

public static void main(String[] args) {
// The invocation of the BasicConfigurator.configure method
// creates a rather simple log4j setup. This method is hardwired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
*
*/
public class SortByMRF_MovingAverageDriver {

public static void main(String[] args) throws Exception {

private SortByMRF_MovingAverageDriver() {
}

public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
JobConf jobconf = new JobConf(conf, SortByMRF_MovingAverageDriver.class);
jobconf.setJobName("SortByMRF_MovingAverageDriver");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
*
*/
public class FindAssociationRules {

static List<String> toList(String transaction) {

private FindAssociationRules() {
}

static List<String> toList(String transaction) {
String[] items = transaction.trim().split(",");
List<String> list = new ArrayList<String>();
for (String item : items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
*/
public class FindCommonFriends {

public static void main(String[] args) throws Exception {
private FindCommonFriends() {
}

public static void main(String[] args) throws Exception {

if (args.length < 1) {
// Spark master URL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
*/
public class SparkFriendRecommendation {

public static void main(String[] args) throws Exception {
private SparkFriendRecommendation() {
}

public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.err.println("Usage: SparkFriendRecommendation <input-path>");
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
*
*/
public class MovieRecommendations {
public static void main(String[] args) throws Exception {
private MovieRecommendations() {
}

public static void main(String[] args) throws Exception {

//STEP-1: handle input parameters
if (args.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
*
*/
public class MovieRecommendationsWithJoin {
public static void main(String[] args) throws Exception {
private MovieRecommendationsWithJoin() {
}

public static void main(String[] args) throws Exception {

//STEP-1: handle input parameters
if (args.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
*/
public class SortInMemoryProjectionDriver {
private static final Logger theLogger =
Logger.getLogger(SortInMemoryProjectionDriver.class);

public static void main(String[] args) throws Exception {
Logger.getLogger(SortInMemoryProjectionDriver.class);

private SortInMemoryProjectionDriver() {
}

public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();

Configuration conf = new Configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
public class SecondarySortProjectionDriver {

private static final Logger theLogger =
Logger.getLogger(SecondarySortProjectionDriver.class);

Logger.getLogger(SecondarySortProjectionDriver.class);

private SecondarySortProjectionDriver() {
}

public static void main(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
Configuration conf = new Configuration();
Expand Down
Loading