??xml version="1.0" encoding="utf-8" standalone="yes"?>精品视频在线观看,四虎8848精品成人免费网站,日韩视频一区二区三区四区http://www.aygfsteel.com/csusky/zh-cnThu, 03 Jul 2025 08:04:04 GMTThu, 03 Jul 2025 08:04:04 GMT60异步IO的关闭事?/title><link>http://www.aygfsteel.com/csusky/archive/2009/11/10/301900.html</link><dc:creator>晓宇</dc:creator><author>晓宇</author><pubDate>Tue, 10 Nov 2009 14:28:00 GMT</pubDate><guid>http://www.aygfsteel.com/csusky/archive/2009/11/10/301900.html</guid><wfw:comment>http://www.aygfsteel.com/csusky/comments/301900.html</wfw:comment><comments>http://www.aygfsteel.com/csusky/archive/2009/11/10/301900.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/csusky/comments/commentRss/301900.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/csusky/services/trackbacks/301900.html</trackback:ping><description><![CDATA[<p>JAVA SOCKET只定义了(jin)四种事g<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"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><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">final</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> OP_READ </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></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">final</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> OP_WRITE </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">2</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></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">final</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> OP_CONNECT </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">3</span><span style="color: #000000">;<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></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">final</span><span style="color: #000000"> </span><span style="color: #0000ff">int</span><span style="color: #000000"> OP_ACCEPT </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">4</span><span style="color: #000000">;</span></div> <br /> 是没有关闭事件的Q我们怎么判断一个连接是否关闭呢Q?br /> 如果你的selector注册?jin)一个OP_READ事gQ那么在q接关闭的时候将?x)生一个OP_READ事g<br /> 也就是说本来d的selector此时会(x)被唤醒,但是如果试图在此事g的通道中读取数据将?x)返?1<br /> 如下Q?br /> <br /> <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"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #000000">Set</span><span style="color: #000000"><</span><span style="color: #000000">SelectionKey</span><span style="color: #000000">></span><span style="color: #000000"> readyKeys </span><span style="color: #000000">=</span><span style="color: #000000"> selector.selectedKeys();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" />i </span><span style="color: #000000">=</span><span style="color: #000000"> readyKeys.iterator()<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" />SelectionKey key </span><span style="color: #000000">=</span><span style="color: #000000"> (SelectionKey)i.next();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">if</span><span style="color: #000000"> (operation </span><span style="color: #000000">==</span><span style="color: #000000"> SelectionKey.OP_READ </span><span style="color: #000000">&&</span><span style="color: #000000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" />                         key.isReadable())<br /> <img id="Codehighlighter1_226_377_Open_Image" onclick="this.style.display='none'; Codehighlighter1_226_377_Open_Text.style.display='none'; Codehighlighter1_226_377_Closed_Image.style.display='inline'; Codehighlighter1_226_377_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_226_377_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_226_377_Closed_Text.style.display='none'; Codehighlighter1_226_377_Open_Image.style.display='inline'; Codehighlighter1_226_377_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" />                </span><span id="Codehighlighter1_226_377_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.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_226_377_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                    ReadableByteChannel incomingChannel </span><span style="color: #000000">=</span><span style="color: #000000"> (ReadableByteChannel)key.channel(); <br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /></span><span style="color: #008000">//</span><span style="color: #008000">此时会(x)得到-1Q表明该链接已关?/span><span style="color: #008000"><br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">int</span><span style="color: #000000"> n </span><span style="color: #000000">=</span><span style="color: #000000"> incomingChannel.read(readBuffer);<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span></div> 此时我们需要取消该KEY 如下Q?br /> <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"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">if</span><span style="color: #000000"> (n </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #000000">-</span><span style="color: #000000">1</span><span style="color: #000000">)<br /> <img id="Codehighlighter1_25_133_Open_Image" onclick="this.style.display='none'; Codehighlighter1_25_133_Open_Text.style.display='none'; Codehighlighter1_25_133_Closed_Image.style.display='inline'; Codehighlighter1_25_133_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" alt="" /><img id="Codehighlighter1_25_133_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_25_133_Closed_Text.style.display='none'; Codehighlighter1_25_133_Open_Image.style.display='inline'; Codehighlighter1_25_133_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align="top" alt="" />            </span><span id="Codehighlighter1_25_133_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.aygfsteel.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_25_133_Open_Text"><span style="color: #000000">{<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align="top" alt="" />                key.cancel();<br />                   //关闭输入输出 <br />                   sc.socket().shutdownOutput();<br />                   sc.socket().shutdownInput();<br />                    //关闭SOCKET<br />                    sc.socket().close();<br /> </span><span style="color: #000000">                  //关闭通道<br />                    incomingChannel.close();<br /> <img src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />            }</span></span></div> <br /> <img src ="http://www.aygfsteel.com/csusky/aggbug/301900.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/csusky/" target="_blank">晓宇</a> 2009-11-10 22:28 <a href="http://www.aygfsteel.com/csusky/archive/2009/11/10/301900.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ExecutorFilterhttp://www.aygfsteel.com/csusky/archive/2008/12/12/245891.html晓宇晓宇Fri, 12 Dec 2008 03:33:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/12/12/245891.htmlhttp://www.aygfsteel.com/csusky/comments/245891.htmlhttp://www.aygfsteel.com/csusky/archive/2008/12/12/245891.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/245891.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/245891.html
ExecutorService executor = Executors.newCachedThreadPool();

