Skip to content

Instantly share code, notes, and snippets.

View Denis1990's full-sized avatar
🏠
Working from home

Denis Mone Denis1990

🏠
Working from home
  • Athens, Greece
  • 23:07 (UTC +03:00)
View GitHub Profile
private static String [] MAIL_LIST_PROJECTIONS = {
MessageProvider.MessageColumns._ID,
MessageProvider.MessageColumns.SENDER_ADDRESS,
MessageProvider.MessageColumns.SENDER,
MessageProvider.MessageColumns.SEND_DATE,
MessageProvider.MessageColumns.SUBJECT,
MessageProvider.MessageColumns.PREVIEW,
MessageProvider.MessageColumns.UNREAD,
};
2016-09-18 20:29:58 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2016-09-18 20:31:34 INFO deprecation:1173 - session.id is deprecated. Instead, use dfs.metrics.session-id
2016-09-18 20:31:34 INFO JvmMetrics:76 - Initializing JVM Metrics with processName=JobTracker, sessionId=
2016-09-18 20:31:35 WARN JobResourceUploader:171 - No job jar file set. User classes may not be found. See Job or Job#setJar(String).
2016-09-18 20:31:35 INFO FileInputFormat:283 - Total input paths to process : 0
2016-09-18 20:31:35 INFO JobSubmitter:198 - number of splits:0
2016-09-18 20:31:35 INFO JobSubmitter:287 - Submitting tokens for job: job_local1137380161_0001
2016-09-18 20:31:36 INFO Job:1294 - The url to track the job: http://localhost:8080/
2016-09-18 20:31:36 INFO Job:1339 - Running job: job_local1137380161_0001
2016-09-18 20:31:36 INFO LocalJobRunner:471 - OutputCommitter set in config null
@Denis1990
Denis1990 / PointVector.java
Created September 17, 2016 10:44
vector data structure
public class PointVector implements WritableComparable<PointVector> {
/**
* Keep the tfIdf values of the terms of a document
*/
private Vector<Double> data = new Vector<>();
public PointVector(double [] values) {
this.data = new Vector<>(values.length);
this.data.addAll(Doubles.asList(values));
}
@Denis1990
Denis1990 / KMeansReduce.java
Created September 17, 2016 10:43
Reducer class
public class KMeansReducer extends Reducer<PointVector, PointVector, Text, Text> {
private double min_dist = Double.MAX_VALUE;
@Override
public void reduce(PointVector center, Iterable<PointVector> points, Context context) throws IOException, InterruptedException {
EuclideanDistance measure = new EuclideanDistance();
double distance = 0.0;
int numOfPoints = 0;
double centerx = 0;
double centery = 0;
@Denis1990
Denis1990 / KMeansMapper.java
Created September 17, 2016 10:42
Mapper class
public class KMeansMapper extends Mapper<LongWritable, Text, PointVector, PointVector> {
private int clusters;
private List<ImmutableTriple<Integer, String, PointVector>> centers;
@Override
protected void setup(Context context) throws IOException, InterruptedException {
System.out.println("Inside setup");
this.clusters = Integer.valueOf(context.getConfiguration().get("clusters"));
this.centers = new ArrayList<>();
@Denis1990
Denis1990 / KMeans.java
Last active September 18, 2016 17:50
KMeans driver code
/**
* Implementation of k-means algorithm using Map Reduce paradigm.
*/
public class KMeans extends Configured implements Tool {
/**
* Number of indexed documents
*/
private int indexedDocuments;
private List<ImmutableTriple<Integer, String, PointVector>> centers;
@Denis1990
Denis1990 / sudo command
Created July 13, 2014 17:47
sudo command output
[denis@denisArch]$ sudo cp INSTALL.txt /etc/
[sudo] password for denis:
/usr/bin/cp INSTALL /etc/
@Denis1990
Denis1990 / sudoers
Last active August 29, 2015 14:03
Sudoers file in my arch machine.
## sudoers file.
##
## This file MUST be edited with the 'visudo' command as root.
## Failure to use 'visudo' may result in syntax or file permission errors
## that prevent sudo from running.
##
## See the sudoers man page for the details on how to write a sudoers file.
##
##
@Denis1990
Denis1990 / AppZip
Last active August 29, 2015 14:01
testEmptyFolderCompression
// taken from http://www.mkyong.com/java/how-to-compress-files-in-zip-format/
// and slightly modified to test my hypothesis.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;