diff --git a/.travis.yml b/.travis.yml index b688410..2fd5140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java jdk: - - openjdk6 - - openjdk7 + - oraclejdk7 + - oraclejdk8 diff --git a/core/lib/apache-cassandra-0.6.0.jar b/core/lib/apache-cassandra-0.6.0.jar deleted file mode 100644 index 858e2af..0000000 Binary files a/core/lib/apache-cassandra-0.6.0.jar and /dev/null differ diff --git a/core/lib/cassandra-javautils.jar b/core/lib/cassandra-javautils.jar deleted file mode 100644 index 1cd5e4f..0000000 Binary files a/core/lib/cassandra-javautils.jar and /dev/null differ diff --git a/core/lib/clhm-production-1.0.jar b/core/lib/clhm-production-1.0.jar deleted file mode 100644 index 028f505..0000000 Binary files a/core/lib/clhm-production-1.0.jar and /dev/null differ diff --git a/core/lib/commons-lang-2.4.jar b/core/lib/commons-lang-2.4.jar deleted file mode 100644 index 532939e..0000000 Binary files a/core/lib/commons-lang-2.4.jar and /dev/null differ diff --git a/core/lib/flexjson-1.7.jar b/core/lib/flexjson-1.7.jar deleted file mode 100644 index 5e07e12..0000000 Binary files a/core/lib/flexjson-1.7.jar and /dev/null differ diff --git a/core/lib/hector-0.6.0-15.jar b/core/lib/hector-0.6.0-15.jar deleted file mode 100644 index edddec6..0000000 Binary files a/core/lib/hector-0.6.0-15.jar and /dev/null differ diff --git a/core/lib/high-scale-lib-1.0.jar b/core/lib/high-scale-lib-1.0.jar deleted file mode 100644 index 421a436..0000000 Binary files a/core/lib/high-scale-lib-1.0.jar and /dev/null differ diff --git a/core/lib/libthrift-r917130.jar b/core/lib/libthrift-r917130.jar deleted file mode 100644 index 896cdb2..0000000 Binary files a/core/lib/libthrift-r917130.jar and /dev/null differ diff --git a/core/pom.xml b/core/pom.xml index 58ce948..bac7380 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -21,10 +21,10 @@ org.apache.maven.plugins maven-compiler-plugin - 2.3.1 + 3.2 - 1.5 - 1.5 + 1.7 + 1.7 @@ -45,4 +45,4 @@ test - \ No newline at end of file + diff --git a/core/src/main/java/org/unigram/likelike/common/FsUtil.java b/core/src/main/java/org/unigram/likelike/common/FsUtil.java index bcf21e4..b5849e3 100644 --- a/core/src/main/java/org/unigram/likelike/common/FsUtil.java +++ b/core/src/main/java/org/unigram/likelike/common/FsUtil.java @@ -16,13 +16,13 @@ */ package org.unigram.likelike.common; -import java.io.IOException; -import java.util.logging.Level; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import java.io.IOException; +import java.util.logging.Level; + /** * File utility class. */ @@ -49,7 +49,7 @@ public static boolean checkPath(final Path dir, final FileSystem fs) throws IOException { if (fs.exists(dir)) { - logger.log(Level.INFO, "Overiding: " + dir.toString()); + logger.log(Level.INFO, "Overriding: " + dir.toString()); return fs.delete(dir, true); } else { logger.log(Level.FINE, "No such file: " + dir.toString()); @@ -80,16 +80,15 @@ public static boolean checkPath(final Path dir, */ public static void clean(final FileSystem fs, final String... fileNames) throws IOException { - - for (int i = 0; i < fileNames.length; i++) { - Path path = new Path(fileNames[i]); + + for (String fileName : fileNames) { + Path path = new Path(fileName); if (fs.exists(path)) { - logger.log(Level.INFO, + logger.log(Level.INFO, "Removing: " + path.toString()); fs.delete(path, true); } } - return; - } + } } diff --git a/core/src/main/java/org/unigram/likelike/common/RelatedUsersWritable.java b/core/src/main/java/org/unigram/likelike/common/RelatedUsersWritable.java index b3b3e85..e64550b 100644 --- a/core/src/main/java/org/unigram/likelike/common/RelatedUsersWritable.java +++ b/core/src/main/java/org/unigram/likelike/common/RelatedUsersWritable.java @@ -16,6 +16,9 @@ */ package org.unigram.likelike.common; +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Writable; + import java.io.DataInput; import java.io.DataOutput; import java.io.EOFException; @@ -23,9 +26,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.hadoop.io.LongWritable; -import org.apache.hadoop.io.Writable; - /** * */ @@ -72,7 +72,6 @@ public List getRelatedUsers() { * @param in input stream * @throws IOException - */ - @Override public void readFields(final DataInput in) throws IOException { try { int listSize = in.readInt(); @@ -93,7 +92,6 @@ public void readFields(final DataInput in) throws IOException { * @param out output stream * @throws IOException - */ - @Override public void write(final DataOutput out) throws IOException { out.writeInt(this.relatedUsers.size()); for (LongWritable item : this.relatedUsers) { diff --git a/core/src/main/java/org/unigram/likelike/feature/FeatureExtraction.java b/core/src/main/java/org/unigram/likelike/feature/FeatureExtraction.java index e712481..056e591 100644 --- a/core/src/main/java/org/unigram/likelike/feature/FeatureExtraction.java +++ b/core/src/main/java/org/unigram/likelike/feature/FeatureExtraction.java @@ -1,7 +1,5 @@ package org.unigram.likelike.feature; -import java.io.IOException; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; @@ -13,13 +11,14 @@ import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; - import org.unigram.likelike.common.FsUtil; import org.unigram.likelike.common.LikelikeConstants; -import org.unigram.likelike.util.IdentityReducer; -import org.unigram.likelike.util.InverseMapper; import org.unigram.likelike.util.AddFeatureMapper; import org.unigram.likelike.util.AddFeatureReducer; +import org.unigram.likelike.util.IdentityReducer; +import org.unigram.likelike.util.InverseMapper; + +import java.io.IOException; /** * @@ -33,7 +32,6 @@ public class FeatureExtraction extends Configured * @return 0 when succeeded * @throws Exception - */ - @Override public int run(final String[] args) throws Exception { Configuration conf = getConf(); return this.run(args, conf); diff --git a/core/src/main/java/org/unigram/likelike/feature/FeatureExtractionReducer.java b/core/src/main/java/org/unigram/likelike/feature/FeatureExtractionReducer.java index 4498b6f..ed57756 100644 --- a/core/src/main/java/org/unigram/likelike/feature/FeatureExtractionReducer.java +++ b/core/src/main/java/org/unigram/likelike/feature/FeatureExtractionReducer.java @@ -97,13 +97,12 @@ public int compare(final Object o1, final Object o2){ Map.Entry obj = (Map.Entry) it.next(); Long feature = (Long) obj.getKey(); if (!targetFeatures.containsKey(feature)) { - //System.out.println("target: " + target + "\tfeature: " + feature); - try { - this.writer.write((Long) target.get(), feature, context); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + try { + this.writer.write((Long) target.get(), feature, context); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } } @@ -145,7 +144,7 @@ public final void setup(final Context context) { LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER; jc.set(LikelikeConstants.CASSANDRA_COLUMNFAMILY_NAME, - LikelikeConstants.LIKELIKE_CASSANDRA_FEATURE_EXTRACTION_COLUMNFAMILY_NAME); + LikelikeConstants.LIKELIKE_CASSANDRA_FEATURE_EXTRACTION_COLUMNFAMILY_NAME); try { writerClassName = diff --git a/core/src/main/java/org/unigram/likelike/lsh/GetRecommendationsReducer.java b/core/src/main/java/org/unigram/likelike/lsh/GetRecommendationsReducer.java index 204141d..1b372be 100644 --- a/core/src/main/java/org/unigram/likelike/lsh/GetRecommendationsReducer.java +++ b/core/src/main/java/org/unigram/likelike/lsh/GetRecommendationsReducer.java @@ -40,7 +40,6 @@ public class GetRecommendationsReducer extends Reducer { - /** * reduce. * @param key target @@ -53,8 +52,7 @@ public void reduce(final LongWritable key, final Iterable values, final Context context) throws IOException, InterruptedException { - - HashMap candidates + HashMap candidates = new HashMap(); for (Candidate cand : values) { Long tid = cand.getId().get(); @@ -63,10 +61,8 @@ public void reduce(final LongWritable key, weight += 1.0; // not use the size of the cluster candidates.put(tid, weight); } else { - candidates.put(tid, - new Double(1.0)); + candidates.put(tid, new Double(1.0)); } - if (candidates.size() > 50000) { // TODO should be parameterized break; } @@ -109,7 +105,7 @@ public void reduce(final LongWritable key, */ @Override public final void setup(final Context context) { - Configuration jc = null; + Configuration jc = null; if (context == null) { jc = new Configuration(); @@ -118,11 +114,11 @@ public final void setup(final Context context) { } this.maxOutputSize = jc.getLong( - LikelikeConstants.MAX_OUTPUT_SIZE , + LikelikeConstants.MAX_OUTPUT_SIZE, LikelikeConstants.DEFAULT_MAX_OUTPUT_SIZE); - - this.comparator = new Comparator(){ - public int compare(final Object o1, final Object o2){ + + this.comparator = new Comparator() { + public int compare(final Object o1, final Object o2) { Map.Entry e1 = (Map.Entry) o1; Map.Entry e2 = (Map.Entry) o2; Double e1Value = (Double) e1.getValue(); @@ -132,28 +128,20 @@ public int compare(final Object o1, final Object o2){ }; // create writer - String writerClassName = + String writerClassName = LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER; try { - writerClassName = + writerClassName = jc.get(LikelikeConstants.LIKELIKE_OUTPUT_WRITER, - LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER); + LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER); Class extractorClass = Class.forName( writerClassName).asSubclass(IWriter.class); Constructor constructor = extractorClass .getConstructor(Configuration.class); this.writer = constructor.newInstance(jc); - } catch (NoSuchMethodException nsme) { - throw new RuntimeException(nsme); - } catch (ClassNotFoundException cnfe) { - throw new RuntimeException(cnfe); - } catch (InstantiationException ie) { - throw new RuntimeException(ie); - } catch (IllegalAccessException iae) { - throw new RuntimeException(iae); - } catch (InvocationTargetException ite) { - throw new RuntimeException(ite.getCause()); + } catch (NoSuchMethodException | ClassNotFoundException | InstantiationException + | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); } - - } + } } diff --git a/core/src/main/java/org/unigram/likelike/lsh/LSHRecommendations.java b/core/src/main/java/org/unigram/likelike/lsh/LSHRecommendations.java index 4eb5356..87c76de 100644 --- a/core/src/main/java/org/unigram/likelike/lsh/LSHRecommendations.java +++ b/core/src/main/java/org/unigram/likelike/lsh/LSHRecommendations.java @@ -16,18 +16,11 @@ */ package org.unigram.likelike.lsh; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.Random; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; - import org.apache.hadoop.mapreduce.Counters; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; @@ -36,24 +29,18 @@ import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; +import org.unigram.likelike.common.*; -import org.unigram.likelike.common.Candidate; -import org.unigram.likelike.common.FsUtil; -import org.unigram.likelike.common.LikelikeConstants; -import org.unigram.likelike.common.LikelikeLogger; -import org.unigram.likelike.common.RelatedUsersWritable; -import org.unigram.likelike.common.SeedClusterId; -import org.unigram.likelike.lsh.GetRecommendationsMapper; -import org.unigram.likelike.lsh.GetRecommendationsReducer; -import org.unigram.likelike.lsh.SelectClustersMapper; -import org.unigram.likelike.lsh.SelectClustersReducer; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Random; /** * Extract recommendations for input examples. */ -public class LSHRecommendations extends - Configured implements Tool { - +public class LSHRecommendations extends Configured implements Tool { /** logger. */ protected final LikelikeLogger logger = LikelikeLogger.getLogger(); @@ -122,20 +109,20 @@ public int run(final String[] args, final Configuration conf) conf.setLong(LikelikeConstants.MAX_OUTPUT_SIZE, Long.parseLong(args[++i])); } else if ("-storage".equals(args[i])) { - String storageType = args[++i]; - if (storageType.equals("dfs")) { - conf.set(LikelikeConstants.LIKELIKE_OUTPUT_WRITER, - LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER); - } else if (storageType.equals("cassandra")) { - conf.set(LikelikeConstants.LIKELIKE_OUTPUT_WRITER, - this.cassandraAccessor); - } + String storageType = args[++i]; + if (storageType.equals("dfs")) { + conf.set(LikelikeConstants.LIKELIKE_OUTPUT_WRITER, + LikelikeConstants.DEFAULT_LIKELIKE_OUTPUT_WRITER); + } else if (storageType.equals("cassandra")) { + conf.set(LikelikeConstants.LIKELIKE_OUTPUT_WRITER, + this.cassandraAccessor); + } } else if ("-help".equals(args[i])) { this.showParameters(); return 0; } } - + this.setHashKeys(iterate, inputFile, conf); this.extractClusters(inputFile, clusterDir, conf); this.getRecommendations(clusterDir, @@ -351,7 +338,5 @@ public static void main(final String[] args) int exitCode = ToolRunner.run( new LSHRecommendations(), args); System.exit(exitCode); - } - - + } } diff --git a/core/src/main/java/org/unigram/likelike/lsh/SelectClustersMapper.java b/core/src/main/java/org/unigram/likelike/lsh/SelectClustersMapper.java index 113be56..a98242a 100644 --- a/core/src/main/java/org/unigram/likelike/lsh/SelectClustersMapper.java +++ b/core/src/main/java/org/unigram/likelike/lsh/SelectClustersMapper.java @@ -16,23 +16,21 @@ */ package org.unigram.likelike.lsh; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.Set; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; -import org.apache.hadoop.mapreduce.Mapper.Context; - import org.unigram.likelike.common.LikelikeConstants; import org.unigram.likelike.common.RelatedUsersWritable; import org.unigram.likelike.common.SeedClusterId; import org.unigram.likelike.lsh.function.IHashFunction; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.Set; + /** * SelectClustersMapper. */ @@ -114,16 +112,10 @@ public final void setup(final Context context) { = functionClass .getConstructor(Configuration.class); function = constructor.newInstance(jc); - } catch (NoSuchMethodException nsme) { - throw new RuntimeException(nsme); - } catch (ClassNotFoundException cnfe) { - throw new RuntimeException(cnfe); - } catch (InstantiationException ie) { - throw new RuntimeException(ie); - } catch (IllegalAccessException iae) { - throw new RuntimeException(iae); - } catch (InvocationTargetException ite) { - throw new RuntimeException(ite.getCause()); + } catch (NoSuchMethodException | ClassNotFoundException | + InstantiationException | IllegalAccessException | + InvocationTargetException e){ + throw new RuntimeException(e); } /* extract set of hash seeds */ diff --git a/core/src/main/java/org/unigram/likelike/util/AddFeatureMapper.java b/core/src/main/java/org/unigram/likelike/util/AddFeatureMapper.java index ad762fc..b016686 100644 --- a/core/src/main/java/org/unigram/likelike/util/AddFeatureMapper.java +++ b/core/src/main/java/org/unigram/likelike/util/AddFeatureMapper.java @@ -1,17 +1,15 @@ package org.unigram.likelike.util; -import java.io.IOException; - import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; +import java.io.IOException; + /** * */ -public class AddFeatureMapper extends - Mapper { - +public class AddFeatureMapper extends Mapper { /** * Map method. * @@ -34,7 +32,7 @@ public final void map(final LongWritable key, new Text(valueArray[1])); } else { System.out.println( - "Input hould have two segments: " + valueStr); + "Input should have two segments: " + valueStr); } } } diff --git a/core/src/main/java/org/unigram/likelike/util/AddFeatureReducer.java b/core/src/main/java/org/unigram/likelike/util/AddFeatureReducer.java index b2b5e66..c1ef634 100644 --- a/core/src/main/java/org/unigram/likelike/util/AddFeatureReducer.java +++ b/core/src/main/java/org/unigram/likelike/util/AddFeatureReducer.java @@ -16,21 +16,18 @@ */ package org.unigram.likelike.util; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer; -import org.apache.hadoop.mapreduce.Reducer.Context; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; /** * */ -public class AddFeatureReducer extends - Reducer { - +public class AddFeatureReducer extends Reducer { /** * Reduce method. * @param key - @@ -59,7 +56,6 @@ public void reduce(final LongWritable key, if (rtValue==null) { return; } - for (Long v : candidates) { /* write with inverse key and value */ /* caution: inverse key (target) and value (candidate) */ diff --git a/core/src/main/java/org/unigram/likelike/util/IdentityReducer.java b/core/src/main/java/org/unigram/likelike/util/IdentityReducer.java index a3821e7..6ca5635 100644 --- a/core/src/main/java/org/unigram/likelike/util/IdentityReducer.java +++ b/core/src/main/java/org/unigram/likelike/util/IdentityReducer.java @@ -1,18 +1,15 @@ package org.unigram.likelike.util; -import java.io.IOException; - import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer; -import org.apache.hadoop.mapreduce.Reducer.Context; + +import java.io.IOException; /** * */ -public class IdentityReducer extends Reducer { - +public class IdentityReducer extends Reducer { /** * Reduce method. * @param key - @@ -29,5 +26,5 @@ public void reduce(final LongWritable key, for (Text v : values) { context.write(key, v); } - } + } } diff --git a/core/src/main/java/org/unigram/likelike/util/InverseMapper.java b/core/src/main/java/org/unigram/likelike/util/InverseMapper.java index 9c2c639..5f2f66f 100644 --- a/core/src/main/java/org/unigram/likelike/util/InverseMapper.java +++ b/core/src/main/java/org/unigram/likelike/util/InverseMapper.java @@ -1,18 +1,15 @@ package org.unigram.likelike.util; -import java.io.IOException; - import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; -import org.apache.hadoop.mapreduce.Mapper.Context; + +import java.io.IOException; /** * */ -public class InverseMapper extends Mapper { - +public class InverseMapper extends Mapper { /** * Map method. * @param dummy - @@ -27,7 +24,6 @@ public final void map(final LongWritable dummy, throws InterruptedException, IOException { String valueStr = value.toString(); String[] valueArray = valueStr.split("\t"); - if (valueArray.length == 2) { context.write( new LongWritable(Long.parseLong(valueArray[1])), diff --git a/core/src/main/java/org/unigram/likelike/util/accessor/IReader.java b/core/src/main/java/org/unigram/likelike/util/accessor/IReader.java index 8cb7a1f..3580688 100644 --- a/core/src/main/java/org/unigram/likelike/util/accessor/IReader.java +++ b/core/src/main/java/org/unigram/likelike/util/accessor/IReader.java @@ -2,11 +2,6 @@ import java.util.Map; -import org.apache.hadoop.mapreduce.Reducer.Context; - public interface IReader { - - Map read(Long key) - throws Exception, InterruptedException; - + Map read(Long key) throws Exception, InterruptedException; } diff --git a/core/src/main/java/org/unigram/likelike/util/accessor/IWriter.java b/core/src/main/java/org/unigram/likelike/util/accessor/IWriter.java index b2c5f76..2d5b6ed 100644 --- a/core/src/main/java/org/unigram/likelike/util/accessor/IWriter.java +++ b/core/src/main/java/org/unigram/likelike/util/accessor/IWriter.java @@ -22,9 +22,6 @@ * */ public interface IWriter { - @SuppressWarnings("unchecked") - boolean write(Long key, Long value, Context context) - throws Exception, InterruptedException; - + boolean write(Long key, Long value, Context context) throws Exception, InterruptedException; } diff --git a/core/src/main/java/org/unigram/likelike/validate/Validation.java b/core/src/main/java/org/unigram/likelike/validate/Validation.java index f94a446..1f5baff 100644 --- a/core/src/main/java/org/unigram/likelike/validate/Validation.java +++ b/core/src/main/java/org/unigram/likelike/validate/Validation.java @@ -1,7 +1,5 @@ package org.unigram.likelike.validate; -import java.io.IOException; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; @@ -20,18 +18,18 @@ import org.unigram.likelike.util.IdentityReducer; import org.unigram.likelike.util.InverseMapper; +import java.io.IOException; + /** * */ public class Validation extends Configured implements Tool { - /** * Run. * @param args arguments * @return 0 * @throws Exception - */ - @Override public int run(final String[] args) throws Exception { Configuration conf = getConf(); return this.run(args, conf); @@ -103,7 +101,7 @@ private boolean inverse(final String inputDir, Path inputPath = new Path(inputDir); Path outputPath = new Path(outputDir); FsUtil.checkPath(outputPath, this.fs); - + Job job = new Job(conf); job.setJarByClass(Validation.class); FileInputFormat.addInputPath(job, inputPath); @@ -219,8 +217,8 @@ private void showParameters() { + "use VALUE as the threshold to output pairs"); System.out.println(" [-help] " + "show this message"); - } - + } + /** * Main method. * @@ -233,7 +231,7 @@ public static void main(final String[] args) new Validation(), args); System.exit(exitCode); } - + /** File system. */ private FileSystem fs = null; } diff --git a/core/src/main/java/org/unigram/likelike/validate/ValidationMapper.java b/core/src/main/java/org/unigram/likelike/validate/ValidationMapper.java index f6c1a90..7af031f 100644 --- a/core/src/main/java/org/unigram/likelike/validate/ValidationMapper.java +++ b/core/src/main/java/org/unigram/likelike/validate/ValidationMapper.java @@ -1,17 +1,17 @@ package org.unigram.likelike.validate; -import java.io.IOException; - import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; +import java.io.IOException; + /** * */ public class ValidationMapper extends Mapper { - + /** * map. * @param key - diff --git a/core/src/main/java/org/unigram/likelike/validate/ValidationReducer.java b/core/src/main/java/org/unigram/likelike/validate/ValidationReducer.java index 602b370..50ef1cc 100644 --- a/core/src/main/java/org/unigram/likelike/validate/ValidationReducer.java +++ b/core/src/main/java/org/unigram/likelike/validate/ValidationReducer.java @@ -1,27 +1,19 @@ package org.unigram.likelike.validate; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer; -import org.apache.hadoop.mapreduce.Mapper.Context; + +import java.io.IOException; +import java.util.*; /** * */ public class ValidationReducer extends Reducer { - - - /** + /** * Reduce method. * @param candidate candidate id * @param values targets and candidateFeature @@ -85,7 +77,7 @@ private double calcCosine(final Map vectorOne, } else { return (ip / norm); } - } + } /** * Calculate inner product between two vectors. @@ -155,8 +147,8 @@ public final void setup(final Context context) { this.threshold = jc.getFloat( ValidationConstants.VALIDATION_THRESHOLD, ValidationConstants.DEFAULT_VALIDATION_THRESHOLD); - } - + } + /** minimum cosine value. */ private float threshold; } diff --git a/webapp/pom.xml b/webapp/pom.xml deleted file mode 100644 index 3b905ac..0000000 --- a/webapp/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - - likelike - org.unigram - 0.3-SNAPSHOT - - org.unigram - webapp - 0.2-SNAPSHOT - war - likelike webapps - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - - webapp - - - UTF-8 - - diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 9f88c1f..0000000 --- a/webapp/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Archetype Created Web Application - diff --git a/webapp/src/main/webapp/index.jsp b/webapp/src/main/webapp/index.jsp deleted file mode 100644 index c38169b..0000000 --- a/webapp/src/main/webapp/index.jsp +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello World!

- -