Ҏ(gu) newCachedThreadPool();
创徏一个可Ҏ(gu)需要创建新U程的线E池Q但是在以前构造的U程可用时将重用它们Qƈ在需要时使用提供?ThreadFactory 创徏新线E?
2. 用构造的U程池创建ExecutorFilter
ExecutorFilter es= new ExecutorFilter(executor));

在ExecutorFilter内部:
只需要将相应的事件分发到到线E池的相应线E即可,但是SessionCreated事g只能在主U程中,不能分发
触发Ҏ(gu)
1 .
首先构造一个IoFilterEventQ这个IoFilterEvent包含1、事件的cdQ?、下一个过滤器
然后触发该时间的处理Ҏ(gu)?br />
 if (eventTypes.contains(IoEventType.SESSION_OPENED)) {
            fireEvent(
new IoFilterEvent(nextFilter, IoEventType.SESSION_OPENED,
                    session, 
null));
        }

2 .
从线E池中取Z个线E执行事件处?br />
protected void fireEvent(IoFilterEvent event) {
        getExecutor().execute(event);
    }


在构造ExecutorFilter 时如果没有传入IoEventType则默认只对如下几U几件感兴趣
EXCEPTION_CAUGHT
MESSAGE_RECEIVED
MESSAGE_SENT
SESSION_CLOSED
SESSION_IDLE
SESSION_OPENED
当然q需要覆盖相应的事g处理Ҏ(gu) 如上所C?

晓宇 2008-12-12 11:33 发表评论
]]>
ORACLE的块大小http://www.aygfsteel.com/csusky/archive/2008/11/25/242570.html晓宇晓宇Tue, 25 Nov 2008 07:45:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/11/25/242570.htmlhttp://www.aygfsteel.com/csusky/comments/242570.htmlhttp://www.aygfsteel.com/csusky/archive/2008/11/25/242570.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/242570.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/242570.html参数db_block_sizeQ?br /> q个参数只能讄成底层操作系l物理块大小的整数倍,最好是2的nơ方倍?br /> 如WINDOWS?KBQ?KB,16KB
且该参数需要在建库的时候指定,一旦指定不能更攏V?br /> 虽然在ORACLE9I以上可以指定表空间的数据库大,允许同时使用包括非默认大在内的数据库块大小。不q需要设|指定大数据块的buffer_cache.

的块:(x)
的块降低块竞争Q因为每个块中的行较?yu)?
的块对于小的行有益.
的块对于随意的讉K较好.如果一个块不太可能在读入内存后被修改,那么块的大小小使用buffer cache有效率。当内存资源很珍贉|ؓ(f)重要Q因为数据库的buffer cache是被限制大小的?br /> 劣势Q?br /> 块的管理消费相对大.
因ؓ(f)行的大小你可能只在块中存储很数目的行,q可能导致额外的I/O?br /> 块可能D更多的烦(ch)引块被读?/p>

大的?br /> 好处Q?br /> 更少的管理消费和更多存储数据的空?
大块对于有顺序的d较好.  譬如说全表扫?br /> 大块对很大的行较?br /> 大块改进?jin)?ch)引读取的性能.大的块可以在一个块中容Ux多的索引条目,降低?jin)大的?ch)引的数?少的index level意味着在遍历烦(ch)引分支的时候越的I/O?br /> 劣势Q?br /> 大块不适合在OLTP中用作烦(ch)引块,因ؓ(f)它们增加?jin)在索引叶块上的块竞争?br /> 如果你是随意的访问小的行q有大的块,buffer cachep费?jin)。例如,8 KB的block size ?0 byte row size,你浪费了(jin)7,950



 



晓宇 2008-11-25 15:45 发表评论
]]>
TIPShttp://www.aygfsteel.com/csusky/archive/2008/11/10/239696.html晓宇晓宇Mon, 10 Nov 2008 08:31:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/11/10/239696.htmlhttp://www.aygfsteel.com/csusky/comments/239696.htmlhttp://www.aygfsteel.com/csusky/archive/2008/11/10/239696.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/239696.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/239696.html进?nbsp; 杯莫?nbsp; -------> 亭名Q?nbsp; (zhn)默?sh)?br />
全球通史

《诗l?#183;采薇?br />
昔我往?杨柳依依 今我来?雨雪霏霏



晓宇 2008-11-10 16:31 发表评论
]]>
SPRING整合IBMMQ实现全局事物http://www.aygfsteel.com/csusky/archive/2008/10/27/236912.html晓宇晓宇Mon, 27 Oct 2008 09:01:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/10/27/236912.htmlhttp://www.aygfsteel.com/csusky/comments/236912.htmlhttp://www.aygfsteel.com/csusky/archive/2008/10/27/236912.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/236912.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/236912.html阅读全文

