https://stackoverflow.com/questions/3091524/what-are-carriage-return-linefeed-and-form-feed
“What Are Carriage Return, Linefeed, and Form Feed?” Newline - What Are Carriage Return, Linefeed, and Form Feed? - Stack Overflow, stackoverflow.com/questions/3091524/what-are-carriage-return-linefeed-and-form-feed.
Thursday, November 9, 2017
Wednesday, July 5, 2017
About Multi-thread
https://www.jiuzhang.com/qa/2232/
“关于多线程?.” 问答 | 九章算法, www.jiuzhang.com/qa/2232/. Accessed 5 July 2017.
“关于多线程?.” 问答 | 九章算法, www.jiuzhang.com/qa/2232/. Accessed 5 July 2017.
Friday, June 30, 2017
echo SGVsbG8gZnJvbSBZaWZlbmcK | base64 -D
Wednesday, June 14, 2017
Java - why doesn't ArrayList as key in HashMap work?
https://stackoverflow.com/questions/35560067/why-doesnt-arraylist-as-key-in-hashmap-work
“Why Doesn't ArrayList as Key in HashMap Work?” Java - Why Doesn't ArrayList as Key in HashMap Work? - Stack Overflow, stackoverflow.com/questions/35560067/why-doesnt-arraylist-as-key-in-hashmap-work. Accessed 14 June 2017.
“Why Doesn't ArrayList as Key in HashMap Work?” Java - Why Doesn't ArrayList as Key in HashMap Work? - Stack Overflow, stackoverflow.com/questions/35560067/why-doesnt-arraylist-as-key-in-hashmap-work. Accessed 14 June 2017.
Tuesday, May 23, 2017
Binary Tree Postorder Traversal
This file contains hidden or 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
/** | |
* Definition of TreeNode: | |
* public class TreeNode { | |
* public int val; | |
* public TreeNode left, right; | |
* public TreeNode(int val) { | |
* this.val = val; | |
* this.left = this.right = null; | |
* } | |
* } | |
*/ | |
public class Solution { | |
/** | |
* @param root: The root of binary tree. | |
* @return: Postorder in ArrayList which contains node values. | |
*/ | |
public ArrayList<Integer> postorderTraversal(TreeNode root) { | |
// write your code here | |
ArrayList<Integer> res = new ArrayList<>(); | |
if (root == null) { | |
return res; | |
} | |
Deque<TreeNode> stack = new ArrayDeque<>(); | |
stack.push(root); | |
TreeNode cur = root; | |
while (!stack.isEmpty()) { | |
TreeNode node = stack.peek(); | |
if (node.left == null && node.right == null || | |
node.left == cur || node.right == cur) { | |
cur = stack.pop(); | |
res.add(cur.val); | |
} else { | |
if (node.right != null) { | |
stack.push(node.right); | |
} | |
if (node.left != null) { | |
stack.push(node.left); | |
} | |
} | |
} | |
return res; | |
} | |
} |
Saturday, April 8, 2017
Does Java pass by reference or pass by value?
http://www.javaworld.com/article/2077424/learn-java/does-java-pass-by-reference-or-pass-by-value.html
Sintes, Tony. “Does Java Pass by Reference or Pass by Value?” JavaWorld, JavaWorld, 26 May 2000, www.javaworld.com/article/2077424/learn-java/does-java-pass-by-reference-or-pass-by-value.html. Accessed 8 Apr. 2017.
Sintes, Tony. “Does Java Pass by Reference or Pass by Value?” JavaWorld, JavaWorld, 26 May 2000, www.javaworld.com/article/2077424/learn-java/does-java-pass-by-reference-or-pass-by-value.html. Accessed 8 Apr. 2017.
Tuesday, March 28, 2017
Operation latency
From:
https://fusiontables.google.com/DataSource?snapid=S523155yioc
Latency numbers every programmer should knowJeff Dean (http://research.google.com/people/jeff/)
https://fusiontables.google.com/DataSource?snapid=S523155yioc
Latency numbers every programmer should knowJeff Dean (http://research.google.com/people/jeff/)
| ||||||||||||||||||||||||||||||||||||||||
|
Thursday, March 23, 2017
Set, HashSet, Map, HashMap, TreeSet, TreeMap
https://teamtreehouse.com/community/set-hashset-map-hashmap-treeset-treemap
“Set, HashSet, Map, HashMap, TreeSet, TreeMap.” Set, HashSet, Map, HashMap, TreeSet, TreeMap | Treehouse Community, teamtreehouse.com/community/set-hashset-map-hashmap-treeset-treemap. Accessed 23 Mar. 2017.
“Set, HashSet, Map, HashMap, TreeSet, TreeMap.” Set, HashSet, Map, HashMap, TreeSet, TreeMap | Treehouse Community, teamtreehouse.com/community/set-hashset-map-hashmap-treeset-treemap. Accessed 23 Mar. 2017.
Tuesday, March 21, 2017
Hadoop FS/DFS
https://dzone.com/articles/difference-between-hadoop-dfs
Jain, Abhishek. “The Difference Between 'Hadoop DFS' and 'Hadoop FS' - DZone Big Data.” Dzone.com, 25 Dec. 2015, dzone.com/articles/difference-between-hadoop-dfs. Accessed 21 Mar. 2017.
Jain, Abhishek. “The Difference Between 'Hadoop DFS' and 'Hadoop FS' - DZone Big Data.” Dzone.com, 25 Dec. 2015, dzone.com/articles/difference-between-hadoop-dfs. Accessed 21 Mar. 2017.
Monday, March 20, 2017
Master-Master vs Master-Slave Database Architecture
http://stackoverflow.com/questions/3736969/master-master-vs-master-slave-database-architecture
“Master-Master vs Master-Slave Database Architecture?” Stack Overflow, stackoverflow.com/questions/3736969/master-master-vs-master-slave-database-architecture. Accessed 21 Mar. 2017.
“Master-Master vs Master-Slave Database Architecture?” Stack Overflow, stackoverflow.com/questions/3736969/master-master-vs-master-slave-database-architecture. Accessed 21 Mar. 2017.
Thursday, March 16, 2017
HashMap vs HashTable
http://stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable
“Differences between HashMap and Hashtable?” Java - Differences between HashMap and Hashtable? - Stack Overflow, stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable. Accessed 16 Mar. 2017.
“Differences between HashMap and Hashtable?” Java - Differences between HashMap and Hashtable? - Stack Overflow, stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable. Accessed 16 Mar. 2017.
Saturday, March 11, 2017
List vs ArrayList
http://stackoverflow.com/questions/9852831/polymorphism-why-use-list-list-new-arraylist-instead-of-arraylist-list-n
“Polymorphism: Why Use ‘List List = New ArrayList’ Instead of ‘ArrayList List = New ArrayList’?” Java - Polymorphism: Why Use "List List = New ArrayList" Instead of "ArrayList List = New ArrayList"? - Stack Overflow, stackoverflow.com/questions/9852831/polymorphism-why-use-list-list-new-arraylist-instead-of-arraylist-list-n. Accessed 11 Mar. 2017.
“Converting 'ArrayList to 'String[]' in Java.”
http://stackoverflow.com/questions/4042434/converting-arrayliststring-to-string-in-java
“Converting 'ArrayList to 'String[]' in Java.” Arrays - Converting 'ArrayList to 'String[]' in Java - Stack Overflow , stackoverflow.com/questions/4042434/converting-arrayliststring-to-string-in-java. Accessed 11 Mar. 2017.
“Converting 'ArrayList
Friday, March 10, 2017
P/NP/NPC
http://www.matrix67.com/blog/archives/105
“Matrix67: The Aha Moments.” Matrix67 The Aha Moments, www.matrix67.com/blog/archives/105. Accessed 10 Mar. 2017.
“Matrix67: The Aha Moments.” Matrix67 The Aha Moments, www.matrix67.com/blog/archives/105. Accessed 10 Mar. 2017.
Thursday, February 23, 2017
Static class in Java
http://www.geeksforgeeks.org/static-class-in-java/
“Static Class in Java.” GeeksforGeeks, 24 Feb. 2014, www.geeksforgeeks.org/static-class-in-java/. Accessed 23 Feb. 2017.
“Static Class in Java.” GeeksforGeeks, 24 Feb. 2014, www.geeksforgeeks.org/static-class-in-java/. Accessed 23 Feb. 2017.
Saturday, February 18, 2017
Stack
http://www.ruanyifeng.com/blog/2013/11/stack.html
“Stack的三种含义.” Stack的三种含义 - 阮一峰的网络日志, www.ruanyifeng.com/blog/2013/11/stack.html. Accessed 18 Feb. 2017.
“Stack的三种含义.” Stack的三种含义 - 阮一峰的网络日志, www.ruanyifeng.com/blog/2013/11/stack.html. Accessed 18 Feb. 2017.
An article about Google Spanner
www.wired.com/2012/11/google-spanner-time
Metz, Cade. “Exclusive: Inside Google Spanner, the Largest Single Database on Earth.” Wired, Conde Nast, 26 Nov. 2012, www.wired.com/2012/11/google-spanner-time/. Accessed 18 Feb. 2017.
Metz, Cade. “Exclusive: Inside Google Spanner, the Largest Single Database on Earth.” Wired, Conde Nast, 26 Nov. 2012, www.wired.com/2012/11/google-spanner-time/. Accessed 18 Feb. 2017.
Wednesday, February 15, 2017
Hadoop shuffle phase
Cite from http://www.cnblogs.com/edisonchou/p/4298423.html
“Edison Chou.” Hadoop学习笔记-10.Shuffle过程那点事儿 - Edison Chou - 博客园, www.cnblogs.com/edisonchou/p/4298423.html.
“Edison Chou.” Hadoop学习笔记-10.Shuffle过程那点事儿 - Edison Chou - 博客园, www.cnblogs.com/edisonchou/p/4298423.html.
Tuesday, February 14, 2017
The difference between String, StringBuffer and StringBuilder
Cite from http://blog.csdn.net/kingzone_2008/article/details/9220691
“Java:String、StringBuffer和StringBuilder的区别.” Java:String、StringBuffer和StringBuilder的区别 - __kingzone__的专栏 - 博客频道 - CSDN.NET, blog.csdn.net/kingzone_2008/article/details/9220691.
“Java:String、StringBuffer和StringBuilder的区别.” Java:String、StringBuffer和StringBuilder的区别 - __kingzone__的专栏 - 博客频道 - CSDN.NET, blog.csdn.net/kingzone_2008/article/details/9220691.
wordCount template
This file contains hidden or 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
/** | |
* Created by Yifeng Zeng on 2/14/17. | |
*/ | |
import java.io.IOException; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.IntWritable; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapreduce.Job; | |
import org.apache.hadoop.mapreduce.Mapper; | |
import org.apache.hadoop.mapreduce.Reducer; | |
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; | |
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; | |
public class WordCount { | |
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> { | |
enum WordList{ | |
Big, | |
Data, | |
Love, | |
OTHER | |
} | |
@Override | |
public void map(Object key, Text value, Context context) | |
throws IOException, InterruptedException { | |
//key: offset | |
//value: line | |
//value: I love big data | |
String[] words = value.toString().replaceAll("[,.;]", "").trim().split(" "); | |
for (String word : words) { | |
// I=1, love=1, big=1, data=1 | |
Text outKey = new Text(word); | |
IntWritable outValue = new IntWritable(1); | |
context.write(outKey, outValue); | |
if (word.toLowerCase().equals("big")) { | |
context.getCounter(WordList.Big).increment(1); | |
} else if (word.toLowerCase().equals("data")) { | |
context.getCounter(WordList.Data).increment(1); | |
} else if (word.toLowerCase().equals("love")) { | |
context.getCounter(WordList.Love).increment(1); | |
} else { | |
context.getCounter(WordList.OTHER).increment(1); | |
} | |
context.getCounter("wordCount", word).increment(1); | |
} | |
} | |
} | |
public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> { | |
@Override | |
public void reduce(Text key, Iterable<IntWritable> values, Context context) | |
throws IOException, InterruptedException { | |
//I <1> | |
//big <1, 1> | |
int sum = 0; | |
for (IntWritable value : values) { | |
sum += value.get(); | |
} | |
context.write(key, new IntWritable(sum)); | |
} | |
} | |
public static void main(String[] args) throws Exception { | |
Configuration configuration = new Configuration(); | |
Job job = new Job(configuration, "wordCount"); | |
job.setJarByClass(WordCount.class); | |
job.setMapperClass(TokenizerMapper.class); | |
job.setReducerClass(IntSumReducer.class); | |
job.setOutputKeyClass(Text.class); | |
job.setOutputValueClass(IntWritable.class); | |
FileInputFormat.addInputPath(job, new Path(args[0])); | |
FileOutputFormat.setOutputPath(job, new Path(args[1])); | |
job.waitForCompletion(true); | |
} | |
} |
Subscribe to:
Posts (Atom)