顯示具有 雲端運算 標籤的文章。 顯示所有文章
顯示具有 雲端運算 標籤的文章。 顯示所有文章

2013年12月6日 星期五

I-List: Create Your Own Lists of Links

I-List is a very helpful links share platform to share your collected links.

It provides an user friendly interface to you for sharing some kind of links.

I’ve found that there are two collections which is very helpful for some people whose subjects are for studying and implementation in statistics, accounting and computer science.

1. List of Free Accounting Software : For business/accounting area.

2. List of Free Statistical Software : For statistics area.

2013年10月11日 星期五

XPATH, MapReduce and SAX

  1. SAX Create XPath
  2. XPath4Sax
  3. SPEX: XPath Evaluation against XML Streams
  4. Apache MRQL: MRQL is a query processing and optimization system for large-scale, distributed data analysis, built on top of Apache Hadoop, Hama, and Spark.

2013年9月17日 星期二

Differences in each hadoop version

Hadoop 2.x is developed from hadoop-1.x, with the significant features over hadoop-1.x:

  • HDFS HA for NameNode (manual failover)
  • NextGen MapReduce (YARN)
  • HDFS Federation
  • Performance
  • Wire-compatibility for both HDFS and YARN/MapReduce (using protobufs)

Hadoop 0.23.x is a trunk which contains:

  • HDFS Federation
  • NextGen MapReduce (YARN)

Hadoop 1.x is developed from hadoop 0.20-security code support for:

  • security
  • HBase (append/hsynch/hflush, and security)
  • webhdfs (with full support for security)
  • performance enhanced access to local files for HBase
  • other performance enhancements, bug fixes, and features

2012年8月11日 星期六

[Google Extension] Yahoo字典查詢器

為了學英文,有點不爽Google開發的Google Dictionary。
花了一些時間,自己研究怎麼寫一個簡易的查字典工具。
最後終於完成啦!

下載網址:請按我。

2012年3月14日 星期三

[雲端運算] Google Cloud Storage 來囉!

Google Cloud Storage 開始試營運囉。什麼是Google Cloud Storage?
Google Cloud Storage提供雲端儲存服務,具備RESTful (REpresentational State Transfer) 功能,根據"REST and RESTfull web service"這篇文章的說明,對RESTful做了以下闡釋:
REST 把軟體視為 "資源"(Resource),以 URL (Uniform Resource Locator) 定位資源所在處。資源的使用者則藉由 HTTP 協定中所定義的"方法"(method)操作資源。REST 所稱的軟體,其實是資料與資料處理方法的包裝,也就是 OOP 中的 "個體"、"物件"。同時在 HTTP 中,也定義了四種基本方法,即 GET, POST, PUT, DELETE。以上四種基本方法大致上對應了四種資料處理動作,即 Create, Read, Update, Delete (CRUD) 
有興趣的讀者,可以自行看看原文解釋。

Google Cloud Storage 服務提供了以下幾種特性:

  1. 快速、高延展性與高可靠度的物件儲存服務
    1. 所有資料皆複製好幾份到Google雲端資料中心
    2. 讀寫同步
    3. 物件大小可達TB等級,支援可恢復性的上傳、下載以及Range-GET。
    4. Domain-scoped bucket命名空間
  2. 簡單、彈性 、具驗證以及共享能力
    1. 支援  OAuth 2.0 驗證
    2. 可驗證的Web下載能力
    3. 個別的、專案等級或是群組等級的控制存取
那麼,要怎麼樣才可以開發Google Cloud Storage呢?你只要:
  1. 擁有Google帳號,並且有存取Cloud Storage的能力
  2. 安裝Python 2.6或2.7
  3. 安裝最新版的GSUtil 工具
付費方式則根據儲存資料大小、網路流量大小、Request(GET, POST, PUT, HEAD)等需求,有不同的計價方式,詳細請參考官網頁面。