晓宇 2008-10-27 17:01 发表评论
]]>
Lucene的切?analysis?/title><link>http://www.aygfsteel.com/csusky/archive/2008/05/30/204087.html</link><dc:creator>晓宇</dc:creator><author>晓宇</author><pubDate>Fri, 30 May 2008 06:47:00 GMT</pubDate><guid>http://www.aygfsteel.com/csusky/archive/2008/05/30/204087.html</guid><wfw:comment>http://www.aygfsteel.com/csusky/comments/204087.html</wfw:comment><comments>http://www.aygfsteel.com/csusky/archive/2008/05/30/204087.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/csusky/comments/commentRss/204087.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/csusky/services/trackbacks/204087.html</trackback:ping><description><![CDATA[<p style="font-size: 10pt">在搜索引擎中Q切词语是一个重要的部分Q其中包括专有名词的提取、词的分剌Ӏ词的格式化{等?br /> TokenStream cd乎是所有这些类的基c?br /> 有两个需要被子类实现的方法Token next() ?nbsp;close()<br /> 首先来看analysis包,q个包主要是提供一些简单的词汇化处?br /> ?span style="color: #339966">Tokenizerl尾的类</span>是将要处理的字符串进行分割成Token,而根据分割的依据的又产生?jin)以下几个Tokenizerc?br /> 首先TokenizercL所?span style="color: #000000"><span style="color: #008080">以Tokenizerl尾的类</span>的基<span style="color: #000000">c?br /> 然后是CharTokenizerQ所有的?span style="color: #339966">Tokenizerl尾的类都是从这个类l承?br /> <span style="color: #000000">q个cM有一个抽象方?br /> <span style="color: #ff0000">  protected abstract boolean isTokenChar(char c);</span><br /> 另外一个需要被子类覆写的方?br />  <span style="color: #ff0000"> protected char normalize(char c) {}Q?/span><br /> 是对单个字符q行处理的方法譬如说英文字母全部{化ؓ(f)写<br /> <br /> q有一个变?br /> <span style="color: #ff0000">protected Reader input;<br /> </span><span style="color: #0000ff">q个d器是q些cL处理的数据的   数据?br /> 输入一个Reader Q生一个Token?/span><br /> <br /> q个Ҏ(gu)是是否进行切分的依据Q依ơ读取char,然后用这个方法对每个charq行(g),如果q回false则将预先存储?br /> 词汇~冲Z的char数组作ؓ(f)一个Tokenq回<br /> <span style="color: #ff0000">LetterTokenizer Q?/span><br />     <span style="color: #ff99cc"> <span style="color: #333399"> protected boolean isTokenChar(char c) {<br />               return Character.isLetter(c);<br />       }<br /> </span></span><span style="color: #ff0000">WhitespaceTokenizerQ?/span><br />      <span style="color: #333399"> protected boolean isTokenChar(char c) {<br />               return !Character.isWhitespace(c);<br />       } <br /> </span><span style="color: #ff0000">LowerCaseTokenizer extends LetterTokenizerQ?/span><br /> <span style="color: #333399">protected char normalize(char c) {<br />       return Character.toLowerCase(c);<br />    }</span><br />    在构造函C调用super(in);q行?nbsp;LetterTokenizer同样的操作,但是在词汇化之前所有的词都转化为小写了(jin)<br />  <br /> 然后是以Filterl尾的类Q这个类主要是对已l词汇化的Token进行进一步的处理<br />  输入是Token?, 输出仍然是Token?br /> TokenFilter extends TokenStream  是所有这些类的父c?br /> protected TokenStream input;<br /> 在TokenFilter 中有一个TokenStream 变量Q是Filtercȝ处理的数据源Q而Filtercȝ又是l承?jin)TokenStream cȝ<br /> 有一个public final Token next()Ҏ(gu),q个Ҏ(gu)以TokenStream.next()产生的Token?为处理源Q生的仍然是Token?br /> 只不q中间有一些处理的q程<br /> <span style="color: #ff0000">LowerCaseFilterQ将所有的Token的转化为小?br /> </span>    <span style="color: #333399"> t.termText = t.termText.toLowerCase();</span><br /> <span style="color: #ff0000">StopFilterQ过滤掉一些停止词Q这些停止词由构造函数指?/span><br />  <span style="color: #333399">    for (Token token = input.next(); token != null; token = input.next())<br />       if (!stopWords.contains(token.termText))<br />         return token;<br /> </span><br /> <br /> <span style="color: #800080">比较一下Tokenizercȝ和FiltercȝQ可以知?br /> Tokenizercȝ主要是对输入的Reader,实际上是字符按照一定的规则q行分割Q生出Token?br /> 其输入是字符串的ReaderŞ式,输出是Token?br /> <br /> Filtercȝ主要是对输入的Token进行更q一步的处理Q如去除停止词,转化为小?br /> 主要Z些格式化操作?br /> ׃Filtercȝ的输入输出相同,所以可以嵌套几个不同的Filterc,以达到预期的处理目的?br /> 前一个Filtercȝ输出作ؓ(f)后一个Filtercȝ输入<br /> 而Tokenizercȝ׃输入输出不同Q所以不能嵌?br /> <br /> <br /> </span><br /> <br /> <br /> <br /> <br /> </span></span></span></span></p> <img src ="http://www.aygfsteel.com/csusky/aggbug/204087.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/csusky/" target="_blank">晓宇</a> 2008-05-30 14:47 <a href="http://www.aygfsteel.com/csusky/archive/2008/05/30/204087.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JDK1.5的自动装功?/title><link>http://www.aygfsteel.com/csusky/archive/2008/05/16/200842.html</link><dc:creator>晓宇</dc:creator><author>晓宇</author><pubDate>Fri, 16 May 2008 03:33:00 GMT</pubDate><guid>http://www.aygfsteel.com/csusky/archive/2008/05/16/200842.html</guid><wfw:comment>http://www.aygfsteel.com/csusky/comments/200842.html</wfw:comment><comments>http://www.aygfsteel.com/csusky/archive/2008/05/16/200842.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/csusky/comments/commentRss/200842.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/csusky/services/trackbacks/200842.html</trackback:ping><description><![CDATA[<p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt">在JAVA JDK1.5以后h的自动装׃拆箱的功能,所谓的自动装箱<br clear="all" /> 与拆׃是把基本的数据cd自动的{为封装类型?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">如:(x)自动装箱Q它可以直接把基本类型赋值给装cd</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer num = 10 ;</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Double d = 2d ;</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">自动拆箱Q它可以把封装类型赋值给基本cd</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">int num = new Integer(10);</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">double d = new Double(2d);</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt">自动装箱与拆q功能事实上是~译器来帮?zhn)的忙Q编译器在编译时期依(zhn)所~写的语法,军_是否q行装箱或拆动作。在自动装箱时对于g-128?27之间的|它们被装׃ؓ(f)Integer对象后,?x)存在内存?sh)被重用,所以范?.6中?=q行比较Ӟi1 ?i2实际上参考至同一个对象。如果超q了(jin)?128?27之间的|被装后的Integer对象q不?x)被重用Q即相当于每ơ装时都新Z个Integer对象Q所以范?.7使用==q行比较Ӟi1与i2参考的是不同的对象。所以不要过分依赖自动装׃拆箱Q?zhn)q是必须知道基本数据cd与对象的差异?/span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">    <span style="color: blue">public void testBoxingUnboxing() {</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">        int i = 10;</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">        Integer inta = i;</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">        inta++;</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">        inta += 1;</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">        int j = inta;</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt"><span style="color: blue">        assertTrue(j == inta);</span><span style="color: blue">l果是:(x)</span><span style="color: blue">true</span><span style="color: red">//junit</span><span style="color: red">里面的方?/span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt"><span style="color: blue">        assertTrue(j == new Integer(j)); </span><span style="color: blue">l果是:(x)</span><span style="color: blue">true</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt"><span style="color: blue">        assertTrue(10000 == new Integer(10000)); </span><span style="color: blue">l果是:(x)</span><span style="color: blue">true</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="color: blue"><span style="font-size: 10pt">    }</span></span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">Integer i = 100.相当于编译器自动为?zhn)作以下的语法~译Q?/span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">Integer i = new Integer(100).所以自动装׃拆箱的功能是所谓的“~译器蜜p?#8221;(Compiler Sugar)Q虽然用这个功能很方便Q但在程序运行阶D|得了(jin)解Java的语义。例如下面的E序是可以通过~译的:(x)</span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">Integer i = null.int j = i.q样的语法在~译时期是合法的Q但是在q行时期?x)有错误Q因U写法相当于Q?/span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">Integer i = null.int j = i.intValue().null表示i没有参考至M的对象实体,它可以合法地指定l对象参考名U。由于实际上iq没有参考至M的对象,所以也׃可能操作intValue()Ҏ(gu)Q这样上面的写法在运行时?x)出现NullPointerException错误?/span></p> <p style="margin: 0cm 0cm 0pt; text-indent: 21pt"><span style="font-size: 10pt">自动装箱、拆q功能提供?jin)方便性,但隐藏了(jin)一些细节,所以必d?j)。再来看范例4.6Q?zhn)认?f)l果是什么呢Q?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><span style="color: red">Ü. </span><span style="color: red">范例</span><span style="color: red">4.6 AutoBoxDemo2.java </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">public class AutoBoxDemo2 { </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">public static void main(String[] args) { <br /> Integer i1 = 100;</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer i2 = 100; </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">if (i1 == i2) </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 == i2");</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">else </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 != i2"). </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt">从自动装׃拆箱的机制来看,可能?x)觉得结果是昄i1 == i2Q?zhn)是对的。那么范?.7的这个程序,(zhn)觉得结果是什么?</span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><span style="color: #ff6600">Ü. </span><span style="color: #ff6600">范例</span><span style="color: #ff6600">4.7 AutoBoxDemo3.java </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">public class AutoBoxDemo3 { </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">public static void main(String[] args) { </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer i1 = 200;</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer i2 = 200; </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">if (i1 == i2) </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 == i2");</span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">else </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 != i2"); </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><strong><span style="color: red">l果是显C?/span><span style="color: red">i1 != i2</span></strong><strong><span style="color: red">Q?/span></strong>q有些o(h)人惊Ӟ两个范例语法完全一P只不q改个数D已Q结果却相反?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt">其实q与==q算W的比较有关Q在W?章中介绍q?=是用来比较两个基本数据类型的变量值是否相{,事实?=也用于判断两个对象引用名U是否参考至同一个对象?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><span style="color: #ff6600">在自动装时对于g</span><span style="color: #ff6600">–128</span><span style="color: #ff6600">?/span><span style="color: #ff6600">127</span><span style="color: #ff6600">之间的|它们被装׃ؓ(f)</span><span style="color: #ff6600">Integer</span><span style="color: #ff6600">对象后,?x)存在内存?sh)被重用,所以范?/span><span style="color: #ff6600">4.6</span><span style="color: #ff6600">中?/span><span style="color: #ff6600">==</span><span style="color: #ff6600">q行比较Ӟ</span><span style="color: #ff6600">i1 </span><span style="color: #ff6600">?/span><span style="color: #ff6600"> i2</span><span style="color: #ff6600">实际上参考至同一个对象。如果超q了(jin)?/span><span style="color: #ff6600">–128</span><span style="color: #ff6600">?/span><span style="color: #ff6600">127</span><span style="color: #ff6600">之间的|被装后?/span><span style="color: #ff6600">Integer</span><span style="color: #ff6600">对象q不?x)被重用Q即相当于每ơ装时都新Z?/span><span style="color: #ff6600">Integer</span><span style="color: #ff6600">对象Q所以范?/span><span style="color: #ff6600">4.7</span><span style="color: #ff6600">使用</span><span style="color: #ff6600">==</span><span style="color: #ff6600">q行比较Ӟ</span><span style="color: #ff6600">i1</span><span style="color: #ff6600">?/span><span style="color: #ff6600">i2</span><span style="color: #ff6600">参考的是不同的对象?/span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt">所以不要过分依赖自动装׃拆箱Q?zhn)q是必须知道基本数据cd与对象的差异。范?.7最好还是依正规的方式来写,而不是依赖编译器蜜糖(Compiler Sugar)。例如范?.7必须改写?.8才是正确的?/span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><span style="color: red">Ü. </span><span style="color: red">范例</span><span style="color: red">4.8 AutoBoxDemo4.java </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">public class AutoBoxDemo4 { <br /> public static void main(String[] args) { </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer i1 = 200; </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">Integer i2 = 200; </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">if (i1.equals(i2)) </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 == i2"); </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">else </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">System.out.println("i1 != i2"); </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="color: blue"><span style="font-size: 10pt">} </span></span></p> <p style="margin: 0cm 0cm 0pt"><span style="font-size: 10pt"><strong>l果q次是显C?span style="color: red">i1 == i2</span></strong><strong>?/strong>使用q样的写法,怿也会(x)比较攑ֿ(j)一些,对于q些方便但隐藏细节的功能到底要不要用呢?基本上只有一个原则:(x)如果(zhn)不定׃要用?/span></p> <img src ="http://www.aygfsteel.com/csusky/aggbug/200842.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/csusky/" target="_blank">晓宇</a> 2008-05-16 11:33 <a href="http://www.aygfsteel.com/csusky/archive/2008/05/16/200842.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于IndexWriter中的3个性能参数http://www.aygfsteel.com/csusky/archive/2008/05/15/200706.html晓宇晓宇Thu, 15 May 2008 11:27:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/05/15/200706.htmlhttp://www.aygfsteel.com/csusky/comments/200706.htmlhttp://www.aygfsteel.com/csusky/archive/2008/05/15/200706.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/200706.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/200706.html?font size="2">IndexWriter中有3个重要的性能参数
mergeFactor           默认?0
minMergeDocs      默认?0
maxMergeDocs     默认为Integer.maxValue

maxMergeDocs     一个段中所能包含的最大的doc敎ͼ辑ֈq个数目即不再将D进行合q?一般不改变q个?br /> minMergeDocs      是指在RAMDirectory中保存的Doc的个敎ͼ辑ֈminMergeDocs 个即要合q到盘?sh)去Q在盘?sh)新Z个段Q?br /> mergeFactor           合ƈ因子Q是控制盘?sh)的D늚合ƈ的,每次在硬盘(sh)新徏一个段之后x?br />                                  targetMergeDocs*=mergeFactorQ一开?font size="2">targetMergeDocs=minMergeDocsQ?nbsp;如果盘?sh)的doc数目大于{于                            targetMergeDocs则将盘?sh)最后徏立的mergeFactor个段q行合ƈ成一个段

拉K认的参数举例Q?br /> 如果盘?sh)面已经?个段  每个D分别存储了(jin)10个Document,共(90个DOCQ,q时候如果程序再向硬盘合q一个新的段Q含10个DOCQ,合ƈ完之?font size="2">targetMergeDocs=10*10  E序(g)查已l合q的最后(按照创徏的时间先后顺序)(j)mergeFactor个段的document的d100是否大于{于targetMergeDocsQ这里是100Q刚好满求)(j)于是E序又将盘?sh)面的?0个段合ƈZ个新的段?br />
另外一个例子:(x)
doc数目            D|?br />   1000---------------9?br />   100-----------------9?br />   10   ----------------9?br /> q时如果再象盘?sh)新Z个新的包含了(jin)10个doc的段
    doc数目            D|?br />   (1) 1000----------------9?br />
  (2)  100-----------------9?br />
  (3)   10  ----------------9?br />                                      
  (4)    10 ----------------1?br /> q时?3)(4)首先合ƈ成一个新的段(3-4)包含100个doc
 然后(2)(3-4)和ƈ成一个新D(2-3-4Q包?000个doc
然后(1)(2-3-4)合ƈ成一个新的段  包含10000个doc
最后合q成一个段


private final void maybeMergeSegments() throws IOException {
    
long targetMergeDocs = minMergeDocs;
    
while (targetMergeDocs <= maxMergeDocs) {
      
// find segments smaller than current target size
      int minSegment = segmentInfos.size();
      
int mergeDocs = 0;
      
while (--minSegment >= 0{
        SegmentInfo si 
= segmentInfos.info(minSegment);
        
if (si.docCount >= targetMergeDocs)
          
break;
        mergeDocs 
+= si.docCount;
      }


      
if (mergeDocs >= targetMergeDocs)          // found a merge to do
        mergeSegments(minSegment+1);
      
else
        
break;

      targetMergeDocs 
*= mergeFactor;        // increase target size
      System.out.println("- -- - -targetMergeDocs:"+targetMergeDocs);
      
try {Thread.sleep(5000);} catch(Exception e) {};
    }

  }


晓宇 2008-05-15 19:27 发表评论
]]>
HIBERNATE的一对多和多对一兌http://www.aygfsteel.com/csusky/archive/2008/05/14/200363.html晓宇晓宇Wed, 14 May 2008 03:01:00 GMThttp://www.aygfsteel.com/csusky/archive/2008/05/14/200363.htmlhttp://www.aygfsteel.com/csusky/comments/200363.htmlhttp://www.aygfsteel.com/csusky/archive/2008/05/14/200363.html#Feedback0http://www.aygfsteel.com/csusky/comments/commentRss/200363.htmlhttp://www.aygfsteel.com/csusky/services/trackbacks/200363.htmlHIBERNATE一多对兌?nbsp; 要求在持久化cM定义集合cd性时Q必L属性声明ؓ(f)接口Q因为HIBERNATE在调用持久化cȝSET/GETҎ(gu)时传递的是HIBERNATE自己定义的集合类?br /> 在定义集合时Q一般先初始化ؓ(f)集合实现cȝ一个实?Q?private Set orders=new HashSet()Q这样可以避免访问空集合出现NullPointerException.



