x MapReduce A Italic URL Constant width Constant width bold Constant width italic 這個圖示代表提示或建議 這個圖示代表一般註解

Similar documents
6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

未命名

目錄

1-1 database columnrow record field 不 DBMS Access Paradox SQL Server Linux MySQL Oracle IBM Informix IBM DB2 Sybase 1-2

四川省普通高等学校

untitled

基于UML建模的管理管理信息系统项目案例导航——VB篇

untitled

untitled

untitled

目錄 C ontents Chapter MTA Chapter Chapter

Java ¿ª·¢ 2.0: Óà Hadoop MapReduce ½øÐдóÊý¾Ý·ÖÎö

回滚段探究

FileMaker 16 ODBC 和 JDBC 指南

Microsoft Word - 01.DOC

Oracle 4

untitled

RUN_PC連載_8_.doc

EJB-Programming-3.PDF

ebook46-23

FileMaker 15 ODBC 和 JDBC 指南

数 据 库 系 统 基 础 2/54 第 6 章 数 据 库 管 理 与 维 护

學 科 100% ( 為 單 複 選 題, 每 題 2.5 分, 共 100 分 ) 1. 請 參 閱 附 圖 作 答 : (A) 選 項 A (B) 選 項 B (C) 選 項 C (D) 選 項 D Ans:D 2. 下 列 對 於 資 料 庫 正 規 化 (Normalization) 的 敘

untitled

RUN_PC連載_12_.doc

1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6

3.1 num = 3 ch = 'C' 2

基于ECO的UML模型驱动的数据库应用开发1.doc

JavaIO.PDF

Oracle高级复制配置手册_业务广告_.doc

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

關於本書 l 3 PhoneGap Appcelerator Titanium Sencha Touch (wrapper framework) Native App PhoneGap Build Native App Hybrid App Java Objective-C Android SDK

幻灯片 1

untitled