而Google官方則提供免費試用版本,直到2012年6月30日以前申請,你可以得到:
  • 5 GB of storage
  • 25 GB of download data (20 GB to Americas and EMEA*; 5 GB to Asia-Pacific)
  • 25 GB of upload data (20 GB to Americas and EMEA*; 5 GB to Asia-Pacific)
  • 30,000 GET, HEAD requests
  • 3,000 PUT, POST, GET bucket**, GET service** requests
這樣看起來,收費方式跟Amazon S3, Windows Azure等差不多耶。不過,因為是全球知名的Google做的,品質應該不差吧。 (它背後有強大的Google App Engine啊XD)

參考資料

2011年8月15日 星期一

[程式設計] 影像搜尋與處理相關API


1. TinEye API
說明:TinEye 的API目前看起來並沒有支援手機上使用版本。僅支援Python, Perl, Ruby, javascript, .NET等程式語言。
若要用他的手機版,得去使用他開發的PixID。(目前此版本還沒看到相關API)

2. Google Image API
Google Image API
說明:目前看起來只有提供輸入文字以搜尋相關圖片的API。
而Google Image Search 則提供了與TinEye一樣的圖片搜尋服務。不過相關API則是還沒支援,僅支援瀏覽器外掛版本。
Google 也提供了一些Java專用的圖形處理API: Image Java API ,專門替1MB以下圖片進行翻轉、刷淡、擷取縮圖等處理。

2011年7月9日 星期六

使用SVN 與 Google Docs 之備份機制優劣

筆者以前寫在Google文件內的文章,貼出來給大家奇文共賞。:)
使用SVN 與 Google Docs 之備份機制優劣 

SVN(Subversion Control System)Google Docs
優點
  • 可以自己架設,自由度高。
  • 每一次的修改都可以做記錄。
  • 必須額外裝軟體。
  • 空間可以自己擴充。
  • 免費且不用額外裝設軟體,只需要Browser即可。
  • 操作簡單。
缺點
  • 需知道SVN操作觀念。
  • 萬一SVN Server掛點,後果自行負責。
  • 欠缺完整的備份策略。
  • 空間太小(1GB),若需擴充,則需額外購買。

2011年7月1日 星期五

Multi-Thread Job in Hadoop 實驗

問題定義
假設今有2 Jobs, 皆讀取相同格式之資料,但是每個Job 處理的方式與輸出資料皆不相同。

Job 1: Source Data A→ Map → Reduce → Output B
Job 2: Source Data A→ Map → Reduce → Output C

若今天以Job1 → Job 2的順序,分別需要 20 seconds, 30 seconds。則總時間需要 50 seconds。是否能夠平行處理的技巧,達到Performance的提升?

2011年6月14日 星期二

[Java][雲端運算] 透過Hadoop Map/Reduce,將資料送到MySQL

哈哈!終於搞定了!
卡了那麼久,竟然有一行根本不該加進去的。
話不多說,先說明接下來的Code該做什麼?
首先,我修改了Hadoop WordCount範例,主要是把HDFS中的input/input.txt,透過WordCount Map/Reduce後的資料,餵進MySQL資料庫。
依照以下步驟:
1. 建立資料庫:

