-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ubuntu
committed
Aug 4, 2016
0 parents
commit fa33811
Showing
200 changed files
with
31,521 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# ************************************************************************* | ||
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** | ||
# *** FILES IN THIS DIRECTORY AND SUBDIRECTORIES CONSTITUTE A DERBY *** | ||
# *** DATABASE, WHICH INCLUDES THE DATA (USER AND SYSTEM) AND THE *** | ||
# *** FILES NECESSARY FOR DATABASE RECOVERY. *** | ||
# *** EDITING, ADDING, OR DELETING ANY OF THESE FILES MAY CAUSE DATA *** | ||
# *** CORRUPTION AND LEAVE THE DATABASE IN A NON-RECOVERABLE STATE. *** | ||
# ************************************************************************* |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# ************************************************************************* | ||
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** | ||
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE RECOVERY *** | ||
# *** SYSTEM. EDITING, ADDING, OR DELETING FILES IN THIS DIRECTORY *** | ||
# *** WILL CAUSE THE DERBY RECOVERY SYSTEM TO FAIL, LEADING TO *** | ||
# *** NON-RECOVERABLE CORRUPT DATABASES. *** | ||
# ************************************************************************* |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
# ************************************************************************* | ||
# *** DO NOT TOUCH FILES IN THIS DIRECTORY! *** | ||
# *** FILES IN THIS DIRECTORY ARE USED BY THE DERBY DATABASE TO STORE *** | ||
# *** USER AND SYSTEM DATA. EDITING, ADDING, OR DELETING FILES IN THIS *** | ||
# *** DIRECTORY WILL CORRUPT THE ASSOCIATED DERBY DATABASE AND MAKE *** | ||
# *** IT NON-RECOVERABLE. *** | ||
# ************************************************************************* |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#/home/ubuntu/testing/Spark/metastore_db | ||
# ******************************************************************** | ||
# *** Please do NOT edit this file. *** | ||
# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. *** | ||
# ******************************************************************** | ||
#Thu Aug 04 10:23:35 CEST 2016 | ||
SysschemasIndex2Identifier=225 | ||
SyscolumnsIdentifier=144 | ||
SysconglomeratesIndex1Identifier=49 | ||
SysconglomeratesIdentifier=32 | ||
SyscolumnsIndex2Identifier=177 | ||
SysschemasIndex1Identifier=209 | ||
SysconglomeratesIndex3Identifier=81 | ||
SystablesIndex2Identifier=129 | ||
SyscolumnsIndex1Identifier=161 | ||
derby.serviceProtocol=org.apache.derby.database.Database | ||
SysschemasIdentifier=192 | ||
derby.storage.propertiesId=16 | ||
SysconglomeratesIndex2Identifier=65 | ||
derby.serviceLocale=en_US | ||
SystablesIdentifier=96 | ||
SystablesIndex1Identifier=113 | ||
#--- last line, don't put anything after this line --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
este texto es el primer texto | ||
que es importante para el ejercicio | ||
en el que es el objetivo contar palabras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/python | ||
|
||
import sys, random | ||
from pyspark import SparkConf, SparkContext | ||
|
||
if len(sys.argv)<2 : | ||
NUM_SAMPLES=100000 | ||
else: | ||
NUM_SAMPLES=int(sys.argv[1]) | ||
|
||
conf = SparkConf().setMaster("local").setAppName("My App") | ||
sc = SparkContext(conf = conf) | ||
def sample(p): | ||
x, y = random.random(), random.random() | ||
return 1 if x*x + y*y < 1 else 0 | ||
|
||
count = sc.parallelize(xrange(0, NUM_SAMPLES)).map(sample) \ | ||
.reduce(lambda a, b: a + b) | ||
print "Pi is roughly %f" % (4.0 * count / NUM_SAMPLES) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
val NUM_SAMPLES=100000 | ||
val count = sc.parallelize(1 to NUM_SAMPLES).map{i => | ||
val x = Math.random() | ||
val y = Math.random() | ||
if (x*x + y*y < 1) 1 else 0 | ||
}.reduce(_ + _) | ||
println("Pi is roughly " + 4.0 * count / NUM_SAMPLES) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pyspark import SparkConf, SparkContext | ||
import sys | ||
|
||
conf = SparkConf().setMaster("local").setAppName("My App") | ||
sc = SparkContext(conf = conf) | ||
|
||
if len(sys.argv)<2 : | ||
print 'An input file is needed' | ||
sys.exit(2) | ||
else: | ||
lines = sc.textFile(str(sys.argv[1])) | ||
words = lines.flatMap(lambda x: x.split(" ")) | ||
result = words.map(lambda x: (x, 1)).reduceByKey(lambda x, y: x + y) | ||
extract= result.filter(lambda x:x[1]>2) | ||
for pair in extract.take(extract.count()): | ||
print(pair) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.hadoop.examples; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.StringTokenizer; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.conf.Configured; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.io.IntWritable; | ||
import org.apache.hadoop.io.LongWritable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.mapred.FileInputFormat; | ||
import org.apache.hadoop.mapred.FileOutputFormat; | ||
import org.apache.hadoop.mapred.JobClient; | ||
import org.apache.hadoop.mapred.JobConf; | ||
import org.apache.hadoop.mapred.MapReduceBase; | ||
import org.apache.hadoop.mapred.Mapper; | ||
import org.apache.hadoop.mapred.OutputCollector; | ||
import org.apache.hadoop.mapred.Reducer; | ||
import org.apache.hadoop.mapred.Reporter; | ||
import org.apache.hadoop.util.Tool; | ||
import org.apache.hadoop.util.ToolRunner; | ||
|
||
/** | ||
* This is an example Hadoop Map/Reduce application. | ||
* It reads the text input files, breaks each line into words | ||
* and counts them. The output is a locally sorted list of words and the | ||
* count of how often they occurred. | ||
* | ||
* To run: bin/hadoop jar build/hadoop-examples.jar wordcount | ||
* [-m <i>maps</i>] [-r <i>reduces</i>] <i>in-dir</i> <i>out-dir</i> | ||
*/ | ||
public class WordCount extends Configured implements Tool { | ||
|
||
/** | ||
* Counts the words in each line. | ||
* For each line of input, break the line into words and emit them as | ||
* (<b>word</b>, <b>1</b>). | ||
*/ | ||
public static class MapClass extends MapReduceBase | ||
implements Mapper<LongWritable, Text, Text, IntWritable> { | ||
|
||
private final static IntWritable one = new IntWritable(1); | ||
private Text word = new Text(); | ||
|
||
public void map(LongWritable key, Text value, | ||
OutputCollector<Text, IntWritable> output, | ||
Reporter reporter) throws IOException { | ||
String line = value.toString(); | ||
StringTokenizer itr = new StringTokenizer(line, " \t\n\r\f.,;:-?¿!¡'"); | ||
while (itr.hasMoreTokens()) { | ||
word.set(itr.nextToken().toLowerCase()); | ||
output.collect(word, one); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* A reducer class that just emits the sum of the input values. | ||
*/ | ||
public static class Reduce extends MapReduceBase | ||
implements Reducer<Text, IntWritable, Text, IntWritable> { | ||
|
||
public void reduce(Text key, Iterator<IntWritable> values, | ||
OutputCollector<Text, IntWritable> output, | ||
Reporter reporter) throws IOException { | ||
int sum = 0; | ||
while (values.hasNext()) { | ||
sum += values.next().get(); | ||
} | ||
if (sum>1000) output.collect(key, new IntWritable(sum)); | ||
} | ||
} | ||
|
||
static int printUsage() { | ||
System.out.println("wordcount [-m <maps>] [-r <reduces>] <input> <output>"); | ||
ToolRunner.printGenericCommandUsage(System.out); | ||
return -1; | ||
} | ||
|
||
/** | ||
* The main driver for word count map/reduce program. | ||
* Invoke this method to submit the map/reduce job. | ||
* @throws IOException When there is communication problems with the | ||
* job tracker. | ||
*/ | ||
public int run(String[] args) throws Exception { | ||
JobConf conf = new JobConf(getConf(), WordCount.class); | ||
conf.setJobName("wordcount"); | ||
|
||
// the keys are words (strings) | ||
conf.setOutputKeyClass(Text.class); | ||
// the values are counts (ints) | ||
conf.setOutputValueClass(IntWritable.class); | ||
|
||
conf.setMapperClass(MapClass.class); | ||
conf.setCombinerClass(Reduce.class); | ||
conf.setReducerClass(Reduce.class); | ||
|
||
List<String> other_args = new ArrayList<String>(); | ||
for(int i=0; i < args.length; ++i) { | ||
try { | ||
if ("-m".equals(args[i])) { | ||
conf.setNumMapTasks(Integer.parseInt(args[++i])); | ||
} else if ("-r".equals(args[i])) { | ||
conf.setNumReduceTasks(Integer.parseInt(args[++i])); | ||
} else { | ||
other_args.add(args[i]); | ||
} | ||
} catch (NumberFormatException except) { | ||
System.out.println("ERROR: Integer expected instead of " + args[i]); | ||
return printUsage(); | ||
} catch (ArrayIndexOutOfBoundsException except) { | ||
System.out.println("ERROR: Required parameter missing from " + | ||
args[i-1]); | ||
return printUsage(); | ||
} | ||
} | ||
// Make sure there are exactly 2 parameters left. | ||
if (other_args.size() != 2) { | ||
System.out.println("ERROR: Wrong number of parameters: " + | ||
other_args.size() + " instead of 2."); | ||
return printUsage(); | ||
} | ||
FileInputFormat.setInputPaths(conf, other_args.get(0)); | ||
FileOutputFormat.setOutputPath(conf, new Path(other_args.get(1))); | ||
|
||
JobClient.runJob(conf); | ||
return 0; | ||
} | ||
|
||
|
||
public static void main(String[] args) throws Exception { | ||
int res = ToolRunner.run(new Configuration(), new WordCount(), args); | ||
System.exit(res); | ||
} | ||
|
||
} |
Binary file added
BIN
+2.03 KB
WordCount/WordCount_classes/org/apache/hadoop/examples/WordCount$MapClass.class
Binary file not shown.
Binary file added
BIN
+1.62 KB
WordCount/WordCount_classes/org/apache/hadoop/examples/WordCount$Reduce.class
Binary file not shown.
Binary file added
BIN
+3.29 KB
WordCount/WordCount_classes/org/apache/hadoop/examples/WordCount.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
program=`echo $1 | awk -F "." '{print $1}'` | ||
|
||
if [ ! -d "${program}_classes" ] | ||
then mkdir ${program}_classes/; | ||
fi | ||
|
||
|
||
HADOOP_PATH=/opt/hadoop | ||
|
||
HADOOP_CLASSES=/opt/hadoop-2.7.2/etc/hadoop:/opt/hadoop-2.7.2/share/hadoop/common/lib/*:/opt/hadoop-2.7.2/share/hadoop/common/*:/opt/hadoop-2.7.2/share/hadoop/hdfs:/opt/hadoop-2.7.2/share/hadoop/hdfs/lib/*:/opt/hadoop-2.7.2/share/hadoop/hdfs/*:/opt/hadoop-2.7.2/share/hadoop/yarn/lib/*:/opt/hadoop-2.7.2/share/hadoop/yarn/*:/opt/hadoop-2.7.2/share/hadoop/mapreduce/lib/*:/opt/hadoop-2.7.2/share/hadoop/mapreduce/*:/contrib/capacity-scheduler/*.jar | ||
|
||
|
||
javac -classpath $HADOOP_CLASSES -d ${program}_classes/ $1 | ||
|
||
jar -cvf ${program}.jar -C ${program}_classes/ .; |
Oops, something went wrong.