x*0
2 楼
公婆第二次来,还一个月走,我每天都在崩溃的边缘
好奇板上的人最多能忍多久
好奇板上的人最多能忍多久
w*p
3 楼
下面这个是收到的coding exercise, 烦请帮忙看看。
Please design, code and send back a complete, production ready module,
第一步:
* if CLI parameter is “-g [foler_name]"
** generates 100 files in a specified folder, named from 001.txt to 100.txt
** each file contains 10,000 text lines
** each line is a space separated list of random 10 integers
** each integer contains 8 digits
** prints file generation timing statistics
*** per file
*** total
第二步
* if CLI parameter is “-s [foler_name]"
** reads 10 files from a specified folder, named from 01.txt to 10.txt and
prints out time it took to finish reading all files
** puts all the numbers into a map, with file name being the key
** uses fork/join paradigm to map/reduce this map in order to sort all the
numbers in the shortest possible time
** outputs results into a single file, with the same line structure, named
res.txt in the same folder
** prints how long it took to
*** read the files
*** sort the numbers
*** write the file
我没有java multithread 或者java concurrency的经验。
所以这句“uses fork/join paradigm to map/reduce this map”不是很懂。
第二步是不是有个Hashmap> map, 然后用Fork把每个
value -- arrayList 的integer排序?
Join的时候,再merge所有的ArrayList? 再写到file里
这个具体的fork/join咋整的。是用 java 7 的fork/join framework 吗? http://homes.cs.washington.edu/~djg/teachingMaterials/spac/grossmanSPAC_forkJoinFramework.html
http://fahdshariff.blogspot.com/2012/08/java-7-forkjoin-framewo
求指导?
还有我理解的有偏差不?
还有linux 下fork明明是create child process
咋到了java fork/join 里就是multithread 呢?
谢谢。
Please design, code and send back a complete, production ready module,
第一步:
* if CLI parameter is “-g [foler_name]"
** generates 100 files in a specified folder, named from 001.txt to 100.txt
** each file contains 10,000 text lines
** each line is a space separated list of random 10 integers
** each integer contains 8 digits
** prints file generation timing statistics
*** per file
*** total
第二步
* if CLI parameter is “-s [foler_name]"
** reads 10 files from a specified folder, named from 01.txt to 10.txt and
prints out time it took to finish reading all files
** puts all the numbers into a map, with file name being the key
** uses fork/join paradigm to map/reduce this map in order to sort all the
numbers in the shortest possible time
** outputs results into a single file, with the same line structure, named
res.txt in the same folder
** prints how long it took to
*** read the files
*** sort the numbers
*** write the file
我没有java multithread 或者java concurrency的经验。
所以这句“uses fork/join paradigm to map/reduce this map”不是很懂。
第二步是不是有个Hashmap
value -- arrayList 的integer排序?
Join的时候,再merge所有的ArrayList? 再写到file里
这个具体的fork/join咋整的。是用 java 7 的fork/join framework 吗? http://homes.cs.washington.edu/~djg/teachingMaterials/spac/grossmanSPAC_forkJoinFramework.html
http://fahdshariff.blogspot.com/2012/08/java-7-forkjoin-framewo
求指导?
还有我理解的有偏差不?
还有linux 下fork明明是create child process
咋到了java fork/join 里就是multithread 呢?
谢谢。
d*d
4 楼
前十二名如下:
1 QueeWinX 27.36%
2 biot 27.20%
3 carrix 23.35%
4 yaofei 18.06%
5 HTO 15.61%
6 mitbbs2020 15.50%
7 ll111 15.10%
8 cherry88 13.12%
9 McWave 11.27%
10 laridoff 11.59%
11 Trader01117 11.37%
12 Bridgewatre 10.13%
反指:
81 flr -22.44%
1 QueeWinX 27.36%
2 biot 27.20%
3 carrix 23.35%
4 yaofei 18.06%
5 HTO 15.61%
6 mitbbs2020 15.50%
7 ll111 15.10%
8 cherry88 13.12%
9 McWave 11.27%
10 laridoff 11.59%
11 Trader01117 11.37%
12 Bridgewatre 10.13%
反指:
81 flr -22.44%
F*k
5 楼
嫌麻烦,I returned.
j*3
7 楼
菜鸟不会,帮你把帖子顶起来哈
c*8
8 楼
能坐稳反指也是艺术
K*n
9 楼
我还没退... 不知道该怎么弄...
ebay上有卖office2010的,就是这个版本的...
ebay上有卖office2010的,就是这个版本的...
p*g
11 楼
有趣 mark 下。
m*0
12 楼
I missed 150% gain:(
M*s
13 楼
one day
b*n
14 楼
我觉得就是你说的那样。
用Java的forkjoin framework,
input size大就继续fork,然后merge结果返回上一层。
一个JVM只有一个process,concurrency只能通过multithread实现。
fork到底是什么不重要吧。对你解决问题有什么影响么。。
用Java的forkjoin framework,
input size大就继续fork,然后merge结果返回上一层。
一个JVM只有一个process,concurrency只能通过multithread实现。
fork到底是什么不重要吧。对你解决问题有什么影响么。。
y*i
15 楼
风水轮流转啊,哈哈。
v*6
22 楼
是有多难相处啊。。。我觉得来多久都行,pp做的饭还挺好吃的,我lg比我挑。。。
w*p
29 楼
就是指定一定要用forkjoin。 不是想太多。
这道题考的就是同时处理多个文件。这个是经典的hadoop的考题,说白了,是模
拟hadoop 的程序。不是简单的java刷题算法。
如果您懂Java8, nio还请指教。我要如何同时handle多个文件的处理。给个链接啊,
关键词啥的都好。
我找了好多links,都没有发现到底怎么整。
多谢了。
【在 b*****n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: Why do you need stream and nio for this problem?
: 你写的大概就是stream怎么搞map reduce的一种实现方式。
: nio你需要用来做什么?aynch同时处理多个文件?感觉不是这道题目考查的地方。
: 如果不用forkjoin的话应该是可以的,但是貌似这里说了一定要forkjoin,所以你可能
: 想太多了。
这道题考的就是同时处理多个文件。这个是经典的hadoop的考题,说白了,是模
拟hadoop 的程序。不是简单的java刷题算法。
如果您懂Java8, nio还请指教。我要如何同时handle多个文件的处理。给个链接啊,
关键词啥的都好。
我找了好多links,都没有发现到底怎么整。
多谢了。
【在 b*****n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: Why do you need stream and nio for this problem?
: 你写的大概就是stream怎么搞map reduce的一种实现方式。
: nio你需要用来做什么?aynch同时处理多个文件?感觉不是这道题目考查的地方。
: 如果不用forkjoin的话应该是可以的,但是貌似这里说了一定要forkjoin,所以你可能
: 想太多了。
b*n
31 楼
You are totally on the wrong track.
nio只是为了提供channel做IO读写,根本不是这个题目考察的地方。
一个thread写一个file不行么?nio跟hadoop有什么必然联系?
建议你先把一些基本概念理清楚了再说。
【在 w********p 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 就是指定一定要用forkjoin。 不是想太多。
: 这道题考的就是同时处理多个文件。这个是经典的hadoop的考题,说白了,是模
: 拟hadoop 的程序。不是简单的java刷题算法。
: 如果您懂Java8, nio还请指教。我要如何同时handle多个文件的处理。给个链接啊,
: 关键词啥的都好。
: 我找了好多links,都没有发现到底怎么整。
: 多谢了。
nio只是为了提供channel做IO读写,根本不是这个题目考察的地方。
一个thread写一个file不行么?nio跟hadoop有什么必然联系?
建议你先把一些基本概念理清楚了再说。
【在 w********p 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 就是指定一定要用forkjoin。 不是想太多。
: 这道题考的就是同时处理多个文件。这个是经典的hadoop的考题,说白了,是模
: 拟hadoop 的程序。不是简单的java刷题算法。
: 如果您懂Java8, nio还请指教。我要如何同时handle多个文件的处理。给个链接啊,
: 关键词啥的都好。
: 我找了好多links,都没有发现到底怎么整。
: 多谢了。
l*n
36 楼
这种事情完全属于具体情况具体分析;相处得好的家庭住半年也没事,相处不好的比如
饮食卫生消费方面差距特别大的,住一天都是大家受罪。
饮食卫生消费方面差距特别大的,住一天都是大家受罪。
w*p
37 楼
我想用nio是因为,我想用Stream API (parallel streams use common fork-join
thread pool)
不过fork-join 和Parallel stream 哪个更快,是有争议的。
参看:From Imperative Programming to Fork/Join to Parallel Streams in Java 8
http://www.infoq.com/articles/forkjoin-to-parallel-streams
Fork/Join Framework vs. Parallel Streams vs. ExecutorService: The Ultimate
Fork/Join Benchmark
http://blog.takipi.com/forkjoin-framework-vs-parallel-streams-v
这题并不是要在hadoop上写,而是借用了map reduce 的概念。参看forkjoin 和Stream
的其他reference.
【在 b*****n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: You are totally on the wrong track.
: nio只是为了提供channel做IO读写,根本不是这个题目考察的地方。
: 一个thread写一个file不行么?nio跟hadoop有什么必然联系?
: 建议你先把一些基本概念理清楚了再说。
thread pool)
不过fork-join 和Parallel stream 哪个更快,是有争议的。
参看:From Imperative Programming to Fork/Join to Parallel Streams in Java 8
http://www.infoq.com/articles/forkjoin-to-parallel-streams
Fork/Join Framework vs. Parallel Streams vs. ExecutorService: The Ultimate
Fork/Join Benchmark
http://blog.takipi.com/forkjoin-framework-vs-parallel-streams-v
这题并不是要在hadoop上写,而是借用了map reduce 的概念。参看forkjoin 和Stream
的其他reference.
【在 b*****n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: You are totally on the wrong track.
: nio只是为了提供channel做IO读写,根本不是这个题目考察的地方。
: 一个thread写一个file不行么?nio跟hadoop有什么必然联系?
: 建议你先把一些基本概念理清楚了再说。
f*g
38 楼
同情!跟我妈差不多. 还不是婆婆呢,呆六个月,我差点抑郁了
B*e
40 楼
一帮没有家教的女人,土鳖给了你们太多的权利。看看伊拉克的女人吧。
现在连自己的公婆父母都嫌弃,生活上文化上有代沟,大家不能相互迁就点?
现在连自己的公婆父母都嫌弃,生活上文化上有代沟,大家不能相互迁就点?
B*e
42 楼
一帮没有家教的女人,土鳖给了你们太多的权利。看看伊拉克的女人吧。
现在连自己的公婆父母都嫌弃,生活上文化上有代沟,大家不能相互迁就点?
现在连自己的公婆父母都嫌弃,生活上文化上有代沟,大家不能相互迁就点?
S*5
45 楼
不懂,帮顶
h*4
46 楼
这个取决于双方的个性。
生活习惯相同,双方都随和的,时间长点没事。
生活习惯不同,双方都强势的,分分钟大战,或者是忍到内出血。
bless LZ,不容易,心放宽点。好你现在没娃,也不需要和公婆分工合作带娃,不高兴
还能躲出去。关键要搞定老公,公婆同住要靠老公给力,不想要和公婆同住,更需要老
公给力。
生活习惯相同,双方都随和的,时间长点没事。
生活习惯不同,双方都强势的,分分钟大战,或者是忍到内出血。
bless LZ,不容易,心放宽点。好你现在没娃,也不需要和公婆分工合作带娃,不高兴
还能躲出去。关键要搞定老公,公婆同住要靠老公给力,不想要和公婆同住,更需要老
公给力。
w*p
47 楼
程序终于吭哧吭哧写完了。
公司说要和我面聊suggestion. 头疼。不知道要建议个啥。
恳请大牛们批评指教。与其被别人challenge, 不如在这预先知道的说。一定发包子感
谢的说。
https://github.com/selinaGit/SortNFiles
为了搏眼球,牺牲下隐私。貌似无盐,切勿下载哦, 否则是小猪🐷
还有主要的reference 是下面这个link. 照葫芦画瓢的说。
http://www.oracle.com/technetwork/articles/java/fork-join-42260
我想请教下在上面的link里为什么要用static method return new object.
而不是 用非static method "public Document fromFile(File file)" 然后 new
WordCounter obj
调用obj.Document fromFile(File file)
没有concurrency 的经验。问题有点傻。求教的说。
我的理解是这样的话,fork之前,file就read到list里了,file reading不会
是多线程一起run。
class Document {
private final List lines;
Document(List lines) {
this.lines = lines;
}
List getLines() {
return this.lines;
}
static Document fromFile(File file) throws IOException {
List lines = new LinkedList<>();
try(BufferedReader reader = new BufferedReader(new FileReader(file))
) {
String line = reader.readLine();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
}
return new Document(lines);
}
}
公司说要和我面聊suggestion. 头疼。不知道要建议个啥。
恳请大牛们批评指教。与其被别人challenge, 不如在这预先知道的说。一定发包子感
谢的说。
https://github.com/selinaGit/SortNFiles
为了搏眼球,牺牲下隐私。貌似无盐,切勿下载哦, 否则是小猪🐷
还有主要的reference 是下面这个link. 照葫芦画瓢的说。
http://www.oracle.com/technetwork/articles/java/fork-join-42260
我想请教下在上面的link里为什么要用static method return new object.
而不是 用非static method "public Document fromFile(File file)" 然后 new
WordCounter obj
调用obj.Document fromFile(File file)
没有concurrency 的经验。问题有点傻。求教的说。
我的理解是这样的话,fork之前,file就read到list
是多线程一起run。
class Document {
private final List
Document(List
this.lines = lines;
}
List
return this.lines;
}
static Document fromFile(File file) throws IOException {
List
try(BufferedReader reader = new BufferedReader(new FileReader(file))
) {
String line = reader.readLine();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
}
return new Document(lines);
}
}
相关阅读