DROP TABLE IF EXISTS `WordCount`.`Counting`;
CREATE TABLE  `WordCount`.`Counting` (
`name` char(48) default NULL,
`count` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

2. 將以下程式碼存成DBWordCount.java

import java.io.IOException;
import java.util.*;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
import java.io.DataInput;
import java.io.DataOutput;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.hadoop.mapred.lib.db.DBWritable;
import org.apache.hadoop.mapred.lib.IdentityReducer;
import org.apache.hadoop.mapred.lib.db.DBConfiguration;
import org.apache.hadoop.mapred.lib.db.DBOutputFormat;
import org.apache.hadoop.mapred.lib.db.DBInputFormat;
/*
MySQL DB Schema:

DROP TABLE IF EXISTS `WordCount`.`Counting`;
CREATE TABLE  `WordCount`.`Counting` (
`name` char(48) default NULL,
`count` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

*/

public class DBWordCount {
    // Output Record Object
    static class WordCountInfoRecord implements Writable,  DBWritable
    {
        public String name;
        public int count;
        public WordCountInfoRecord() {

        }

        public WordCountInfoRecord(String str, int c)
        {
            this.name = str;
            this.count = c;
        }

        public void readFields(DataInput in) throws IOException {
            this.name = Text.readString(in);
            this.count = in.readInt();
        }
        public void write(DataOutput out) throws IOException {
            Text.writeString(out, this.name);
            out.writeInt(this.count);
        }

        public void readFields(ResultSet result) throws SQLException {
            this.name = result.getString(1);
            this.count = result.getInt(2);
        }
        public void write(PreparedStatement stmt) throws SQLException {
            stmt.setString(1, this.name);
            stmt.setInt(2, this.count);
        }
        public String toString() {
            return new String(this.name + " " + this.count);
        }
    }

    public static class Map extends MapReduceBase implements Mapper<LongWritable, IntWritable,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 tokenizer = new StringTokenizer(line);
        while (tokenizer.hasMoreTokens()) {
          word.set(tokenizer.nextToken());

          word.set(tokenizer.nextToken());
          output.collect(word, one);
        }
      }
    }

    public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, WordCountInfoRecord, NullWritable>
    {
      public void reduce(Text key, Iterator<intwritable> values, OutputCollector<
WordCountInfoRecord, NullWritable=""> output, Reporter reporter) throws IOException
{ int sum = 0; while (values.hasNext()) { sum += values.next().get(); } // Output Data into MySQL output.collect(new WordCountInfoRecord(key.toString(),sum), NullWritable.get()); } } public static void main(String[] args) throws Exception { // The following is basic wordcount JobConf conf = new JobConf(DBWordCount.class); conf.setJobName("MySQL DB Wordcount"); Class.forName("com.mysql.jdbc.Driver"); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(DBOutputFormat.class); FileInputFormat.setInputPaths(conf, new Path(args[0])); // Setup MySQL Connection , default account:root , no password String[] MyDBPath={"jdbc:mysql://localhost:3306/WordCount","你的帳號", "你的密碼"}; DBConfiguration.configureDB(conf, "com.mysql.jdbc.Driver",MyDBPath[0], MyDBPath[1], MyDBPath[2]); // Setup Output MySQL Format DBOutputFormat.setOutput(conf, "Counting","name", "count"); // Set Mapper and Reducer Class conf.setMapperClass(Map.class); //conf.setCombinerClass(Reduce.class); conf.setReducerClass(Reduce.class); // I've tried all combinations , but the bug still happen. conf.setMapOutputKeyClass(Text.class); conf.setMapOutputValueClass(IntWritable.class); conf.setOutputKeyClass(WordCountInfoRecord.class); conf.setOutputValueClass(NullWritable.class); JobClient.runJob(conf); } }


3. 撰寫以下Makefile:
# Author: Jyun-Yao Huang (allen501pc@gmail.com)

## Set up class path.
CLASSPATH=/opt/hadoop/hadoop-0.20.2-ant.jar:/opt/hadoop/hadoop-0.20.2-tools.jar:/opt/hadoop/hadoop-0.20.2-core.jar:/opt/hadoop/lib/mysql-connector-java-5.1.16-bin.jar:./

## Set up src files.
SRC = DBWordCount.java
## Set up class files.
OBJ = $(SRC:.java=.class)
## Set up jar file.
JAR_FILE = DBWordCount.jar
## Set up main function.
MAIN_FUNC = DBWordCount

all: $(OBJ)
        jar -cvf $(JAR_FILE) DBWordCount*.class
        make help

%.class: %.java
        javac -classpath $(CLASSPATH) $<
clean:
        hadoop fs -rmr output
cleanall:
        rm *.class *.jar
        hadoop fs -rmr output
run:
        hadoop jar $(JAR_FILE) $(MAIN_FUNC) input/input.txt

help:
        @echo "==============HELP====================="
        @echo "make run"
        @echo "=====END================"
4. 輸入以下指令:
make , make run.

大功告成!

最後,附上一張MySQL DataBase結果輸出: