??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品一区第二页,亚洲爆乳少妇无码激情,久久亚洲2019中文字幕http://www.tkk7.com/freddychu/Javaq行到底zh-cnSat, 10 May 2025 10:52:22 GMTSat, 10 May 2025 10:52:22 GMT60转:sql优化 http://www.tkk7.com/freddychu/archive/2006/03/04/33624.html风萧?/dc:creator>风萧?/author>Sat, 04 Mar 2006 12:34:00 GMThttp://www.tkk7.com/freddychu/archive/2006/03/04/33624.htmlhttp://www.tkk7.com/freddychu/comments/33624.htmlhttp://www.tkk7.com/freddychu/archive/2006/03/04/33624.html#Feedback0http://www.tkk7.com/freddychu/comments/commentRss/33624.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/33624.htmlSql优化是一复杂的工作Q以下的一些基本原则是本h看书时所记录下来的,很明且没什么废话:

1Q?/FONT>  索引的用:

Q?/SPAN>1Q?/SPAN>.当插入的数据为数据表中的记录数量?/SPAN>10%以上Q首先需要删除该表的索引来提高数据的插入效率Q当数据插入后,再徏立烦引?/SPAN>

Q?/SPAN>2Q?/SPAN>.避免在烦引列上用函数或计算Q在where子句中,如果索引是函数的一部分Q优化器不再用烦引而用全表扫描。如Q?/SPAN>

低效Q?/SPAN>select * from dept where sal*12 >2500;

高效Q?/SPAN>select * from dept where sal>2500/12;

(3).避免在烦引列上?/SPAN>not?/SPAN> ?/SPAN>!=”,索引只能告诉什么存在于表中Q而不能告诉什么不存在于表中,当数据库遇到not ?/SPAN> ?/SPAN>!=”时Q就会停止用烦引而去执行全表扫描?/SPAN>

(4).索引列上>=代替>

 低效Q?/SPAN>select * from emp where deptno > 3

 高效Q?/SPAN>select * from emp where deptno >=4

两者的区别在于Q前?/SPAN>dbms直接蟩到第一?/SPAN>deptno{于4的记录,而后者将首先定位?/SPAN>deptno{于3的记录ƈ且向前扫描到W一?/SPAN>deptno大于3的?/SPAN>

(5).非要对一个用函数的列启用烦引,Z函数的烦引是一个较好的Ҏ?/SPAN>

2. 游标的用:

   当在量的数据表中进行数据的删除、更新、插入操作时Q用游标处理的效率是最慢的Q但是游标又是必不可的Q所以正用游标十分重要:

   (1). 在数据抽取的源表中用时间戳Q这h天的l表数据l护只针Ҏ新日期ؓ最新时间的数据来进行,大大减少需要维护的数据记录数?/SPAN>

   (2). ?/SPAN>insert?/SPAN>updatel表旉加上一个条件来qol表中已l存在的记录Q例如:

insert into dim_customer select * from ods_customer where ods_customer.code not exists (dim_customer.code)

 ods_customer为数据源表?/SPAN>dim_customer为维表?/SPAN>

   (3). 使用昑ּ的游标,因ؓ隐式的游标将会执行两ơ操作,W一ơ检索记录,W二ơ检?/SPAN>too many rowsq个exception,而显式游标不执行W二ơ操作?/SPAN>

3Q?/FONT>  据抽取和上蝲时的sql优化Q?/SPAN>

(1). Where 子句中的q接序Q?/SPAN>

oracle采用自下而上的顺序解?/SPAN>where子句Q根据这个原理,表之间的q接必须写在其他where条g之前Q那些可以过滤掉大量记录的条件必d?/SPAN>where子句的末。如Q?/SPAN>

低效Q?/SPAN>select * from emp e where sal>5000 and job = ‘manager?and 25<(select count (*) from emp where mgr=e.empno);

高效Q?/SPAN>select * from emp e where 25<(select count(*) from emp where mgr=e.empno) and sal>5000 and job=’manager?

   (2). 删除全表Ӟ?/SPAN>truncate 替代 delete,同时注意truncate只能在删除全表时适用Q因?/SPAN>truncate?/SPAN>ddl而不?/SPAN>dml?/SPAN>

   (3). 量多?/SPAN>commit

只要有可能就在程序中Ҏ?/SPAN>delete,insert,update操作量多?/SPAN>commit,q样pȝ性能会因?/SPAN>commit所释放的资源而大大提高?/SPAN>

   (4). ?/SPAN>exists替代in Q可以提高查询的效率?/SPAN>

   (5). ?/SPAN>not exists 替代 not in

   (6). 优化group by

提高group by语句的效率,可以不需要的记录?/SPAN>group by之前qo掉。如Q?/SPAN>

低效Q?/SPAN>select job, avg(sal) from emp group by job having job = ‘president?or job=’manager?

高效Q?/SPAN> select job, avg(sal) from emp having  job=’president?or job=’manager?group by job;

   (7). 有条件的使用union-all 替代 unionQ这样做排序׃必要了,效率会提?/SPAN>3?/SPAN>5倍?/SPAN>

   (8). 分离表和索引

       L你的表和烦引徏立在不同的表I间内,决不要将不属?/SPAN>oracle内部pȝ的对象存攑ֈsystem表空间内。同时确保数据表I间和烦引表I间|于不同的硬盘控制卡控制的硬盘上?/SPAN>


转自Q?A >http://blog.csdn.net/eigo/archive/2006/03/02/614157.aspx

]]>
转:数据库笔试题 http://www.tkk7.com/freddychu/archive/2006/03/04/33623.html风萧?/dc:creator>风萧?/author>Sat, 04 Mar 2006 12:31:00 GMThttp://www.tkk7.com/freddychu/archive/2006/03/04/33623.htmlhttp://www.tkk7.com/freddychu/comments/33623.htmlhttp://www.tkk7.com/freddychu/archive/2006/03/04/33623.html#Feedback1http://www.tkk7.com/freddychu/comments/commentRss/33623.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/33623.html/*
Q?BR>dept:
 deptno(primary key),dname,loc
emp:
 empno(primary key),ename,job,mgr,sal,deptno
*/

1 列出emp表中各部门的部门P最高工资,最低工?BR>select max(sal) as 最高工?min(sal) as 最低工?deptno from emp group by deptno;

2 列出emp表中各部门job?CLERK'的员工的最低工资,最高工?BR>select max(sal) as 最高工?min(sal) as 最低工?deptno as 部门?from emp where job = 'CLERK' group by deptno;

3 对于emp中最低工资小?000的部门,列出job?CLERK'的员工的部门P最低工资,最高工?BR>select max(sal) as 最高工?min(sal) as 最低工?deptno as 部门?from emp as b
where job='CLERK' and 1000>(select min(sal) from emp as a where a.deptno=b.deptno) group by b.deptno

4 Ҏ部门L高而低Q工资有低而高列出每个员工的姓名,部门P工资
select deptno as 部门?ename as 姓名,sal as 工资 from emp order by deptno desc,sal asc

5 写出对上题的另一解决Ҏ
Q请补充Q?/P>

6 列出'张三'所在部门中每个员工的姓名与部门?BR>select ename,deptno from emp where deptno = (select deptno from emp where ename = '张三')

7 列出每个员工的姓名,工作Q部门号Q部门名
select ename,job,emp.deptno,dept.dname from emp,dept where emp.deptno=dept.deptno

8 列出emp中工作ؓ'CLERK'的员工的姓名Q工作,部门P部门?BR>select ename,job,dept.deptno,dname from emp,dept where dept.deptno=emp.deptno and job='CLERK'

9 对于emp中有理者的员工Q列出姓名,理者姓名(理者外键ؓmgrQ?BR>select a.ename as 姓名,b.ename as 理?from emp as a,emp as b where a.mgr is not null and a.mgr=b.empno

10 对于dept表中Q列出所有部门名Q部门号Q同时列出各部门工作?CLERK'的员工名与工?BR>select dname as 部门?dept.deptno as 部门?ename as 员工?job as 工作 from dept,emp
where dept.deptno *= emp.deptno and job = 'CLERK'

11 对于工资高于本部门^均水q的员工Q列出部门号Q姓名,工资Q按部门h?BR>select a.deptno as 部门?a.ename as 姓名,a.sal as 工资 from emp as a
where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) order by a.deptno

12 对于empQ列出各个部门中q_工资高于本部门^均水q的员工数和部门P按部门号排序
select count(a.sal) as 员工?a.deptno as 部门?from emp as a
where a.sal>(select avg(sal) from emp as b where a.deptno=b.deptno) group by a.deptno order by a.deptno

13 对于emp中工资高于本部门q_水^Qh数多?人的Q列出部门号Qh敎ͼ按部门号排序
select count(a.empno) as 员工?a.deptno as 部门?avg(sal) as q_工资 from emp as a
where (select count(c.empno) from emp as c where c.deptno=a.deptno and c.sal>(select avg(sal) from emp as b where c.deptno=b.deptno))>1
group by a.deptno order by a.deptno