晓宇 2008-05-14 11:01 发表评论
]]>
Lucene索引文g的格?/title><link>http://www.aygfsteel.com/csusky/archive/2008/04/21/194564.html</link><dc:creator>晓宇</dc:creator><author>晓宇</author><pubDate>Mon, 21 Apr 2008 09:52:00 GMT</pubDate><guid>http://www.aygfsteel.com/csusky/archive/2008/04/21/194564.html</guid><wfw:comment>http://www.aygfsteel.com/csusky/comments/194564.html</wfw:comment><comments>http://www.aygfsteel.com/csusky/archive/2008/04/21/194564.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/csusky/comments/commentRss/194564.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/csusky/services/trackbacks/194564.html</trackback:ping><description><![CDATA[<p><span style="font-size: 10pt"><span style="color: #ccffcc"><span style="color: #ccffcc"><span style="color: #99ccff"><span style="color: #3366ff">segments文g的格式:(x) Q段的信息)(j)<br /> int:  =-1    查看文g是否是Lucene合法的文件格?br /> long:        版本P每更Cơ该文g会(x)版本号?<br /> int:         用来命名新段<br /> int:         D늚数目<br /> String + int D늚信息 String是段的名U?nbsp; int是段中所含的doc数目<br /> String + int 同上</span></span></span></span></span></p> <p><br /> <span style="font-size: 10pt"><span style="color: #99cc00"><span style="color: #ccffcc"><span style="color: #ccffcc"><span style="color: #99ccff"><span style="color: #3366ff">.fnm的文件格式:(x)   QF(tun)ield的信息)(j)<br /> int:               Field的个敎ͼ最ؓ(f)1Q最有一个Field("",false)Q在初始化的时候写?暂时不知道原?; 名称为空字符Ԍ未烦(ch)引,        ?nbsp;              ?nbsp;          量化。readVInt()d<br /> String: byte      String?nbsp;Field的名U?nbsp; byte指示该Field 是否被烦(ch)引,是否向量?Q值有Q?1Q?0Q?1Q第一?代表被烦(ch)引,W二个代表被向量?br /> String: byte Field 同上</span></span></span></span></span></span>      </p> <p><span style="color: #3366ff"> <br /> </span></p> <p><span style="font-size: 10pt"><span style="color: #3366ff">.fdx的文件格式:(x)主要是提供对.fdt中存储的document的随卌?br /> long :       W一个document?fdt文g中的位置<br /> long:        W二个document?fdt文g中的位置</span></span><span style="color: #3366ff"> <p><span style="color: #3366ff"><br /> </span></p> </span></p> <p><span style="font-size: 10pt"><span style="color: #3366ff">.fdt的文件格式:(x)  .fdt文g存储?jin)一pddocument的信?br /> VInt:        该document中的isStored属性ؓ(f)true的域的个?br /> (VInt:)      如果该field的isStored属性ؓ(f)true则得到该field的fieldNumberQ暂时不知道q个fieldNumber是怎么产生的,有什么用Q初步估计是按照field创徏的顺序生的Q每ơ再上一个field的fieldNumber基础上加1?br /> byte:        如果该field的isTokenized属性ؓ(f)true写入1否则写入false?br /> String:      该field的stringValue()倹{?br /> 一个documentl束Q下面的数据会(x)开始一个新的documentQ每个新的document的开始点的文件位|都?x)?fdx中有记蝲Q便于随卌?/span></span></p> <p> </p> <img src ="http://www.aygfsteel.com/csusky/aggbug/194564.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/csusky/" target="_blank">晓宇</a> 2008-04-21 17:52 <a href="http://www.aygfsteel.com/csusky/archive/2008/04/21/194564.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">ڳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">פ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">ʱ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƺ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ĭ</a>| <a href="http://" target="_blank">ӽ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӫɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͩ®</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ݰ</a>| <a href="http://" target="_blank">ʯɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ľ</a>| <a href="http://" target="_blank">Ԫı</a>| <a href="http://" target="_blank">̫</a>| <a href="http://" target="_blank">ͬ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ٷ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>