Java java.lang.math Java Java.util.Random : ArithmeticException int zero = 0; try { int i= 72 / zero ; }catch (ArithmeticException e ) { // } 0,

EJB-Programming-4-cn.doc

雲端 Cloud Computing 技術指南 運算 應用 平台與架構 10/04/15 11:55:46 INFO 10/04/15 11:55:53 INFO 10/04/15 11:55:56 INFO 10/04/15 11:56:05 INFO 10/04/15 11:56:07 INFO

ebook 96-16

jdbc:hsqldb:hsql: jdbc:hsqldb:hsqls: jdbc:hsqldb:http: jdbc:hsqldb:https: //localhost // :9500 / /dbserver.somedomain.com /an_alias /enrollme

p.2 1 <HTML> 2 3 <HEAD> 4 <TITLE> </TITLE> 5 </HEAD> 6 7 <BODY> 8 <H3><B> </B></H3> 9 <H4><I> </I></H4> 10 </BODY> </HTML> 1. HTML 1. 2.

untitled

0SQL SQL SQL SQL SQL 3 SQL DBMS Oracle DBMS DBMS DBMS DBMS RDBMS R DBMS 2 DBMS RDBMS R SQL SQL SQL SQL SELECT au_fname,au_ lname FROM authors ORDER BY

SQL Server SQL Server SQL Mail Windows NT

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

R D B M S O R D B M S R D B M S / O R D B M S R D B M S O R D B M S 4 O R D B M S R D B M 3. ORACLE Server O R A C L E U N I X Windows NT w w

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基

PowerPoint 演示文稿

untitled

基于CDIO一体化理念的课程教学大纲设计

vi JSON JSON API XML JSON JSON JavaScript RESTful JSON Douglas Crockford JSON / RESTful API JavaScript Node.js Ruby on Rails Java Groovy

x 前言 Python Python ETL extract transform load Python Python / Python Python Python

Chapter 9: Objects and Classes

Java Access 5-1 Server Client Client Server Server Client 5-2 DataInputStream Class java.io.datainptstream (extends) FilterInputStream InputStream Obj

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

1. 访 问 最 新 发 行 公 告 信 息 jconnect for JDBC 访 问 最 新 发 行 公 告 信 息 最 新 版 本 的 发 行 公 告 可 以 从 网 上 获 得 若 要 查 找 在 本 产 品 发 布 后 增 加 的 重 要 产 品 或 文 档 信 息, 请 访

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

一步一步教你搞网站同步镜像!|动易Cms

IoC容器和Dependency Injection模式.doc

概述

untitled

Partition Key: 字 符 串 类 型, 表 示 当 前 Entity 的 分 区 信 息 这 个 Property 对 于 Table Service 自 动 纵 向 和 横 向 扩 展 至 关 重 要 Row Key: 字 符 串 类 型, 在 给 定 Partition Key 的

习题1

JAVA String常用APi

A API Application Programming Interface 见 应 用 程 序 编 程 接 口 ARP Address Resolution Protocol 地 址 解 析 协 议 为 IP 地 址 到 对 应 的 硬 件 地 址 之 间 提 供 动 态 映 射 阿 里 云 内

01 SQL Server SQL Server 2008 SQL Server 6-1 SSIS SQL Server ( master ) ( msdb ) SQL Server ( master ) master 6-1 DTS sysadmin 6-1 sysa

一 個 SQL Injection 實 例 的 啟 示 頁 2 / 6 因 此, 在 知 名 網 站 上 看 到 SQL Injection, 讓 人 驚 心, 卻 不 意 外 網 站 專 案 外 包 是 目 前 業 界 的 常 態, 而 在 價 格 取 勝 的 制 度 下, 低 價 得 標 的 S

VB控件教程大全

coverage2.ppt

投影片 1

C/C++ 语言 - 循环

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

Java

目 录 1. 前 言 为 什 么 要 用 ESB 技 术 发 展 业 务 需 求 IT 需 求 IT 与 业 务 一 致 性 要 求 TongIntegrator ESB v5 简 介..

在 ongodb 中实现强事务

第一章 章标题-F2 上空24,下空24

Microsoft PowerPoint - ch7_1 DA class

Reducing Client Incidents through Big Data Predictive Analytics

(HMI) IO A

untitled

CH01.indd

untitled

13 根 据 各 种 网 络 商 务 信 息 对 不 同 用 户 所 产 生 的 使 用 效 用, 网 络 商 务 信 息 大 致 可 分 为 四 级, 其 中 占 比 重 最 大 的 是 ( A ) A 第 一 级 免 费 信 息 B 第 二 级 低 收 费 信 息 C 第 三 级 标 准 收 费

( Version 0.4 ) 1

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

Microsoft Word - 苹果脚本跟我学.doc

untitled

DB2 (join) SQL DB2 11 SQL DB2 SQL 9.1 DB2 DB2 ( ) SQL ( ) DB2 SQL DB2 DB2 SQL DB2 DB2 SQL DB2 ( DB2 ) DB2 DB2 DB2 SQL DB2 (1) SQL (2) S

白 皮 书 英 特 尔 IT 部 门 实 施 Apache Hadoop* 英 特 尔 分 发 版 软 件 的 最 佳 实 践 目 录 要 点 概 述...1 业 务 挑 战...2 Hadoop* 分 发 版 注 意 事 项...3 Hadoop* 基 础 架 构 注 意 事 项

untitled

ebook60-13

while ((ch = fr.read())!= -1) { System.out.print((char) ch); fr.close(); 例 3: 用 BufferedReader 读 TXT 文件 public class FileReaderDemo3 { public static v

untitled

PowerPoint 演示文稿

互動網頁技術系列課程 HTML與CSS網站基礎設計 [12pt]

<4D F736F F F696E74202D20332D322E432B2BC3E6CFF2B6D4CFF3B3CCD0F2C9E8BCC6A1AAD6D8D4D8A1A2BCCCB3D0A1A2B6E0CCACBACDBEDBBACF2E707074>

通过Hive将数据写入到ElasticSearch

ThreeDtunnel.doc

使用Cassandra和Spark 2.0实现Rest API服务

精 品 库 我 们 的 都 是 精 品 _www.jingpinwenku.com (8) 数 据 库 数 据 库 系 统 和 数 据 库 管 理 系 统 之 问 的 关 系 是 ( ) A) 数 据 库 包 括 数 据 库 系 统 和 数 据 库 管 理 系 统 B) 数 据 库 系 统 包 括

chp6.ppt

Transcription:

Java R Python Java Java Java

x MapReduce A Italic URL Constant width Constant width bold Constant width italic 這個圖示代表提示或建議 這個圖示代表一般註解

第一章 I/O double[][] int[] String[] List

2 Map JavaScript Object Notation JSON somefile.txt id year city id year city int[] id = new int[1024]; int[] year = new int[1024]; String[] city = new String[1024]; BufferedReader clean data int[] row1 = {1, 2014, 1; int[] row2 = {2, 2015, 1; int[] row3 = {3, 2014, 2; int[][] data = {{1, 2014, 1, {2, 2015, 1, {3, 2014, 2;

I/O 3 List Map somefile.txt class Record { int id; int year; String city; List Map Record RecordUtils List Record List<Record> listofrecords = new ArrayList<>(); BufferReader Record Record List<Record> listofrecords Record Map Map<String, Record> mapofrecords = new HashMap<>(); ID URL m n X i j m n x i,j x 1, 1 x 1, 2 x 1, n x 2, 1 x 2, 2 x 2, n x m,1 x m,2 x m, n

4 JSON JavaScript Object Notation JSON JSON json.org JSON HashMap {"city":"san Francisco", "year": 2020, "id": 2, "event_codes":[20, 22, 34, 19] JSON JSON ArrayList [40, 50, 70, "text", {"city":"san Francisco"] JSON JSON JSON JSON JSON Java null null "null" "NULL" "na" private boolean checknull(string value) { return value == null "null".equalsignorecase(value);

I/O 5 0 0 1 0 String.isEmpty() String.trim() String.isEmpty() true private boolean checkblank(string value) { return value.trim().isempty(); double int long Double Integer Long NumberFormatException try { double d = Double.parseDouble(value); // d catch (NumberFormatException e) { // OffsetDateTime.parse() DateTimeParseException try { OffsetDateTime odt = OffsetDateTime.parse(value); // odt catch (DateTimeParseException e) { //

6 0 1 2 minvalue = 1.0 minvalueinclusive = true 1.0 minvalueinclusive = false 1.0 public boolean checkrange(double value) { boolean minbit = (minvalueinclusive)? value >= minvalue : value > minvalue; boolean maxbit = (maxvalueinclusive)? value <= maxvalue : value < maxvalue; return minbit && maxbit; validitems Set Set.contains() private boolean checkrange(string value) { return validitems.contains(value); DateTime OffsetDateTime OffsetDateTime.isBefore() OffsetDateTime.isAfter() private boolean checkrange(offsetdatetime odt) { return odt.isafter(mindate) && odt.isbefore(maxdate); FileReader String String BufferedReader I/O 1000

I/O 7 String[] ASCII ASCII Java Unix bash less somefile.txt bash$ less somefile.txt "id","year","city" 1,2015,"San Francisco" 2,2014,"New York" 3,2012,"Los Angeles"... CSV id year city bash$ wc -l somefile.txt 1025 1024 tab TSV JSON 100 bash$ head -100 filename > new_filename 1000

8 BufferedReader FileReader FileReader String FileReader File File BufferedReader try(bufferedreader br = new BufferedReader(new FileReader("somefile.txt")) ) { String columnnames = br.readline(); // String line; while ((line = br.readline())!= null) { /* */ // TODO catch (Exception e) { System.err.println(e.getMessage()); // URL url = new URL("http://storage.example.com/public-data/somefile.txt"); try(bufferedreader br = new BufferedReader( new InputStreamReader(url.openStream())) ) { String columnnames = br.readline(); // String line; while ((line = br.readline())!= null) { // TODO catch (Exception e) { System.err.println(e.getMessage()); // 解析大字串 0001201503 0002201401 0003201202

I/O 9 id year city 32.456 New York = 01, Los Angeles = 02, and San Francisco = 03 String.substring(int beginindex, int endindex) beginindex enindex /* */ int id = Integer.parseInt(line.substring(0, 4)); int year = Integer.parseInt(line.substring(4, 8)); int city = Integer.parseInt(line.substring(8, 10)); 解析分隔字串 CSV CSV 1,2015,"San Francisco" 2,2014,"New York" 3,2012,"Los Angeles" String.split(",") String.trim() String.replace("\", "") /* */ String[] s = line.split(","); int id = Integer.parseInt(s[0].trim()); int year = Integer.parseInt(s[1].trim()); String city = s[2].trim().replace("\"", ""); somefile.txt tab 1 2015 "San Francisco" 2 2014 "New York" 3 2012 "Los Angeles" tab String.split(",") String[] s = line.split("\t");

10 CSV - San Francisco, CA regex Apache Commons CSV /* */ CSVParser parser = CSVParser.parse(line, CSVFormat.RFC4180); for(csvrecord cr : parser) { int id = cr.get(1); // 1 0 int year = cr.get(2); String city = cr.get(3); Apache Commons CSV CSVFormat.EXCEL CSVFormat.MYSQL CSVFormat.TDF 解析 JSON 字串 JSON JavaScript API RESTful MongoDB CouchDB NoSQL PostgreSQL 9.3 JSON JSON Java JSON HashMaps ArrayLists - JSON 非單引號 {"id":1, "year":2015, "city":"san Francisco" {"id":2, "year":2014, "city":"new York" {"id":3, "year":2012, "city":"los Angeles" JSON JSON JSON JSON JSON String box org. simple.json /* while JSON */ JSONParser parser = new JSONParser();... /* */

I/O 11 JSONObject obj = (JSONObject) parser.parse(line); int id = Integer.parseInt(j.get("id").toString()); int year = Integer.parseInt(j.get("year").toString()); String city = j.get("city").tostring(); JSON JSON JSON ls {{"id":1, "year":2015, "city":"san Francisco", {"id":2, "year":2014, "city":"new York", {"id":3, "year":2012, "city":"los Angeles" Simple JSON JSONParser parser = new JSONParser(); try{ JSONObject jobj = (JSONObject) parser.parse(new FileReader("data.json")); // TODO jobj catch (IOException ParseException e) { System.err.println(e.getMessage()); [{"id":1, "year":2015, "city":"san Francisco", {"id":2, "year":2014, "city":"new York", {"id":3, "year":2012, "city":"los Angeles"] JSON JSONParser parser = new JSONParser(); try{ JSONArray jarr = (JSONArray) parser.parse(new FileReader("data.json")); // TODO jobj catch (IOException ParseException e) { System.err.println(e.getMessage()); 若檔案是每一行一個 JSON 物件, 則檔案技術上並非合法的 JSON 資料結構 讀取檔案與逐行解析 JSON 物件見 讀取文字檔案 一節

12 PNG {x 1, x 2 {y 1... 2D data BufferedImage img = null; try { img = ImageIO.read(new File("Image.png")); int height = img.getheight(); int width = img.getwidth(); int[][] data = new int[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int rgb = img.getrgb(i, j); // data[i][j] = rgb; catch (IOException e) { // RGB int blue = 0x0000ff & rgb; int green = 0x0000ff & (rgb >> 8); int red = 0x0000ff & (rgb >> 16); int alpha = 0x0000ff & (rgb >> 24); byte[] pixels = ((DataBufferByte) img.getraster().getdatabuffer()).getdata(); for (int i = 0; i < pixels.length / 3 ; i++) { int blue = Byte.toUnsignedInt(pixels[3*i]); int green = Byte.toUnsignedInt(pixels[3*i+1]); int red = Byte.toUnsignedInt(pixels[3*i+2]); // 0 255 rgb (0 1) double gray = (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255.0

I/O 13 2D x n = x 1, x 2,... n m p MNIST A 1D 2D MNIST FileWriter BufferedWriter I/O \t /* */ String output = Integer.toString(record.id) + "," + Integer.toString(record.year) + "," + record.city; Java 8 String.join(delimiter, elements) /* in Java 8 */ String newstring = String.join(",", {"a", "b", "c"); /* Iterator */ String newstring = String.join(",", mylist); Apache Commons Lang StringUtils.join(elements, delimiter) StringBuilder /* in Java 7 */ String[] strings = {"a", "b", "c"; /* StringBuilder */ StringBuilder sb; sb.append(strings[0]); /* */ for(int i = 1; i < strings.length, i++){ /*... \t tab */ sb.append(","); sb.append(strings[i]); String newstring = sb.tostring();

14 mystring += mystring_part StringBuilder StringBuilder BufferedWriter.write(String) BufferedWriter.newLine() try(bufferedwriter bw = new BufferedWriter(new FileWriter("somefile.txt")) ) { for(string s : mystringlist){ bw.write(s); /* */ bw.newline(); catch (Exception e) { System.out.println(e.getMessage()); FileWriter false append /* FileWriter append */ try(bufferedwriter bw = new BufferedWriter( new FileWriter("somefile.txt", true))) { for(string s : mystringlist){ bw.write(s); /* */ bw.newline(); catch (Exception e) { System.out.println(e.getMessage()); BufferedWriter PrintWriter PrintWriter println() \n OS PrintWriter try(printwriter pw = new PrintWriter(new BufferedWriter( new FileWriter("somefile.txt"))) ) { for(string s : mystringlist){ /* */ pw.println(s); catch (Exception e) { System.out.println(e.getMessage());

I/O 15 JSON JSONObject.toSTring() JSON String String JSON JSONObject obj =... try(bufferedwriter bw = new BufferedWriter(new FileWriter("somefile.txt")) ) { bw.write(obj.tostring()); catch (Exception e) { System.out.println(e.getMessage()); JSON JSON JSONObject List<JSONObject> datalist =... try(bufferedwriter bw = new BufferedWriter(new FileWriter("somefile.txt")) ) { for(jsonobject obj : datalist){ bw.write(obj.tostring()); /* */ bw.newline(); catch (Exception e) { System.out.println(e.getMessage()); FileWriter append FileWriter append JSON try(bufferedwriter bw = new BufferedWriter( new FileWriter("somefile.txt", true)) ) {... MySQL SQL Java Database Connectivity JDBC

16 SQL Java MySQL PostgreSQL SQLite MySQL bash$ mysql <database> bash$ mysql -u root <database> bash$ mysql -h host -P port -u user -p password <database> MySQL mysql> SHOW DATABASES; USE dbname mysql> USE mydb; mysql> CREATE TABLE my_table(id INT PRIMARY KEY, stuff VARCHAR(256)); mysql> SOURCE <filename>; mysql> SHOW TABLES; mysql> DESCRIBE <tablename>;

I/O 17 SQL ORM SQL 建構 SQL CREATE DATABASE <databasename>; CREATE TABLE <tablename> ( col1 type, col2 type,...); 選取 SELECT SELECT [DISTINCT] col_name, col_name,... col_name FROM table_name [WHERE where_condition] [GROUP BY col_name [ASC DESC]] [HAVING where_condition] [ORDER BY col_name [ASC DESC]] [LIMIT row_count OFFSET offset] [INTO OUTFILE 'file_name'] ORDER BY ORDER BY RAND(); LIMIT ORDER BY RAND() LIMIT 1000; 新增 INSERT INTO tablename(col1, col2,...) VALUES(val1, val2,...);

18 INSERT INTO tablename VALUES(val1, val2,...); INSERT INTO tablename(col1, col2,...) VALUES(val1, val2,...),(val1, val2,...), (val1, val2,...); 修改 DBA UPDATE table_name SET col_name = 'value' WHERE other_col_name = 'other_val'; 刪除 UPDATE user_ id record_id DELETE FROM <tablename> WHERE <col_name> = 'col_value'; TRUNCATE TRUNCATE TRUNCATE <tablename>; 拋棄 DROP DROP TABLE <tablename>; DROP DATABASE <databasename>;