14 对于emp中低于自己工资至?人的员工Q列出其部门P姓名Q工资,以及工资于自己的h?BR>select a.deptno,a.ename,a.sal,(select count(b.ename) from emp as b where b.sal<a.sal) as 人数 from emp as a
where (select count(b.ename) from emp as b where b.sal<a.sal)>5


转自Q?A >http://blog.csdn.net/woolceo/archive/2006/03/02/614094.aspx



]]>
在部|PORTAL目Ӟ遇到异常QRepoExceptionTextFormatter ClassNotFound http://www.tkk7.com/freddychu/archive/2006/02/15/30886.html风萧?/dc:creator>风萧?/author>Wed, 15 Feb 2006 15:14:00 GMThttp://www.tkk7.com/freddychu/archive/2006/02/15/30886.htmlhttp://www.tkk7.com/freddychu/comments/30886.htmlhttp://www.tkk7.com/freddychu/archive/2006/02/15/30886.html#Feedback0http://www.tkk7.com/freddychu/comments/commentRss/30886.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/30886.htmlException:weblogic.management.ApplicationException: prepare failed for content_repo.jar Module: content_repo.jar Error: Exception preparing module: EJBModule(content_repo.jar,status=NEW) Unable to deploy EJB: content_repo.jar from content_repo.jar: Class not found: com.bea.content.repo.i18n.RepoExceptionTextFormatter java.lang.NoClassDefFoundError: Class not found: com.bea.content.repo.i18n.RepoExceptionTextFormatter at weblogic.ejb20.compliance.EJBComplianceChecker.check([Ljava.lang.Object;)V(EJBComplianceChecker.java:287)

我在weblogic81 sp3的doc中没有发现com.bea.content.repo.i18nq个package.

重新安装了weblogic sp4Q就不再出现q个错误了?img src ="http://www.tkk7.com/freddychu/aggbug/30886.html" width = "1" height = "1" />

]]>
GOOGLE挑战赛练习题3及答?/title><link>http://www.tkk7.com/freddychu/archive/2005/11/27/21591.html</link><dc:creator>风萧?/dc:creator><author>风萧?/author><pubDate>Sun, 27 Nov 2005 15:42:00 GMT</pubDate><guid>http://www.tkk7.com/freddychu/archive/2005/11/27/21591.html</guid><wfw:comment>http://www.tkk7.com/freddychu/comments/21591.html</wfw:comment><comments>http://www.tkk7.com/freddychu/archive/2005/11/27/21591.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/freddychu/comments/commentRss/21591.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/freddychu/services/trackbacks/21591.html</trackback:ping><description><![CDATA[<TABLE> <TBODY> <TR> <TD colSpan=2> <H3>Problem Statement </H3></TD></TR> <TR> <TD>     </TD> <TD>When editing a single line of text, there are four keys that can be used to move the cursor: end, home, left-arrow and right-arrow. As you would expect, left-arrow and right-arrow move the cursor one character left or one character right, unless the cursor is at the beginning of the line or the end of the line, respectively, in which case the keystrokes do nothing (the cursor does not wrap to the previous or next line). The home key moves the cursor to the beginning of the line, and the end key moves the cursor to the end of the line.<BR><BR>You will be given a int, <B>N</B>, representing the number of character in a line of text. The cursor is always between two adjacent characters, at the beginning of the line, or at the end of the line. It starts before the first character, at position 0. The position after the last character on the line is position <B>N</B>. You should simulate a series of keystrokes and return the final position of the cursor. You will be given a String where characters of the String represent the keystrokes made, in order. 'L' and 'R' represent left and right, while 'H' and 'E' represent home and end. </TD></TR> <TR> <TD colSpan=2> <H3>Definition </H3></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD>Class: </TD> <TD>CursorPosition </TD></TR> <TR> <TD>Method: </TD> <TD>getPosition </TD></TR> <TR> <TD>Parameters: </TD> <TD>String, int </TD></TR> <TR> <TD>Returns: </TD> <TD>int </TD></TR> <TR> <TD>Method signature: </TD> <TD>int getPosition(String keystrokes, int N) </TD></TR> <TR> <TD colSpan=2>(be sure your method is public) </TD></TR></TBODY></TABLE></TD></TR> <TR> <TD>     </TD></TR> <TR> <TD></TD></TR> <TR> <TD colSpan=2> <H3>Constraints </H3></TD></TR> <TR> <TD vAlign=top align=middle>- </TD> <TD><B>keystrokes</B> will be contain between 1 and 50 'L', 'R', 'H', and 'E' characters, inclusive. </TD></TR> <TR> <TD vAlign=top align=middle>- </TD> <TD><B>N</B> will be between 1 and 100, inclusive. </TD></TR> <TR> <TD colSpan=2> <H3>Examples </H3></TD></TR> <TR> <TD noWrap align=middle>0) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"ERLLL"</PRE></TD></TR> <TR> <TD><PRE>10</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: 7</PRE></TD></TR> <TR> <TD> <TABLE> <TBODY> <TR> <TD colSpan=2>First, we go to the end of the line at position 10. Then, the right-arrow does nothing because we are already at the end of the line. Finally, three left-arrows brings us to position 7. </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>1) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"EHHEEHLLLLRRRRRR"</PRE></TD></TR> <TR> <TD><PRE>2</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: 2</PRE></TD></TR> <TR> <TD> <TABLE> <TBODY> <TR> <TD colSpan=2>All the right-arrows at the end ensure that we end up at the end of the line. </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>2) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"ELLLELLRRRRLRLRLLLRLLLRLLLLRLLRRRL"</PRE></TD></TR> <TR> <TD><PRE>10</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: 3</PRE></TD></TR> <TR> <TD></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>3) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"RRLEERLLLLRLLRLRRRLRLRLRLRLLLLL"</PRE></TD></TR> <TR> <TD><PRE>19</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: 12</PRE></TD></TR> <TR> <TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE> <HR> <P>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. <BR><BR>{案Q?BR><BR><BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_29_699_Open_Image onclick="this.style.display='none'; Codehighlighter1_29_699_Open_Text.style.display='none'; Codehighlighter1_29_699_Closed_Image.style.display='inline'; Codehighlighter1_29_699_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_29_699_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_29_699_Closed_Text.style.display='none'; Codehighlighter1_29_699_Open_Image.style.display='inline'; Codehighlighter1_29_699_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> CursorPosition </SPAN><SPAN id=Codehighlighter1_29_699_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_29_699_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_80_471_Open_Image onclick="this.style.display='none'; Codehighlighter1_80_471_Open_Text.style.display='none'; Codehighlighter1_80_471_Closed_Image.style.display='inline'; Codehighlighter1_80_471_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_80_471_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_80_471_Closed_Text.style.display='none'; Codehighlighter1_80_471_Open_Image.style.display='inline'; Codehighlighter1_80_471_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> getPosition(String keystrokes, </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> N)</SPAN><SPAN id=Codehighlighter1_80_471_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_80_471_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> position </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        String s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_165_447_Open_Image onclick="this.style.display='none'; Codehighlighter1_165_447_Open_Text.style.display='none'; Codehighlighter1_165_447_Closed_Image.style.display='inline'; Codehighlighter1_165_447_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_165_447_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_165_447_Closed_Text.style.display='none'; Codehighlighter1_165_447_Open_Image.style.display='inline'; Codehighlighter1_165_447_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> keystrokes.length(); i</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_165_447_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_165_447_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> keystrokes.substring(i, i</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_224_277_Open_Image onclick="this.style.display='none'; Codehighlighter1_224_277_Open_Text.style.display='none'; Codehighlighter1_224_277_Closed_Image.style.display='inline'; Codehighlighter1_224_277_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_224_277_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_224_277_Closed_Text.style.display='none'; Codehighlighter1_224_277_Open_Image.style.display='inline'; Codehighlighter1_224_277_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">L</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.equals(s))</SPAN><SPAN id=Codehighlighter1_224_277_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_224_277_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(position </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #0000ff">continue</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                position</SPAN><SPAN style="COLOR: #000000">--</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_299_352_Open_Image onclick="this.style.display='none'; Codehighlighter1_299_352_Open_Text.style.display='none'; Codehighlighter1_299_352_Closed_Image.style.display='inline'; Codehighlighter1_299_352_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_299_352_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_299_352_Closed_Text.style.display='none'; Codehighlighter1_299_352_Open_Image.style.display='inline'; Codehighlighter1_299_352_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">R</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.equals(s))</SPAN><SPAN id=Codehighlighter1_299_352_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_299_352_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(position </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> N) </SPAN><SPAN style="COLOR: #0000ff">continue</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                position</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_374_397_Open_Image onclick="this.style.display='none'; Codehighlighter1_374_397_Open_Text.style.display='none'; Codehighlighter1_374_397_Closed_Image.style.display='inline'; Codehighlighter1_374_397_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_374_397_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_374_397_Closed_Text.style.display='none'; Codehighlighter1_374_397_Open_Image.style.display='inline'; Codehighlighter1_374_397_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">H</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.equals(s))</SPAN><SPAN id=Codehighlighter1_374_397_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_374_397_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                position </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_419_442_Open_Image onclick="this.style.display='none'; Codehighlighter1_419_442_Open_Text.style.display='none'; Codehighlighter1_419_442_Closed_Image.style.display='inline'; Codehighlighter1_419_442_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_419_442_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_419_442_Closed_Text.style.display='none'; Codehighlighter1_419_442_Open_Image.style.display='inline'; Codehighlighter1_419_442_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">E</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.equals(s))</SPAN><SPAN id=Codehighlighter1_419_442_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_419_442_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                position </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> N;<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> position;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_474_497_Open_Image onclick="this.style.display='none'; Codehighlighter1_474_497_Open_Text.style.display='none'; Codehighlighter1_474_497_Closed_Image.style.display='inline'; Codehighlighter1_474_497_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_474_497_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_474_497_Closed_Text.style.display='none'; Codehighlighter1_474_497_Open_Image.style.display='inline'; Codehighlighter1_474_497_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_474_497_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</SPAN><SPAN id=Codehighlighter1_474_497_Open_Text><SPAN style="COLOR: #008000">/**</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>     * </SPAN><SPAN style="COLOR: #808080">@param</SPAN><SPAN style="COLOR: #008000"> args<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>     </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_539_696_Open_Image onclick="this.style.display='none'; Codehighlighter1_539_696_Open_Text.style.display='none'; Codehighlighter1_539_696_Closed_Image.style.display='inline'; Codehighlighter1_539_696_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_539_696_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_539_696_Closed_Text.style.display='none'; Codehighlighter1_539_696_Open_Image.style.display='inline'; Codehighlighter1_539_696_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN id=Codehighlighter1_539_696_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_539_696_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        CursorPosition cursorPosition </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> CursorPosition();<BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> cursor </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> cursorPosition.getPosition(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ERLLL</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, </SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">cursor:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> cursor);<BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.tkk7.com/freddychu/aggbug/21591.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/freddychu/" target="_blank">风萧?/a> 2005-11-27 23:42 <a href="http://www.tkk7.com/freddychu/archive/2005/11/27/21591.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>GOOGLE挑战赛练习题2及答?/title><link>http://www.tkk7.com/freddychu/archive/2005/11/27/21589.html</link><dc:creator>风萧?/dc:creator><author>风萧?/author><pubDate>Sun, 27 Nov 2005 15:40:00 GMT</pubDate><guid>http://www.tkk7.com/freddychu/archive/2005/11/27/21589.html</guid><wfw:comment>http://www.tkk7.com/freddychu/comments/21589.html</wfw:comment><comments>http://www.tkk7.com/freddychu/archive/2005/11/27/21589.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/freddychu/comments/commentRss/21589.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/freddychu/services/trackbacks/21589.html</trackback:ping><description><![CDATA[<TABLE> <TBODY> <TR> <TD colSpan=2> <H3>Problem Statement </H3></TD></TR> <TR> <TD>     </TD> <TD>A square matrix is a grid of NxN numbers. For example, the following is a 3x3 matrix: <PRE> 4 3 5 2 4 5 0 1 9</PRE>One way to represent a matrix of numbers, each of which is between 0 and 9 inclusive, is as a row-major String. To generate the String, simply concatenate all of the elements from the first row followed by the second row and so on, without any spaces. For example, the above matrix would be represented as "435245019".<BR><BR>You will be given a square matrix as a row-major String. Your task is to convert it into a String[], where each element represents one row of the original matrix. Element i of the String[] represents row i of the matrix. You should not include any spaces in your return. Hence, for the above String, you would return {"435","245","019"}. If the input does not represent a square matrix because the number of characters is not a perfect square, return an empty String[], {}. </TD></TR> <TR> <TD colSpan=2> <H3>Definition </H3></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD>Class: </TD> <TD>MatrixTool </TD></TR> <TR> <TD>Method: </TD> <TD>convert </TD></TR> <TR> <TD>Parameters: </TD> <TD>String </TD></TR> <TR> <TD>Returns: </TD> <TD>String[] </TD></TR> <TR> <TD>Method signature: </TD> <TD>String[] convert(String s) </TD></TR> <TR> <TD colSpan=2>(be sure your method is public) </TD></TR></TBODY></TABLE></TD></TR> <TR> <TD>     </TD></TR> <TR> <TD></TD></TR> <TR> <TD colSpan=2> <H3>Constraints </H3></TD></TR> <TR> <TD vAlign=top align=middle>- </TD> <TD><B>s</B> will contain between 1 and 50 digits, inclusive. </TD></TR> <TR> <TD colSpan=2> <H3>Examples </H3></TD></TR> <TR> <TD noWrap align=middle>0) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"435245019"</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: {"435", "245", "019" }</PRE></TD></TR> <TR> <TD> <TABLE> <TBODY> <TR> <TD colSpan=2>The example above. </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>1) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"9"</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: {"9" }</PRE></TD></TR> <TR> <TD></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>2) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"0123456789"</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: { }</PRE></TD></TR> <TR> <TD> <TABLE> <TBODY> <TR> <TD colSpan=2>This input has 10 digits, and 10 is not a perfect square. </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD noWrap align=middle>3) </TD> <TD></TD></TR> <TR> <TD>     </TD> <TD> <TABLE> <TBODY> <TR> <TD> <TABLE> <TBODY> <TR> <TD><PRE>"3357002966366183191503444273807479559869883303524"</PRE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD><PRE>Returns: {"3357002", "9663661", "8319150", "3444273", "8074795", "5986988", "3303524" }</PRE></TD></TR> <TR> <TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE> <HR> <P>This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. <BR><BR>{案Q?BR><BR><BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG id=Codehighlighter1_24_689_Open_Image onclick="this.style.display='none'; Codehighlighter1_24_689_Open_Text.style.display='none'; Codehighlighter1_24_689_Closed_Image.style.display='inline'; Codehighlighter1_24_689_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_24_689_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_24_689_Closed_Text.style.display='none'; Codehighlighter1_24_689_Open_Image.style.display='inline'; Codehighlighter1_24_689_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> MatrixTool </SPAN><SPAN id=Codehighlighter1_24_689_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_24_689_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_61_405_Open_Image onclick="this.style.display='none'; Codehighlighter1_61_405_Open_Text.style.display='none'; Codehighlighter1_61_405_Closed_Image.style.display='inline'; Codehighlighter1_61_405_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_61_405_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_61_405_Closed_Text.style.display='none'; Codehighlighter1_61_405_Open_Image.style.display='inline'; Codehighlighter1_61_405_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> String[] convert(String s)</SPAN><SPAN id=Codehighlighter1_61_405_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_61_405_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_117_147_Open_Image onclick="this.style.display='none'; Codehighlighter1_117_147_Open_Text.style.display='none'; Codehighlighter1_117_147_Closed_Image.style.display='inline'; Codehighlighter1_117_147_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_117_147_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_117_147_Closed_Text.style.display='none'; Codehighlighter1_117_147_Open_Image.style.display='inline'; Codehighlighter1_117_147_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (s </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000"> s.length() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000"> s.length() </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">50</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_117_147_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_117_147_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_141_142_Open_Image onclick="this.style.display='none'; Codehighlighter1_141_142_Open_Text.style.display='none'; Codehighlighter1_141_142_Closed_Image.style.display='inline'; Codehighlighter1_141_142_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_141_142_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_141_142_Closed_Text.style.display='none'; Codehighlighter1_141_142_Open_Image.style.display='inline'; Codehighlighter1_141_142_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> String[]</SPAN><SPAN id=Codehighlighter1_141_142_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_141_142_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> length </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> s.length();<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> n </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">)Math.sqrt(length);<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_229_366_Open_Image onclick="this.style.display='none'; Codehighlighter1_229_366_Open_Text.style.display='none'; Codehighlighter1_229_366_Closed_Image.style.display='inline'; Codehighlighter1_229_366_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_229_366_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_229_366_Closed_Text.style.display='none'; Codehighlighter1_229_366_Open_Image.style.display='inline'; Codehighlighter1_229_366_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(n</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">n </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> length)</SPAN><SPAN id=Codehighlighter1_229_366_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_229_366_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            String[] result </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> String[n];<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_296_344_Open_Image onclick="this.style.display='none'; Codehighlighter1_296_344_Open_Text.style.display='none'; Codehighlighter1_296_344_Closed_Image.style.display='inline'; Codehighlighter1_296_344_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_296_344_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_296_344_Closed_Text.style.display='none'; Codehighlighter1_296_344_Open_Image.style.display='inline'; Codehighlighter1_296_344_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> n; i</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_296_344_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_296_344_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>                result[i] </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> s.substring(i</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">n, i</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">n </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> n);<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>            }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> result;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_372_402_Open_Image onclick="this.style.display='none'; Codehighlighter1_372_402_Open_Text.style.display='none'; Codehighlighter1_372_402_Closed_Image.style.display='inline'; Codehighlighter1_372_402_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_372_402_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_372_402_Closed_Text.style.display='none'; Codehighlighter1_372_402_Open_Image.style.display='inline'; Codehighlighter1_372_402_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_372_402_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_372_402_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_396_397_Open_Image onclick="this.style.display='none'; Codehighlighter1_396_397_Open_Text.style.display='none'; Codehighlighter1_396_397_Closed_Image.style.display='inline'; Codehighlighter1_396_397_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_396_397_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_396_397_Closed_Text.style.display='none'; Codehighlighter1_396_397_Open_Image.style.display='inline'; Codehighlighter1_396_397_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> String[]</SPAN><SPAN id=Codehighlighter1_396_397_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_396_397_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_409_432_Open_Image onclick="this.style.display='none'; Codehighlighter1_409_432_Open_Text.style.display='none'; Codehighlighter1_409_432_Closed_Image.style.display='inline'; Codehighlighter1_409_432_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_409_432_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_409_432_Closed_Text.style.display='none'; Codehighlighter1_409_432_Open_Image.style.display='inline'; Codehighlighter1_409_432_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_409_432_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</SPAN><SPAN id=Codehighlighter1_409_432_Open_Text><SPAN style="COLOR: #008000">/**</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>     * </SPAN><SPAN style="COLOR: #808080">@param</SPAN><SPAN style="COLOR: #008000"> args<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>     </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_474_686_Open_Image onclick="this.style.display='none'; Codehighlighter1_474_686_Open_Text.style.display='none'; Codehighlighter1_474_686_Closed_Image.style.display='inline'; Codehighlighter1_474_686_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_474_686_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_474_686_Closed_Text.style.display='none'; Codehighlighter1_474_686_Open_Image.style.display='inline'; Codehighlighter1_474_686_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN id=Codehighlighter1_474_686_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_474_686_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        MatrixTool matrix </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> MatrixTool();<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>        String[] result </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> matrix.convert(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">3357002966366183191503444273807479559869883303524</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_645_683_Open_Image onclick="this.style.display='none'; Codehighlighter1_645_683_Open_Text.style.display='none'; Codehighlighter1_645_683_Closed_Image.style.display='inline'; Codehighlighter1_645_683_Closed_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_645_683_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_645_683_Closed_Text.style.display='none'; Codehighlighter1_645_683_Open_Image.style.display='inline'; Codehighlighter1_645_683_Open_Text.style.display='inline';" src="http://www.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> result.length; i</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_645_683_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.tkk7.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_645_683_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top>            System.out.println(result[i]);<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.tkk7.com/freddychu/aggbug/21589.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/freddychu/" target="_blank">风萧?/a> 2005-11-27 23:40 <a href="http://www.tkk7.com/freddychu/archive/2005/11/27/21589.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>GOOGLE挑战赛练习题1及答?/title><link>http://www.tkk7.com/freddychu/archive/2005/11/27/21588.html</link><dc:creator>风萧?/dc:creator><author>风萧?/author><pubDate>Sun, 27 Nov 2005 15:37:00 GMT</pubDate><guid>http://www.tkk7.com/freddychu/archive/2005/11/27/21588.html</guid><wfw:comment>http://www.tkk7.com/freddychu/comments/21588.html</wfw:comment><comments>http://www.tkk7.com/freddychu/archive/2005/11/27/21588.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/freddychu/comments/commentRss/21588.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/freddychu/services/trackbacks/21588.html</trackback:ping><description><![CDATA[     摘要: Problem Statement      A simple line drawing program uses a blank 20 x 20 pixel canvas and a directional cursor that starts at the upper left corner pointing straight down. T...  <a href='http://www.tkk7.com/freddychu/archive/2005/11/27/21588.html'>阅读全文</a><img src ="http://www.tkk7.com/freddychu/aggbug/21588.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/freddychu/" target="_blank">风萧?/a> 2005-11-27 23:37 <a href="http://www.tkk7.com/freddychu/archive/2005/11/27/21588.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>面试题荟?/title><link>http://www.tkk7.com/freddychu/archive/2005/11/16/20003.html</link><dc:creator>风萧?/dc:creator><author>风萧?/author><pubDate>Wed, 16 Nov 2005 01:59:00 GMT</pubDate><guid>http://www.tkk7.com/freddychu/archive/2005/11/16/20003.html</guid><wfw:comment>http://www.tkk7.com/freddychu/comments/20003.html</wfw:comment><comments>http://www.tkk7.com/freddychu/archive/2005/11/16/20003.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/freddychu/comments/commentRss/20003.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/freddychu/services/trackbacks/20003.html</trackback:ping><description><![CDATA[l典面试? <SCRIPT language=javascript>document.title="l典面试?- "+document.title</SCRIPT> <BR> <P>一、面向对象的三个基本特征<BR>   2、方法重载和Ҏ重写的概念和区别<BR>   3、接口和内部cR抽象类的特?BR>   4、文件读写的基本c?BR>   **5、串行化的注意事以及如何实C行化<BR>   6、线E的基本概念、线E的基本状态以及状态之间的关系<BR>   7、线E的同步、如何实现线E的同步<BR>   8、几U常用的数据l构及内部实现原理?BR>   9、Socket通信(TCP、UDP区别及Java实现方式)<BR>  **10、Java的事件委托机制和垃圾回收机制<BR>  11、JDBC调用数据库的基本步骤<BR>  **12、解析XML文g的几U方式和区别<BR>  13、Java四种基本权限的定?BR>  14、Java的国际化<BR>二、JSP<BR>   1、至要能说?个隐含对象以及他们的区别<BR>  ** 2、forward 和redirect的区?BR>   3、JSP的常用指?BR>三、servlet<BR>   1、什么情况下调用doGet()和doPost()Q?BR>   2、servlet的init()Ҏ和service()Ҏ的区?BR>   3、servlet的生命周?BR>   4、如何现实servlet的单U程模式<BR>   5、servlet的配|?BR>   6、四U会话跟t技?BR>四、EJB<BR>   **1、EJB容器提供的服?BR> 主要提供声明周期理、代码生、持l性管理、安全、事务管理、锁和ƈ发行理{服务?BR>   2、EJB的角色和三个对象<BR> EJB角色主要包括Bean开发?应用l装?部v?pȝ理?EJB容器提供?EJB服务器提供?BR> 三个对象是RemoteQLocalQ接口、HomeQLocalHomeQ接口,Beanc?BR>   2、EJB的几U类?BR> 会话QSessionQBean Q实体(EntityQBean 消息驱动的(Message DrivenQBean<BR> 会话Bean又可分ؓ有状态(StatefulQ和无状态(StatelessQ两U?BR> 实体Bean可分为Bean理的持l性(BMPQ和容器理的持l性(CMPQ两U?BR>   3、bean 实例的生命周?BR> 对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池理Q而对于Entity Bean和Statefull Session Bean存在Cache理Q通常包含创徏实例Q设|上下文、创建EJB ObjectQcreateQ、业务方法调用、remove{过E,对于存在~冲池管理的BeanQ在create之后实例q不从内存清除,而是采用~冲池调度机制不断重用实例,而对于存在Cache理的Bean则通过ȀzdLzL制保持Bean的状态ƈ限制内存中实例数量?BR>   4、激zL?BR> 以Statefull Session Bean ZQ其Cache大小军_了内存中可以同时存在的Bean实例的数量,ҎMRU或NRU法Q实例在ȀzdLzȝ态之间迁U,ȀzL制是当客L调用某个EJB实例业务ҎӞ如果对应EJB Object发现自己没有l定对应的Bean实例则从其去ȀzBean存储中(通过序列化机制存储实例)回复Q激z)此实例。状态变q前会调用对应的ejbActive和ejbPassivateҎ?BR>   5、remote接口和home接口主要作用<BR> remote接口定义了业务方法,用于EJB客户端调用业务方?BR> home接口是EJB工厂用于创徏和移除查找EJB实例<BR>   6、客服端调用EJB对象的几个基本步?BR>一?nbsp;讄JNDI服务工厂以及JNDI服务地址pȝ属?BR>二?nbsp;查找Home接口<BR>三?nbsp;从Home接口调用CreateҎ创徏Remote接口<BR>四?nbsp;通过Remote接口调用其业务方?BR>五、数据库<BR>   1、存储过E的~写<BR>   2、基本的SQL语句<BR>六、weblogic<BR>1?nbsp;如何lweblogic指定大小的内? <BR>在启动Weblogic的脚本中Q位于所在Domian对应服务器目录下的startServerNameQ,增加set MEM_ARGS=-Xms32m -Xmx200mQ可以调整最内存ؓ32MQ最?00M<BR>2?nbsp;如何讑֮的weblogic的热启动模式(开发模?与品发布模?<BR>可以在管理控制台中修改对应服务器的启动模式ؓ开发或产品模式之一。或者修Ҏ务的启动文g或者commenv文gQ增加set PRODUCTION_MODE=true?BR>3?nbsp;如何启动时不需输入用户名与密码?<BR>修改服务启动文gQ增?WLS_USER和WLS_PWV也可以在boot.properties文g中增加加密过的用户名和密?<BR>4?nbsp;在weblogic理制台中对一个应用域(或者说是一个网?Domain)q行jms及ejb或连接池{相关信息进行配|后,实际保存在什么文件中?<BR>保存在此Domain的config.xml文g中,它是服务器的核心配置文g?BR>5?nbsp;说说weblogic中一个Domain的缺省目录结?比如要将一个简单的helloWorld.jsp攑օ何目录下,然的在浏览器上就可打入http://L:端口?/helloword.jsp可以看到运行结果了? 又比如这其中用到了一个自己写的javaBean该如何办?<BR>Domain目录\服务器目录\applicationsQ将应用目录攑֜此目录下可以作为应用访问,如果是Web应用Q应用目录需要满Web应用目录要求Qjsp文g可以直接攑֜应用目录中,Javabean需要放在应用目录的WEB-INF目录的classes目录中,讄服务器的~省应用可以实现在览器上无需输入应用名?BR>6?nbsp;如何查看在weblogic中已l发布的EJB?<BR>可以使用理控制収ͼ在它的Deployment中可以查看所有已发布的EJB <BR>7?nbsp;如何在weblogic中进行ssl配置与客L的认证配|或说说j2ee(标准)q行ssl的配|?BR>~省安装中用DemoIdentity.jks和DemoTrust.jks  KeyStore实现SSLQ需要配|服务器使用Enable SSLQ配|其端口Q在产品模式下需要从CA获取U有密钥和数字证书,创徏identity和trust keystoreQ装载获得的密钥和数字证书。可以配|此SSLq接是单向还是双向的?BR>   8、在weblogic中发布ejb需涉及到哪些配|文?BR>不同cd的EJB涉及的配|文件不同,都涉及到的配|文件包括ejb-jar.xml,weblogic-ejb-jar.xmlCMP实体Bean一般还需要weblogic-cmp-rdbms-jar.xml<BR>   9、EJB需直接实现它的业务接口或Home接口?Lq理?<BR>q程接口和Home接口不需要直接实玎ͼ他们的实C码是由服务器产生的,E序q行中对应实现类会作为对应接口类型的实例被用?BR>  10、说说在weblogic中开发消息Bean时的persistent与non-persisten的差?BR>persistent方式的MDB可以保证消息传递的可靠?也就是如果EJB容器出现问题而JMS服务器依然会消息在此MDB可用的时候发送过来,而nonQpersistent方式的消息将被丢弃?BR>  11、说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看?BR>   Session Facade PatternQ用SessionBean讉KEntityBean<BR>Message Facade PatternQ实现异步调?BR>EJB Command PatternQ用Command JavaBeans取代SessionBeanQ实现轻量讉K<BR>Data Transfer Object FactoryQ通过DTO Factory化EntityBean数据提供Ҏ?BR>Generic Attribute AccessQ通过AttibuteAccess接口化EntityBean数据提供Ҏ?BR>Business InterfaceQ通过q程Q本圎ͼ接口和Beancd现相同接口规范业务逻辑一致?BR>QJQ架构的设计好坏直接媄响系l的性能、可扩展性、可l护性、组件可重用性及开发效率。项目越复杂Q项目队伍越庞大则越能体现良好设计的重要性?BR>转蝲自:<A >http://blog.csdn.net/laou2008/archive/2005/11/15/529519.aspx</A><BR><BR>襉K子的一道笔试题<BR><BR>设计一个函敎ͼ形式? int func(unsigned int)Q要求求Z大于输入参数的最大的素数Q比如输?2Q返?1?BR><BR>转蝲自:<A >http://community.csdn.net/Expert/topic/4368/4368551.xml?temp=.4177057</A><BR><BR>微YMSN在南大的W试?BR><BR>|马数字共有七个Q即 <BR>I(1)QV(5)QX(10)QL(50)QC(100)QD(500)QM(1000)?</P> <P>按照下面三条规则可以表示L正整数?</P> <P>重复数次Q一个罗马数字重复几ơ,pC个数的几倍?</P> <P>叛_左减Q在一个较大的|马数字的右边记上一个较的|马数字Q?<BR>表示大数字加数字。在一个较大的数字的左边记上一个较的|?<BR>马数字,表示大数字减数字。但是,左减不能跨越{?<BR>比如Q?9不可以用IC表示Q用XCIX表示</P> <P>基本数字Ⅰ、X 、C 中的M一?自nq用构成数目,或者放在大数的双q用构成数目,都不能超q三?比如40不能用XXXX,而用XL表示</P> <P>设计一个函??00(包括100)以内的整数{换成|马数字,过100不考虑<BR>int itor(int n,char* buf,int bufLength)<BR>其中,n是要转换的整?buf是要输出的字W串,bufLength是buf的字W长?BR>成功,q回0,否则,q回 -1;</P> <P>比如:<BR>char buf[256];<BR>result = itor(n,buf,sizeof(buf));</P> <P>when n = 28; result = 0, 输出"XXVIII"Q?BR>when n = 72; result = 0, 输出"LXXII";<BR><BR>转蝲自:<A >http://community.csdn.net/Expert/topic/4386/4386877.xml?temp=.411175</A><BR><BR><BR><BR><BR><BR></P><img src ="http://www.tkk7.com/freddychu/aggbug/20003.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/freddychu/" target="_blank">风萧?/a> 2005-11-16 09:59 <a href="http://www.tkk7.com/freddychu/archive/2005/11/16/20003.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转蝲QGoogle文gpȝhttp://www.tkk7.com/freddychu/archive/2005/11/09/18892.html风萧?/dc:creator>风萧?/author>Wed, 09 Nov 2005 01:29:00 GMThttp://www.tkk7.com/freddychu/archive/2005/11/09/18892.htmlhttp://www.tkk7.com/freddychu/comments/18892.htmlhttp://www.tkk7.com/freddychu/archive/2005/11/09/18892.html#Feedback0http://www.tkk7.com/freddychu/comments/commentRss/18892.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/18892.htmlGFS是一个可扩展的分布式文gpȝQ用于大型的、分布式的、对大量数据q行讉K的应用。它q行于廉L普通硬件上Q但可以提供定w功能。它可以l大量的用户提供M性能较高的服务?
1、设计概?
Q?Q设计想?
GFS与过ȝ分布式文件系l有很多相同的目标,但GFS的设计受C当前及预期的应用斚w的工作量及技术环境的驱动Q这反映了它与早期的文gpȝ明显不同的设惟뀂这需要对传统的选择q行重新验ƈq行完全不同的设计观点的探烦?
GFS与以往的文件系l的不同的观点如下:
1、部仉误不再被当作异常Q而是其作ؓ常见的情况加以处理。因为文件系l由成百上千个用于存储的机器构成Q而这些机器是由廉L普通部件组成ƈ被大量的客户问。部件的数量和质量得一些机器随旉有可能无法工作ƈ且有一部分q可能无法恢复。所以实时地监控、错误检、容错、自动恢复对pȝ来说必不可少?
2、按照传l的标准Q文仉非常大。长度达几个GB的文件是很^常的。每个文仉常包含很多应用对象。当l常要处理快速增长的、包含数以万计的对象、长度达TB的数据集Ӟ我们很难理成千上万的KB规模的文件块Q即使底层文件系l提供支持。因此,设计中操作的参数、块的大必要重新考虑。对大型的文件的理一定要能做到高效,对小型的文g也必L持,但不必优化?
3、大部分文g的更新是通过d新数据完成的Q而不是改变已存在的数据。在一个文件中随机的操作在实践中几乎不存在。一旦写完,文g只可读Q很多数据都有这些特性。一些数据可能组成一个大仓库以供数据分析E序扫描。有些是q行中的E序q箋产生的数据流。有些是档案性质的数据,有些是在某个机器上生、在另外一个机器上处理的中间数据。由于这些对大型文g的访问方式,d操作成ؓ性能优化和原子性保证的焦点。而在客户Z~存数据块则失去了吸引力?
4、工作量主要׃U读操作构成Q对大量数据的流方式的读操作和对量数据的随机方式的L作。在前一U读操作中,可能要读几百KBQ通常?1MB和更多。来自同一个客Lq箋操作通常会读文g的一个连l的区域。随机的L作通常在一个随机的偏移处读几个KB。性能敏感的应用程序通常对量数据的读操作q行分类q进行批处理以得读操作E_地向前推q,而不要让它来来回回的诅R?
5、工作量q包含许多对大量数据q行的、连l的、向文gd数据的写操作。所写的数据的规模和ȝ伹{一旦写完,文g很少改动。在随机位置对少量数据的写操作也支持Q但不必非常高效?
6、系l必高效地实现定义完好的大量客户同时向同一个文件的d操作的语义?
Q?Q系l接?
GFS提供了一个相似地文gpȝ界面Q虽然它没有向POSIX那样实现标准的API。文件在目录中按层次l织hq由路径名标识?
Q?Q体pȝ构:
一个GFS集群׃个master和大量的chunkserver构成Qƈ被许多客PClientQ访问。如?所C。Master?chunkserver通常是运行用户层服务q程的Linux机器。只要资源和可靠性允许,chunkserver和client可以q行在同一个机器上?
文g被分成固定大的块。每个块׃个不变的、全局唯一?4位的chunkQhandle标识QchunkQhandle是在块创建时?master分配的。ChunkServer块当作Linux文g存储在本地磁盘ƈ可以d写由chunkQhandle和位区间指定的数据。出于可靠性考虑Q每一个块被复制到多个chunkserver上。默认情况下Q保?个副本,但这可以qh定?
Masterl护文gpȝ所以的元数据(metadataQ,包括名字I间、访问控制信息、从文g到块的映以及块的当前位|。它也控制系l范围的zdQ如块租U(leaseQ管理,孤儿块的垃圾攉Qchunkserver间的块迁URMaster定期通过HeartBeat消息与每一?chunkserver通信Q给chunkserver传递指令ƈ攉它的状态?
与每个应用相联的GFS客户代码实现了文件系l的APIq与master和chunkserver通信以代表应用程序读和写数据。客户与master的交换只限于对元数据QmetadataQ的操作Q所有数据方面的通信都直接和chunkserver联系?
客户和chunkserver都不~存文g数据。因为用L存的益处微乎其微Q这是由于数据太多或工作集太大而无法缓存。不~存数据化了客户E序和整个系l,因ؓ不必考虑~存的一致性问题。但用户~存元数据(metadataQ。Chunkserver也不必缓存文Ӟ因ؓ块时作ؓ本地文g存储的?
Q?Q单master?
只有一个master也极大的化了设计q得master可以Ҏ全局情况作出先进的块攄和复制决定。但是我们必要master对读和写的参与减x,q样它才不会成ؓpȝ的瓶颈。Client从来不会从masterd写文件数据。Client只是询问master它应该和哪个 chunkserver联系。Client在一D限定的旉内将q些信息~存Q在后箋的操作中Client直接和chunkserver交互?
以图1解释一下一个简单的L作的交互?
1、client使用固定的块大小应用程序指定的文g名和字节偏移转换成文件的一个块索引Qchunk indexQ?
2、给master发送一个包含文件名和块索引的请求?
3、master回应对应的chunk handle和副本的位置Q多个副本)?
4、client以文件名和块索引为键~存q些信息。(handle和副本的位置Q?
5、Client 向其中一个副本发送一个请求,很可能是最q的一个副本。请求指定了chunk handleQchunkserver以chunk handle标识chunkQ和块内的一个字节区间?
6、除非缓存的信息不再有效Qcache for a limited timeQ或文g被重新打开Q否则以后对同一个块的读操作不再需要client和master间的交互?
通常Client可以在一个请求中询问多个chunk的地址Q而master也可以很快回应这些请求?
Q?Q块规模Q?
块规模是设计中的一个关键参数。我们选择的是64MBQ这比一般的文gpȝ的块规模要大的多。每个块的副本作Z个普通的Linux文g存储Q在需要的时候可以扩展?
块规模较大的好处有:
1、减client和master之间的交互。因写同一个块只是要在开始时向masterh块位|信息。对于读写大型文件这U减尤为重要。即使对于访问少量数据的随机L作也可以很方便的Z个规模达几个TB的工作集~缓存块位置信息?
2、Client在一个给定的块上很可能执行多个操作,和一个chunkserver保持较长旉的TCPq接可以减少|络负蝲?
3、这减少了master上保存的元数据(metadataQ的规模Q从而得可以将metadata攑֜内存中。这又会带来一些别的好处?
不利的一面:
一个小文g可能只包含一个块Q如果很多Client讉KҎ件的话,存储q些块的chunkserver成问的热点。但在实际应用中Q应用程序通常序地读包含多个块的文gQ所以这不是一个主要问题?
Q?Q元数据QmetadataQ:
master存储了三中类型的metadataQ文件的名字I间和块的名字空_从文件到块的映射Q块的副本的位置。所有的metadata都放在内存中。前两种cd的metadata通过向操作日志登C改而保持不变,操作日志存储在master的本地磁盘ƈ在几个远E机器上留有副本。用日志得我们可以很单地、可靠地更新master的状态,即在master崩溃的情况下也不会有不一致的问题。相反,mater在每ơ启动以及当?chuankserver加入的时候询问每个chunkserver的所拥有的块的情c?
A、内存数据结构:
因ؓmetadata存储在内存中Q所以master的操作很快。进一步,master可以L而且高效地定期在后台扫描它的整个状态。这U定期地扫描被用于实现块垃圾攉、chunkserver出现故障时的副本复制、ؓq负蝲和磁盘空间而进行的块迁UR?
q种Ҏ的一个潜在的问题是块的数量也即整个pȝ的容量是否受限与master的内存。实际上Q这q不是一个严重的问题。Master为每?64MB的块l护的metadata不64个字节。除了最后一块,文g所有的块都是满的。类似的Q每个文件的名字I间数据也不?4个字节,因ؓ文g名是以一U事先确定的压羃方式存储?如果要支持更大的文gpȝQ那么增加一些内存的Ҏ对于我们元数据QmetadataQ保存在内存U所获得的简单性、可靠性、高性能和灵zL来_q只是一个很的代h?
B、块位置Q?
masterq不为chunkserver所拥有的块的副本的保存一个不变的记录。它在启动时通过单的查询来获得这些信息。Master可以保持q些信息的更斎ͼ因ؓ它控制所有块的放|ƈ通过HeartBeat消息来监控chunkserver的状态?
q样做的好处Q因为chunkserver可能加入或离开集群、改变\径名、崩溃、重启等Q一个集重有成百个serverQ这些事件经常发生,q种Ҏ排除了master与chunkserver之间的同步问题?
另一个原因是Q只有chunkserver才能定它自己到底有哪些块,׃错误Qchunkserver中的一些块可能会很自然的消失,q样在master中就没有必要为此保存一个不变的记录?
C、操作日志:
操作日志包含了对metadata所作的修改的历史记录。它作ؓ逻辑旉U定义了q发操作的执行顺序。文件、块以及它们的版本号都由它们被创建时的逻辑旉而唯一地、永久地被标识?
操作日志是如此的重要Q我们必要它可靠C存v来,q且只有在metadata的改变固定下来之后才变化呈现给用户。所以我们将操作日志复制到数个远E的机器上,q且只有在将相应的日志记录写到本地和q程的磁盘上之后才回{用Lh?
Master可以用操作日志来恢复它的文gpȝ的状态。ؓ了将启动旉减至最,日志必要比较。每当日志的长度增长到超q一定的规模后,masterp查它的状态,它可以从本地盘装入最q的查点来恢复状态?
创徏一个检查点比较ҎQmaster的内部状态是以一U在创徏一个检查点时ƈ不耽误卛_到来的修Ҏ作的方式来组l的。Master切换C个新的日子文件ƈ在一个单独的U程中创建检查点。这个新的检查点记录了切换前所有的修改。在一个有数十万文件的集群中用一分钟左右p完成。创建完后,它写入本地和远E的盘?
Q?Q数据完整?
名字I间的修改必L原子性的Q它们只能有master处理Q名字空间锁保证了操作的原子性和正确性,而master的操作日志在全局范围内定义了q些操作的顺序?
文g区间的状态在修改之后依赖于修改的cdQ不论操作成功还是失败,也不论是不是q发操作。如果不Z哪个副本上读Q所有的客户都看到同L数据Q那么文件的q个区域是一致的。如果文件的区域是一致的q且用户可以看到修改操作所写的数据Q那么它是已定义的。如果修Ҏ在没有ƈ发写操作的媄响下完成的,那么受媄响的区域是已定义的,所有的client都能看到写的内容。成功的q发写操作是未定义但却是一致的。失败的修改区间处于不一致的状态?
Write操作在应用程序指定的偏移处写入数据,而record append操作使得数据Q记录)即在有q发修改操作的情况下也至原子性的被加到GFS指定的偏UdQ偏Ud址被返回给用户?
在一pd成功的修Ҏ作后Q最后的修改操作保证文g区域是已定义的。GFS通过Ҏ有的副本执行同样序的修Ҏ作ƈ且用块版本h过时的副本Q由于chunkserver退导致丢׃改)来做到这一炏V?
因ؓ用户~存了会位置信息Q所以在更新~存之前有可能从一个过时的副本中读取数据。但q有~存的截止时间和文g的重新打开而受到限制?
在修Ҏ作成功后Q部件故障仍可以是数据受到破坏。GFS通过master和chunkserver间定期的handshakeQ借助校验和来对数据的破坏。一旦检到Q就从一个有效的副本快重新存储。只有在GFS前Q所有的副本都失效,q个块才会丢失?
2、系l交?
Q?Q租U(leaseQ和修改序Q?
Q?Q数据流
我们的目标是充分利用每个机器的网l带宽,避免|络瓉和gq?
Z有效的利用网l,我们数据流和控制流分离。数据是以流水线的方式在选定的chunkerserver链上U性的传递的。每个机器的整个对外带宽都被用作传递数据。ؓ避免瓉Q每个机器在收到数据后,它收到数据快传递给d最q的机器?
Q?Q原子性的record AppendQ?
GFS提供了一个原子性的d操作Qrecord append。在传统的写操作中,client指定被写数据的偏UM|,向同一个区间的q发的写操作是不q箋的:区间有可能包含来自多个client的数据碎片。在record append中, client只是指定数据。GFS在其选定的偏Ud数据至原子性的加入文g一ơ,q将偏移q回lclient?
在分布式的应用中Q不同机器上的许多client可能会同时向一个文件执行添加操作,d操作被频J用。如果用传统的write操作Q可能需要额外的、复杂的、开销较大的同步,例如通过分布式锁理。在我们的工作量中,q些文g通常以多个生产者单个消费者队列的方式或包含从多个不同 client的综合结果?
Record append和前面讲的write操作的控制流差不多,只是在primary上多了一些逻辑判断。首先,client数据发送到文g最后一块的所有副本上。然后向primary发送请求。Primary查添加操作是否会D该块过最大的规模Q?4MQ。如果这P它将该块扩充到最大规模,q告诉其它副本做同样的事Q同旉知client该操作需要在下一个块上重新尝试。如果记录满x大规模的要求Qprimary׃数据添加到它的副本上,q告诉其它的副本在在同样的偏Ud写数据,最后primary向client报告写操作成功。如果在M一个副本上record append操作p|Qclient重新尝试该操作。这时候,同一个块的副本可能包含不同的数据Q因为有的可能复制了全部的数据,有的可能只复制了部分。GFS不能保证所有的副本每个字节都是一L。它只保证每个数据作Z个原子单元被写过臛_一ơ。这个是q样得出的:操作要是成功Q数据必d所有的副本上的同样的偏Ud被写q。进一步,从这以后Q所有的副本臛_和记录一样长Q所以后l的记录被指定到更高的偏移处或者一个不同的块上Q即使另一个副本成了primary。根据一致性保证,成功的record append操作的区间是已定义的。而受到干扰的区间是不一致的?
Q?Q快照(snapshotQ?
快照操作几乎在瞬间构造一个文件和目录树的副本Q同时将正在q行的其他修Ҏ作对它的影响减至最?
我们使用copy-on-write技术来实现snapshot。当master受到一个snapshothӞ它首先将要snapshot的文件上块上的lease。这使得M一个向q些块写数据的操作都必须和master交互以找到拥有lease的副本。这qmaster一个创个块的副本的Z?
副本被撤销或终止后Qmaster在磁盘上登记执行的操作,然后复制源文件或目录树的metadata以对它的内存状态实施登记的操作。这个新创徏的snapshot文g和源文gQ其metadataQ指向相同的块(chunkQ?
Snapshot之后Q客L一ơ向chunk c写的时候,它发一个请求给master以找到拥有lease的副本。Master注意到chunk c的引用记数比1大,它gq对用户的响应,选择一个chunk handle C?然后要求每一有chunk c的副本的chunkserver创徏一个块C’。每个chunkserver在本地创建chunk C’避免了|络开销。从q以后和对别的块的操作没有什么区别?
3、MASTER操作
MASTER执行所有名字空间的操作Q除此之外,他还在系l范围管理数据块的复Ӟ军_数据块的攄ҎQ生新数据块ƈ其备䆾Q和其他pȝ范围的操作协同来保数据备䆾的完整性,在所有的数据块服务器之间q负蝲q收回没有用的存储I间?
3.1 名字I间理和加?
与传l文件系l不同的是,GFS没有与每个目录相关的能列出其所有文件的数据l构Q它也不支持别名Qunix中的连接或W号q接Q,不管是对文g或是目录。GFS的名字空间逻辑上是从文件元数据到\径名映射的一个查用表?
MASTER在执行某个操作前都要获得一pd锁,例如Q它要对/d1/d2?dn/leaf执行操作Q则它必获?d1Q?d1/d2Q…, /d1/d2/?dn的读锁,/d1/d2?dn/leaf的读锁或写锁Q其中leaf可以使文件也可以是目录)。MASTER操作的ƈ行性和数据的一致性就是通过q些锁来实现的?
3.2 备䆾存储攄{略
一个GFS集群文gpȝ可能是多层分布的。一般情况下是成千上万个文g块服务器分布于不同的机架上,而这些文件块服务器又被分布于不同机架上的客户来访问。因此,不同机架上的两台机器之间的通信可能通过一个或多个交换机。数据块冗余配置{略要达到连个目的:最大的数据可靠性和可用性,最大的|络带宽利用率。因此,如果仅仅把数据的拯|于不同的机器上很难满q两个要求,必须在不同的机架上进行数据备份。这样即使整个机架被毁或是掉U,也能保数据的正怋用。这也数据传输Q尤其是L据,可以充分利用带宽Q访问到多个机架Q而写操作Q则不得不涉及到更多的机架?
3.3 产生、重复制、重q数据?
当MASTER产生新的数据块时Q如何放|新数据块,要考虑如下几个因素Q(1Q尽量放|在盘利用率低的数据块服务器上Q这P慢慢地各服务器的盘利用率就会达到^衡。(2Q尽量控制在一个服务器上的“新创徏”的ơ数。(3Q由于上一节讨论的原因,我们需要把数据块放|于不同的机架上?
MASTER在可用的数据块备份低于用戯定的数目旉要进行重复制。这U情冉|于多U原因:服务器不可用Q数据被破坏Q磁盘被破坏Q或者备份数目被修改。每个被需要重复制的数据块的优先Ҏ以下几项定Q第一是现在的数目距目标的距离Q对于能d用户E序的数据块Q我们也提高它的优先U。最后, MASTER按照产生数据块的原则复制数据块,q把它们攑ֈ不同的机架内的服务器上?
MASTER周期性的q各服务器上的负蝲Q它查chunk分布和负载^衡,通过q种方式来填充一个新的服务器而不是把其他的内容统l放|到它上面带来大量的写数据。数据块攄的原则与上面讨论的相同,此外QMASTERq决定那些数据块要被U除Q原则上他会清除那些I闲I间低于q_值的那些服务器?
3.4 垃圾攉
在一个文件被删除之后QGFSq不立即收回盘I间Q而是{到垃圾攉E序在文件和数据块的的查中收回?
当一个文件被应用E序删除之后QMASTER会立卌录下q些变化Q但文g所占用的资源却不会被立x回,而是重新l文件命了一个隐藏的名字Qƈ附上了删除的旉戟뀂在MASTER定期查名字空间时Q它删除过三天Q可以设定)的隐藏的文g。在此之前,可以以一个新的名字来LӞq可以以前的名字恢复。当隐藏的文件在名字I间中被删除以后Q它在内存中的元数据卌擦除Q这有效地切断了他和所有数据块的联pR?
在一个相似的定期的名字空间检查中QMASTER认孤儿数据块(不属于Q何文Ӟq擦除他的元数据Q在和MASTER的心跳信息交换中Q每个服务器报告他所拥有的数据块QMASTERq回元数据不在内存的数据块,服务器即可以删除q些数据块?
3.5 q时数据的探?
在数据更新时如果服务器停ZQ那么他所保存的数据备份就会过时。对每个数据块,MASTER讄了一个版本号来区别更新过的数据块和过时的数据块?
当MASTER授权一个新的leaseӞ他会增加数据块的版本号ƈ会通知更新数据备䆾。MASTER和备份都会记录下当前的版本号Q如果一个备份当时不可用Q那么他的版本号不可能提高,当ChunkServer重新启动q向MASTER报告他的数据块集ӞMASTER׃发现q时的数据?
MASTER在定期的垃圾攉E序中清除过时的备䆾Q在此以前,处于效率考虑Q在各客户及英大使,他会认ؓҎ不存在过时的数据。作为另一个安全措施, MASTER在给客户及关于数据块的应{或是另外一个读取数据的服务器数据是都会带上版本信息Q在操作前客h和服务器会验证版本信息以保得到的是最新的数据?
4、容错和诊断
4.1 高可靠?
4.1.1 快速恢?
不管如何l止服务QMASTER和数据块服务器都会在几秒钟内恢复状态和q行。实际上Q我们不Ҏ常终止和不正常终止进行区分,服务器进E都会被切断而终止。客h和其他的服务器会l历一个小的中断Q然后它们的特定h时Q重新连接重启的服务器,重新h?
4.1.2 数据块备?
如上文所讨论的,每个数据块都会被备䆾到放C同机架上的不同服务器上。对不同的名字空_用户可以讄不同的备份别。在数据块服务器掉线或是数据被破坏时QMASTER会按照需要来复制数据块?
4.1.3 MASTER备䆾
为确保可靠性,MASTER的状态、操作记录和查点都在多台机器上进行了备䆾。一个操作只有在数据块服务器盘上刷新ƈ被记录在MASTER和其备䆾的上之后才算是成功的。如果MASTER或是盘p|Q系l监视器会发现ƈ通过改变域名启动它的一个备份机Q而客h则仅仅是使用规范的名U来讉KQƈ不会发现MASTER的改变?
4.2 数据完整?
每个数据块服务器都利用校验和来检验存储数据的完整性。原因:每个服务器随旉有发生崩溃的可能性,q且在两个服务器间比较数据块也是不现实的Q同Ӟ在两台服务器间拷贝数据ƈ不能保证数据的一致性?
每个Chunk?4kB的大分成块Q每个块?2位的校验和,校验和和日志存储在一P和用h据分开?
在读数据Ӟ服务器首先检查与被读内容相关部分的校验和Q因此,服务器不会传播错误的数据。如果所查的内容和校验和不符Q服务器׃l数据请求者返回一个错误的信息Qƈ把这个情冉|告给MASTER。客h׃d他的服务器来获取数据Q而MASTER则会从其他的拯来复制数据,{到一个新的拷贝完成时QMASTER׃通知报告错误的服务器删除出错的数据块?
附加写数据时的校验和计算优化了,因ؓq是主要的写操作。我们只是更新增加部分的校验和,即末尾部分的校验和数据已被损坏而我们没有检查出来,新的校验和与数据会不相符Q这U冲H在下次使用时将会被查出来?
相反Q如果是覆盖现有数据的写Q在写以前,我们必须查第一和最后一个数据块Q然后才能执行写操作Q最后计和记录校验和。如果我们在覆盖以前不先查首位数据块Q计出的校验和则会因ؓ没被覆盖的数据而生错误?
在空闲时_服务器会查不z跃的数据块的校验和Q这样可以检查出不经常读的数据的错误。一旦错误被查出来,服务器会拯一个正的数据块来代替错误的?
4.3 诊断工具
q泛而细致的诊断日志以微的代h换取了在问题隔离、诊断、性能分析斚w起到了重大的作用。GFS服务器用日志来记录显著的事gQ例如服务器停机和启动)和远E的应答。远E日志记录机器之间的h和应{,通过攉不同机器上的日志记录Qƈ对它们进行分析恢复,我们可以完整地重现活动的场景Qƈ用此来进行错误分析?
6 量
6.1 试环境
一C控机Q两C控机备䆾Q?6台数据块服务器,16台客h?
每台机器Q?块PIII1.4G处理器,2G内存Q??0G5400rpm的硬盘,1?00Mbps全双工网?
19台服务器q接C个HP2524交换ZQ?6台客h俩接到领外一C换机上,两台交换机通过1G的链路相q?BR>

Google 2003q关于Google File System的论?/A>

原文出处Q?A >http://www.irunnet.com/viewtopic.php?p=913&sid=4f05f5b8a26e7d0b0e2586190c175d0b#913


]]>
破解Confluence http://www.tkk7.com/freddychu/archive/2005/11/08/18756.html风萧?/dc:creator>风萧?/author>Tue, 08 Nov 2005 05:37:00 GMThttp://www.tkk7.com/freddychu/archive/2005/11/08/18756.htmlhttp://www.tkk7.com/freddychu/comments/18756.htmlhttp://www.tkk7.com/freddychu/archive/2005/11/08/18756.html#Feedback0http://www.tkk7.com/freddychu/comments/commentRss/18756.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/18756.html下蝲Q?A >http://www.atlassian.com/software/confluence/

破解和jira一栗参考我的另外一随W:《破解JIRA?/A>?img src ="http://www.tkk7.com/freddychu/aggbug/18756.html" width = "1" height = "1" />

]]>
【{载】google ?1道面试问?http://www.tkk7.com/freddychu/archive/2005/11/07/18526.html风萧?/dc:creator>风萧?/author>Mon, 07 Nov 2005 01:36:00 GMThttp://www.tkk7.com/freddychu/archive/2005/11/07/18526.htmlhttp://www.tkk7.com/freddychu/comments/18526.htmlhttp://www.tkk7.com/freddychu/archive/2005/11/07/18526.html#Feedback2http://www.tkk7.com/freddychu/comments/commentRss/18526.htmlhttp://www.tkk7.com/freddychu/services/trackbacks/18526.html转自Q?/FONT>http://www.softboss.com

      10月底QGoogle在美国《麻省技术评论》、《LinuxJournal》、《Mensa》、《今日物理》等几本专业杂志上,刊登了一份“Google实验室能力們֐试”?BR>  试卷开_蛊惑地写着“试试看Q把{案寄回GoogleQ你有希望去Google总部参观Qƈ成ؓ我们其中一员”?/FONT>

我看了这些题目,虽然古怪,但是也不有困难Q有兴趣的h可以做完了邮寄给google公司Q也怼得到一个工作机会呢?/FONT>

注:不要向我要答案?/FONT>

1. Solve this cryptic equation, realizing of
course that values for M and E could be
interchanged. No leading zeros are allowed.

WWWDOT - GOOGLE = DOTCOM

2. Write a haiku describing possible methods
for predicting search traffic seasonality.

3.
1
1 1
2 1
1 2 1 1
1 1 1 2 2 1

What is the next line?

4. You are in a maze of twisty little passages,
all alike. There is a dusty laptop here with a
weak wireless connection. There are dull,
lifeless gnomes strolling about. What dost
thou do?

A) Wander aimlessly, bumping into
obstacles until you are eaten by a grue.
B) Use the laptop as a digging device to
tunnel to the next level.
C) Play MPoRPG until the battery dies
along with your hopes.
D) Use the computer to map the nodes
of the maze and discover an exit path.
E) Email your resume to Google, tell the
lead gnome you quit and find yourself
in whole different world.

5. What's broken with Unix?
How would you fix it?

6. On your first day at Google, you discover
that your cubicle mate wrote the textbook
you used as a primary resource in your first
year of graduate school. Do you:

A) Fawn obsequiously and ask if you
can have an autograph.
B) Sit perfectly still and use only soft
keystrokes to avoid disturbing her
concentration.
C) Leave her daily offerings of granola
and English toffee from the food bins.

D) Quote your favorite formula from the
textbook and explain how it's now
your mantra.
E) Show her how example 17b could
have been solved with 34 fewer lines
of code.
7. Which of the following expresses Google?
over-arching philosophy?

A) "I'm feeling lucky"
B) "Don't be evil"
C) "Oh, I already fixed that"
D) "You should never be more than
50 feet from food"
E) All of the above

8. How many different ways can you color an
icosahedron with one of three colors on
each face?

What colors would you choose?

9. This space left intentionally blank. Please fill it
with something that improves upon emptiness.

10.On an infinite, two-dimensional, rectangular
lattice of 1-ohm resistors, what is the
resistance between two nodes that are a
knight's move away?

11.It's 2 PM on a sunny Sunday afternoon in the
Bay Area. You're minutes from the Pacific
Ocean, redwood forest hiking trails and world
class cultural attractions. What do you do?

12.In your opinion, what is the most beautiful
math equation ever derived?

13. Which of the following is NOT an actual
interest group formed by Google employees?

A. Women's basketball
B. Buffy fans
C. Cricketeers
D. Nobel winners
E. Wine club

14.What will be the next great improvement in
search technology?

15.What is the optimal size of a project team,
above which additional members do not
contribute productivity equivalent to the
percentage increase in the staff size?
A) 1
B) 3
C) 5
D) 11
E) 24

16.Given a triangle ABC, how would you use only
a compass and straight edge to find a point P
such that triangles ABP, ACP and BCP have
equal perimeters? (Assume that ABC is
constructed so that a solution does exist.)

17.Consider a function which, for a given whole
number n, returns the number of ones required
when writing out all numbers between 0 and n.
For example, f(13)=6. Notice that f(1)=1. What
is the next largest n such that f(n)=n?

18.What's the coolest hack you've ever written?

19.'Tis known in refined company, that choosing
K things out of N can be done in ways as
many as choosing N minus K from N: I pick K,
you the remaining.

Find though a cooler bijection, where you show
a knack uncanny, of making your choices contain
all K of mine. Oh, for pedantry: let K be no more
than half N.

20.What number comes next in the sequence:
10, 9, 60, 90, 70, 66,?

A)96
B) 1000000000000000000000000000000000
0000000000000000000000000000000000
000000000000000000000000000000000
C) Either of the above
D) None of the above

21.In 29 words or fewer, describe what you
would strive to accomplish if you worked
at Google Labs.



]]>
վ֩ģ壺 ҹƷþþþ | պݺݾþ͵͵ɫۺ | ɫַ| 91鶹Բ߹ۿ| 99߹ۿƵ| Ļ| ޾ƷAAƬ߹ۿ | л| vvaþ| þþƷӰѶ| Ʒ޵һ| պŷcom91tv| 97޳ | 4444޹˾Ʒ| avֻ߹ۿ| ĻӰȫѰ| ۹һ| þþþAVƬ| va˳Ƶվȫ| Ʒ鶹ѹۿ| һŮëƬ| þ޾Ʒϵַ | www.avѹۿ| һƷ| ۺɫӰ| ˰ձƵ| 91ѹԲַ| ѨƬ߹ۿ| avɫ㽶һ| ۺ߳һ| 뾫Ʒ| | պһ| 97Ƶ| 鵺̳Ƶ| ŷһ| һ| ޹AVרAV| AV߹ۿ| ѹۿ+ձ| վ߹ۿ|