<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Events</title>
	<atom:link href="http://grepme2.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://grepme2.wordpress.com</link>
	<description>the blog is about me</description>
	<lastBuildDate>Wed, 11 Jul 2007 11:16:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='grepme2.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Events</title>
		<link>http://grepme2.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://grepme2.wordpress.com/osd.xml" title="Events" />
	<atom:link rel='hub' href='http://grepme2.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Document scoring in lucene &#8211; Part 2</title>
		<link>http://grepme2.wordpress.com/2007/07/06/document-scoring-in-lucene-part-2/</link>
		<comments>http://grepme2.wordpress.com/2007/07/06/document-scoring-in-lucene-part-2/#comments</comments>
		<pubDate>Fri, 06 Jul 2007 10:43:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/07/06/document-scoring-in-lucene-part-2/</guid>
		<description><![CDATA[This is an addition to the previous post document scoring/calculating relevance in lucene. If you find the link inadequate you can refer scoring@lucene.org and the formula at Default similarity formula. What i did was i created some txt file and some code to index the file and have tried to find out in practice how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=138&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is an addition to the previous post <a HREF="http://jayant7k.blogspot.com/2006/07/document-scoringcalculating-relevance_08.html">document scoring/calculating relevance in lucene</a>. If you find the link inadequate you can refer <a HREF="http://lucene.apache.org/java/docs/scoring.html">scoring@lucene.org</a> and the formula at <a HREF="http://lucene.zones.apache.org:8080/hudson/job/Lucene-Nightly/javadoc/org/apache/lucene/search/Similarity.html"> Default similarity formula</a>.</p>
<p>What i did was i created some txt file and some code to index the file and have tried to find out in practice how lucene calculates relevance using the DefaultSimilarity class. Here is the file and the source code.</p>
<p>file: file_a.txt<br />
<span STYLE="font-style: italic">jayant project manager project leader team leader java linux c c++ lucene apache solaris aix unix minix gnome kde ubuntu redhat fedora rpm deb media player vlc evolution exchange microsoft java vb vc vc++ php mysql java<br />
</span><br />
source code: FIndexer.java<br />
<span STYLE="font-style: italic">import java.io.*;<br />
import java.util.Date;<br />
import org.apache.lucene.index.*;<br />
import org.apache.lucene.document.*;<br />
import org.apache.lucene.analysis.*;public class FIndexer<br />
{</p>
<p>public static void main (String[] args) throws Exception<br />
{<br />
String src_path = args[0];<br />
String des_path = args[1];</p>
<p>File f_src = new File(src_path);<br />
File f_des = new File(des_path);</p>
<p>if(!f_src.isDirectory() || !f_des.isDirectory())<br />
{<br />
System.out.println(&#8220;Error : &#8220;+f_src+&#8221; || &#8220;+f_des+&#8221; is not directory&#8221;);<br />
System.exit(1);<br />
}</p>
<p>IndexWriter writer = new IndexWriter(f_des,new WhitespaceAnalyzer(), true);</p>
<p>File[] files = f_src.listFiles();<br />
for(int x=0; x &lt; files.length; x++)<br />
{<br />
Document doc = new Document();<br />
if(files[x].isFile())<br />
{<br />
BufferedReader br = new BufferedReader(new FileReader(files[x]));<br />
StringBuffer content = new StringBuffer();<br />
String line = null;<br />
while( (line = br.readLine()) != null)<br />
{<br />
content.append(line).append(&#8220;\n&#8221;);<br />
}</p>
<p>Field f1 = new Field(&#8220;name&#8221;,files[x].getName(), Field.Store.YES, Field.Index.NO);<br />
doc.add(f1);<br />
Field f2 = new Field(&#8220;content&#8221;, content.toString(), Field.Store.NO, Field.Index.TOKENIZED);<br />
doc.add(f2);<br />
Field f3 = new Field(&#8220;content2&#8243;, content.toString(), Field.Store.NO, Field.Index.TOKENIZED);<br />
doc.add(f3);</p>
<p>}<br />
writer.addDocument(doc);<br />
}<br />
writer.optimize();<br />
writer.close();<br />
}<br />
}</p>
<p></span>I created copies of the file_a.txt as file_b.txt and file_c.txt and edited file_c.txt. Such that file_a.txt and file_b.txt have the same content (that is word <span STYLE="font-style: italic">java</span> occurs 3 times in both the files). And file_c.txt has word <span STYLE="font-style: italic">java</span> occuring only 2 times.</p>
<p>I created an index using FIndexer.java and used <a HREF="http://www.getopt.org/luke/">luke</a> to fire queries on the index.</p>
<p>Firstly did a search <span STYLE="font-style: italic">content:java</span>. And as expected i got 3 results with the following score.</p>
<table CLASS="">
<tr>
<td CLASS=""><strong>Rank</strong></td>
<td CLASS=""><strong>score</strong></td>
<td CLASS=""><strong>filename</strong></td>
</tr>
<tr>
<td CLASS="">0</td>
<td CLASS="">0.1928</td>
<td CLASS="">file_b.txt</td>
</tr>
<tr>
<td CLASS="">1</td>
<td CLASS="">0.1928</td>
<td CLASS="">file_a.txt</td>
</tr>
<tr>
<td CLASS="">2</td>
<td CLASS="">0.1574</td>
<td CLASS="">file_c.txt</td>
</tr>
</table>
<p>Lets take the score for file_b.txt and see how it is calculated. The score is a product of<br />
tf = 1.7321 (java occurs 3 times)<br />
idf = 0.7123 (document freq = 3)</p>
<p>And the score of file_c.txt is a product of<br />
tf = 1.4142 (java occurs 2 times)<br />
idf = 0.7123 (document freq = 3)</p>
<p>Here score is equivalent to the <span STYLE="font-style: italic">fieldWeight</span> since there is just one field. If more than one fields are used in the query, then the score would be a product of the <span STYLE="font-style: italic">queryWeight</span> and <span STYLE="font-style: italic">fieldWeight</span></p>
<p>So if i change the query to <span STYLE="font-style: italic">Content:java^5 Content2:java^2</span>. Here i am boosting java in content by 5 and java in content2 by 2. That is java in content is 2.5 times more important than java in content2. Lets check the scores.</p>
<table CLASS="">
<tr>
<td CLASS=""><strong>Rank</strong></td>
<td CLASS=""><strong>score</strong></td>
<td CLASS=""><strong>filename</strong></td>
</tr>
<tr>
<td CLASS="">0</td>
<td CLASS="">0.2506</td>
<td CLASS="">file_b.txt</td>
</tr>
<tr>
<td CLASS="">1</td>
<td CLASS="">0.2506</td>
<td CLASS="">file_a.txt</td>
</tr>
<tr>
<td CLASS="">2</td>
<td CLASS="">0.2046</td>
<td CLASS="">file_c.txt</td>
</tr>
</table>
<p>Lets look at how the score was calculated</p>
<p>Again for file_b.txt<span STYLE="font-style: italic"><br />
0.2506 = 0.1709 (weight of content:java^5) * 0.0716 (weight of content2:java^2)Out of which Weight of content:java^5 is<br />
= 0.9285(Query weight) [ 5 (boost) * 0.7123 (idf docFreq=3) * 0.2607 (queryNorm) ]<br />
* 0.1928(field weight) [ 1.7321 (tf=3) * 0.7123 (idf docFreq=3) * 0.1562 (fieldNorm) ]</p>
<p>And weight of content2:java^2 is<br />
= 0.3714(Query weight) [ 2 (boost) * 0.7123 (idf docFreq=3) * 0.2607 (queryNorm) ]<br />
* 0.1928(Field weight) [ 1.7321 (tf=3) * 0.7123 (idf docFreq=3) * 0.1562 (fieldNorm) ]<span>The same formula is used for calculating of score of file_c.txt except for the fact that <span STYLE="font-style: italic">termfrequency = 1.4142</span> (tf of content:java or content2:java is 2)</p>
<p>This explains a little about scoring in lucene. The scoring can be altered by either changing the DefaultSimilarity class or extending the DefaultSimilarity and changing certain factors/calculations in it. More on how to change the scoring formula later.</p>
<p></span></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/138/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/138/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=138&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/07/06/document-scoring-in-lucene-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>My Chances of being a multimillionaire</title>
		<link>http://grepme2.wordpress.com/2007/07/02/my-chances-of-being-a-multimillionaire/</link>
		<comments>http://grepme2.wordpress.com/2007/07/02/my-chances-of-being-a-multimillionaire/#comments</comments>
		<pubDate>Mon, 02 Jul 2007 04:52:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/07/02/my-chances-of-being-a-multimillionaire/</guid>
		<description><![CDATA[Your Chances of Being a Multimillionaire: 76% You have a good chance of being a multimillionaire. Better than most people.You simply have a natural knack for money and the personality for success. Will You Be a Multimillionaire?<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=137&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<table width="350" align="center" border="0" cellspacing="0" cellpadding="2">
<tr>
<td bgcolor="#EEE9E9" align="center"><font face="Georgia, Times New Roman, Times, serif"><b>Your Chances of Being a Multimillionaire: 76%</b></font></td>
</tr>
<tr>
<td bgcolor="#FFFAFA"><img src="http://images.blogthings.com/willyoubeamultimillionairequiz/mm-4.jpg" height="100" width="100"><font color="#000000"><br />You have a good chance of being a multimillionaire. Better than most people.<br />You simply have a natural knack for money and the personality for success.</font></td>
</tr>
</table>
<div align="center"><a href="http://www.blogthings.com/willyoubeamultimillionairequiz/">Will You Be a Multimillionaire?</a></div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/137/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/137/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=137&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/07/02/my-chances-of-being-a-multimillionaire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>

		<media:content url="http://images.blogthings.com/willyoubeamultimillionairequiz/mm-4.jpg" medium="image" />
	</item>
		<item>
		<title>change boot splash screen ubuntu</title>
		<link>http://grepme2.wordpress.com/2007/06/29/change-boot-splash-screen-ubuntu/</link>
		<comments>http://grepme2.wordpress.com/2007/06/29/change-boot-splash-screen-ubuntu/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 03:13:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/06/29/change-boot-splash-screen-ubuntu/</guid>
		<description><![CDATA[Easy steps to change the boot splash screen in ubuntu 7.04 1. firstly get the available splash screens. Do a sudo apt-get install usplash* It will display a list of available splash screens with ubuntu. 2. Next check out the available splash screens in /usr/lib/usplash ls -lh /usr/lib/usplash total 12M -rw-r&#8211;r&#8211; 1 root root 43K [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=136&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Easy steps to change the boot splash screen in ubuntu 7.04</p>
<p>1. firstly get the available splash screens. Do a</p>
<p><span STYLE="font-weight: 700">sudo apt-get install usplash*</span></p>
<p>It will display a list of available splash screens with ubuntu.</p>
<p>2. Next check out the available splash screens in /usr/lib/usplash</p>
<p><span STYLE="font-weight: 700">ls -lh /usr/lib/usplash</span></p>
<p><span STYLE="font-style: italic">total 12M<br />
-rw-r&#8211;r&#8211; 1 root root  43K 2006-11-23 17:42 debian-edu-usplash.so<br />
-rw-r&#8211;r&#8211; 1 root root 2.3M 2007-03-30 17:33 edubuntu-splash.so<br />
lrwxrwxrwx 1 root root   36 2007-05-17 23:20 usplash-artwork.so -&gt; /etc/alternatives/usplash-artwork.so<br />
-rw-r&#8211;r&#8211; 1 root root 2.0M 2006-10-17 15:13 usplash-theme-ichthux.so<br />
-rw-r&#8211;r&#8211; 1 root root 2.3M 2007-04-07 15:36 usplash-theme-kubuntu.so<br />
-rw-r&#8211;r&#8211; 1 root root 2.6M 2007-04-10 18:28 usplash-theme-ubuntu.so<br />
-rw-r&#8211;r&#8211; 1 root root 2.0M 2007-03-19 16:17 usplash-theme-xubuntu.so<br />
</span></p>
<p>Here you can see that you have 6 splash screens and one soft link. Check out the softlink.</p>
<p><span STYLE="font-weight: 700">ls -lh /etc/alternatives/usplash-artwork.so</span></p>
<p><span STYLE="font-style: italic">lrwxrwxrwx 1 root root 41 2007-06-29 08:38 /etc/alternatives/usplash-artwork.so -&gt; /usr/lib/usplash/usplash-theme-xubuntu.so</span></p>
<p>It points back to one of the screens from the /usr/lib/usplash directory. So to change the screen simply change the soft link</p>
<p><span STYLE="font-weight: 700">sudo ln -sf /usr/lib/usplash-theme-kubuntu.so /etc/alternatives/usplash-artwork.so</span></p>
<p>And now check the new link</p>
<p>3. reconfigure the linux image</p>
<p><span STYLE="font-weight: 700">sudo dpkg-reconfigure linux-image-</span><br />
<span STYLE="font-style: italic"><br />
Running depmod.<br />
update-initramfs: Generating /boot/initrd.img-2.6.20-16-generic<br />
.<br />
.<br />
Updating /boot/grub/menu.lst &#8230; done</span></p>
<p>Thats done&#8230;</p>
<p>To check the new screen, no dont reboot simply type in</p>
<p><span STYLE="font-weight: 700">sudo usplash</span></p>
<p>And you can see the new screen &#8211; bingo. To get back to your xwindows environment press <span STYLE="font-weight: 700">CTRL-ALT-F7</span></p>
<p>P.S.</p>
<p>here is the link for advanced users for creating their own splash screens<br />
<a HREF="http://codeidol.com/unix/ubuntu/X11/Change-the-Ubuntu-Splash-Screen/">http://codeidol.com/unix/ubuntu/X11/Change-the-Ubuntu-Splash-Screen/</a><br />
Anyone who develops his/her own splash screen can share it out with other ubuntians&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/136/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/136/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=136&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/06/29/change-boot-splash-screen-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>lucene in php &amp; lucene in java</title>
		<link>http://grepme2.wordpress.com/2007/06/07/lucene-in-php-lucene-in-java/</link>
		<comments>http://grepme2.wordpress.com/2007/06/07/lucene-in-php-lucene-in-java/#comments</comments>
		<pubDate>Thu, 07 Jun 2007 05:24:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/06/07/lucene-in-php-lucene-in-java/</guid>
		<description><![CDATA[Something i found out while solving some issue from Mr. Nguyen from vietnam. He used lucene-php in zend framework for building a lucene index and searching on the index, and was facing issues with search times. It turned out that mysql full text index was performing better than lucene index. So i did a quick [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=135&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Something i found out while solving some issue from Mr. Nguyen from vietnam.</p>
<p>He used <a href="http://framework.zend.com/manual/en/zend.search.lucene.html">lucene-php in zend framework</a> for building a lucene index and searching on the index, and was facing issues with  search times. It turned out that mysql full text index was performing better than lucene index. </p>
<p>So i did a quick benchmark and found the following stuff</p>
<p>1. Indexing using php-lucene takes a huge amount of time as compared to java-lucene. I indexed 30000 records and the time it took was 1673 seconds. Optimization time was 210 seconds. Total time for index creation was 1883 seconds. Which is hell lot of time.</p>
<p>2. Index created using php-lucene is compatible to java-lucene. So index created by php-lucene can be read by java-lucene and vice versa.</p>
<p>3. Search in php-lucene is very slow as compared to java-lucene. The time for 100 searches are &#8211; </p>
<p><span style="font-style:italic;">jayant@jayantbox:~/myprogs/java$ java searcher <br />Total : 30000 docs<br />t2-t1 : 231 milliseconds</p>
<p>jayant@jayantbox:~/myprogs/php$ php -q searcher.php <br />Total 30000 docs<br />total time : 15 seconds<br /></span></p>
<p>So i thought that maybe php would be retrieving the documents upfront. And changed the code to extract all documents in php and java. Still the time for 100 searches were -</p>
<p><span style="font-style:italic;">jayant@jayantbox:~/myprogs/java$ java searcher<br />Total : 30000 docs<br />t2-t1 : 2128 milliseconds</p>
<p>jayant@jayantbox:~/myprogs/php$ php -q searcher.php <br />Total 30000 docs<br />total time : 63 seconds<br /></span></p>
<p>The code for php search for lucene index is:</p>
<p><span style="font-style:italic;">
<pre>/* *      searcher.php *      On 2007-06-06 * By jayant  * */

include("Zend/Search/Lucene.php");

$index = new Zend_Search_Lucene("/tmp/myindex");echo "Total ".$index-&gt;numDocs()." docs\n";$query = "java";$s = time();for($i=0; $i{ $hits = $index-&gt;find($query);// retrieve all documents. Comment this code if you dont want to retrieve documents foreach($hits as $hit)  $doc = $hit-&gt;getDocument();

}$total = time()-$s;echo "total time : $total s";?&gt;</pre>
<p></span></p>
<p>And the code for java search of lucene index is<br /><span style="font-style:italic;">
<pre>/* *      searcher.java *      On 2007-06-06 * By jayant  * */

import org.apache.lucene.search.*;import org.apache.lucene.queryParser.*;import org.apache.lucene.analysis.*;import org.apache.lucene.analysis.standard.*;import org.apache.lucene.document.*;

public class searcher {

 public static void main (String args[]) throws Exception {  IndexSearcher s = new IndexSearcher("/tmp/myindex");  System.out.println("Total : "+s.maxDoc()+" docs");  QueryParser q = new QueryParser("content",new StandardAnalyzer());  Query qry = q.parse("java");

  long t1 = System.currentTimeMillis();  for(int x=0; x  {   Hits h = s.search(qry);// retrieve all documents. Comment this code if you dont want to retrieve documents   for(int y=0; y   {    Document d = h.doc(y);   }

  }  long t2 = System.currentTimeMillis();  System.out.println("t2-t1 : "+(t2-t1)+" ms"); }}</pre>
<p></span></p>
<p>Hope i havent missed anything here.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/135/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/135/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=135&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/06/07/lucene-in-php-lucene-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>installing zte mc315 on linux</title>
		<link>http://grepme2.wordpress.com/2007/05/23/installing-zte-mc315-on-linux/</link>
		<comments>http://grepme2.wordpress.com/2007/05/23/installing-zte-mc315-on-linux/#comments</comments>
		<pubDate>Wed, 23 May 2007 13:02:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/05/23/installing-zte-mc315-on-linux/</guid>
		<description><![CDATA[Here are 4 steps to get the reliance aircard ZTE MC315 on linux. I got it running on ubuntu 7.04. 1. Insert the card and look at dmesgoutput : 0.0: ttyS3 at I/O 0x2e8 (irq = 3) is a 16C950/954 This says that your card was detected properly.You can also run &#8220;pccardctl info&#8221;output = PRODID_1=&#8221;CDMA1X&#8221;PRODID_2=&#8221;CARD&#8221;PRODID_3=&#8221;"PRODID_4=&#8221;"MANFID=0279,950bFUNCID=2PRODID_1=&#8221;"PRODID_2=&#8221;"PRODID_3=&#8221;"PRODID_4=&#8221;"MANFID=0000,0000FUNCID=255 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=134&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here are 4 steps to get the reliance aircard ZTE MC315 on linux. I got it running on ubuntu 7.04.</p>
<p>1. Insert the card and look at dmesg<br />output :  0.0: ttyS3 at I/O 0x2e8 (irq = 3) is a 16C950/954</p>
<p>This says that your card was detected properly.<br />You can also run  &#8220;pccardctl info&#8221;<br />output = <br /><span style="font-style:italic;">PRODID_1=&#8221;CDMA1X&#8221;<br />PRODID_2=&#8221;CARD&#8221;<br />PRODID_3=&#8221;"<br />PRODID_4=&#8221;"<br />MANFID=0279,950b<br />FUNCID=2<br />PRODID_1=&#8221;"<br />PRODID_2=&#8221;"<br />PRODID_3=&#8221;"<br />PRODID_4=&#8221;"<br />MANFID=0000,0000<br />FUNCID=255<br /></span></p>
<p>2. edit /etc/wvdial.conf</p>
<p><span style="font-style:italic;">[Dialer Defaults]<br />Modem = /dev/ttyS3<br />Baud = 57600<br />SetVolume = 0<br />Dial-AT-OK ATDT Command = <br />Init1 = ATZ<br />FlowControl = Hardware (CRTSCTS)<br />Phone = #777<br />Username = <br />Password = <br />New PPPD = yes<br />Carrier Check = no<br />Stupid Mode = 1<br /></span><br />3. Run set serial<br />(download and install setserial &#8211; if you dont have setserial)<br />&#8220;setserial /dev/ttyS3 baud_base 230400&#8243;</p>
<p>4. run wvdial<br />wvdial</p>
<p>So to get it running everytime you will need to create a shell script doing steps 3 &amp; 4. Say mydial</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;<br /><span style="font-style:italic;">setserial /dev/ttyS3 baud_base 230400<br />wvdial<br /></span>&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><span style="font-weight:bold;">PS</span><br />This method is also not perfect. I got one card working with this procedure, but could not get another card working using the same procedure. </p>
<p>Let me know if this helps you getting your ZTE MC 315 card running on linux.</p>
<p><span style="font-weight:bold;">PS 2</span><br />And to add to it, finally i have got my card running.<br />The trick is simple &#8211; you have to play with the UART and the baud_base.</p>
<p>Just run <span style="font-style:italic;">setserial</span> on your machine and it will give the following output for <span style="font-style:italic;">UART</span> and <span style="font-style:italic;">baud_base</span></p>
<p><span style="font-style:italic;">* uart          set UART type (none, 8250, 16450, 16550, 16550A,<br />                     16650, 16650V2, 16750, 16850, 16950, 16954)<br />* baud_base     set base baud rate (CLOCK_FREQ / 16)<br /></span></p>
<p>What i did was that i kept on changing my UART and kept the baud_base as 230400. I changed my UART to 16850 and then to 16750. And my card responded at 16750. And i got connected to the internet</p>
<p>So, My dialup script does this before doing wvdial<br /><span style="font-style:italic;"><br />setserial /dev/ttyS3 uart 16750<br />setserial /dev/ttyS3 baud_base 230400</span></p>
<p>And this gets my card running. So to get your card running, i would suggest you try setting different UART and baud_base&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/134/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/134/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=134&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/05/23/installing-zte-mc315-on-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>Anger Management</title>
		<link>http://grepme2.wordpress.com/2007/05/23/anger-management/</link>
		<comments>http://grepme2.wordpress.com/2007/05/23/anger-management/#comments</comments>
		<pubDate>Wed, 23 May 2007 04:08:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/05/23/anger-management/</guid>
		<description><![CDATA[Having a bad day? When you occasionally have a really bad day, and you just need to take It out on someone, don&#8217;t take it out on someone you know &#8212; take it out on someone you don&#8217;t know. I was sitting at my desk when I remembered a phone call I had forgotten to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=133&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having a bad day?</p>
<p>When you occasionally have a really bad day, and you just need to take It out <br />on someone, don&#8217;t take it out on someone you know &#8212; take it out on someone <br />you don&#8217;t know. I was sitting at my desk when I remembered a phone call I had <br />forgotten to make. I found the number and dialed it.</p>
<p>A man answered, saying, &#8220;Hello.&#8221;</p>
<p>I politely said, &#8220;Could I please speak with Robin Carter?&#8221;</p>
<p>Suddenly, the phone was slammed down on me. I couldn&#8217;t believe that Anyone <br />could be so rude. I realized I had called the wrong number. I tracked down <br />Robin&#8217;s correct number and called her. I had accidentally transposed the last <br />two digits of her phone number. After hanging up with her, I decided to call <br />the &#8216;wrong&#8217; number again.</p>
<p>When the same guy answered the phone, I yelled, &#8220;You&#8217;re an *******!&#8221; and hung <br />up.</p>
<p>I wrote his number down with the word &#8216;*******&#8217; next to it, and put it in my <br />desk drawer.</p>
<p>Every couple of weeks, when I was paying bills or had a really bad day, I&#8217;d <br />call him up and yell, &#8220;You&#8217;re an *******!&#8221; It always cheered me up.</p>
<p>When Caller ID came to our area, I thought my therapeutic &#8216;*******&#8217; calling <br />would have to stop. So, I called his number and said, &#8220;Hi, this is John Smith <br />from the Telephone Company. I&#8217;m just calling to see if you&#8217;re familiar with <br />the Caller ID program?&#8221;</p>
<p>He yelled, &#8220;NO!&#8221; and slammed the phone down.</p>
<p>I quickly called him back and said, &#8220;That&#8217;s because you&#8217;re an *******!&#8221;</p>
<p>One day I was at the store, getting ready to pull into a parking spot.<br />Some guy in a black BMW cut me off and pulled into the spot I had patiently <br />waited for. I hit the horn and yelled that I had been waiting for that spot. <br />The idiot ignored me. I noticed a &#8220;For Sale&#8221; sign in his car window . . so, I <br />wrote down his number.</p>
<p>A couple of days later, right after calling the first ******* ( I had his <br />number on speed dial), I thought I had better call the BMW *******, too.</p>
<p>I said, &#8220;Is this the man with the black BMW for sale?&#8221;</p>
<p>&#8220;Yes, it is.&#8221;</p>
<p>&#8220;Can you tell me where I can see it?&#8221;</p>
<p>&#8220;Yes, I live at 1802 West 34th Street . It&#8217;s a yellow house, and the car&#8217;s <br />parked right out in front.&#8221;</p>
<p>&#8220;What&#8217;s your name?&#8221; I asked.</p>
<p>&#8220;My name is Don Hansen,&#8221; he said.</p>
<p>&#8220;When&#8217;s a good time to catch you, Don?&#8221;</p>
<p>&#8220;I&#8217;m home every evening after five.&#8221;</p>
<p>&#8220;Listen, Don, can I tell you something?&#8221;</p>
<p>&#8220;Yes?&#8221;</p>
<p>&#8220;Don, you&#8217;re an *******.&#8221;</p>
<p>Then I hung up, and added his number to my speed dial, too. Now, when I had a <br />problem, I had two assholes to call.<br />But after several months of calling them, it wasn&#8217;t as enjoyable as it used to <br />be. So, I came up with an idea. I called ******* #1.</p>
<p>&#8220;Hello.&#8221;</p>
<p>&#8220;You&#8217;re an *******!&#8221; (But I didn&#8217;t hang up.)</p>
<p>&#8220;Are you still there?&#8221; he asked.</p>
<p>&#8220;Yeah,&#8221; I said.</p>
<p>&#8220;Stop calling me,&#8221; he screamed.</p>
<p>&#8220;Make me,&#8221; I said.</p>
<p>&#8220;Who are you?&#8221; he asked.</p>
<p>&#8220;My name is Don Hansen.&#8221;</p>
<p>&#8220;Yeah? Where do you live?&#8221;</p>
<p>&#8220;*******, I live at 1802 West 34th Street , a yellow house, with my black <br />Beamer parked in front.&#8221;</p>
<p>He said, &#8220;I&#8217;m coming over right now, Don. And you had better start saying your <br />prayers.&#8221;</p>
<p>I said, &#8220;Yeah, like I&#8217;m really scared, *******.&#8221;</p>
<p>Then I called ******* #2.</p>
<p>&#8220;Hello?&#8221; he said.</p>
<p>&#8220;Hello, *******,&#8221; I said.</p>
<p>He yelled, &#8220;If I ever find out who you are&#8230;!&#8221;</p>
<p>&#8220;You&#8217;ll what?&#8221; I said.</p>
<p>&#8220;I&#8217;ll kick your ass,&#8221; he exclaimed.</p>
<p>I answered, &#8220;Well, *******, here&#8217;s your chance. I&#8217;m coming over right now.&#8221;</p>
<p>Then I hung up and immediately called the police, saying that I lived at 1802 <br />West 34th Street, and that I was on my way over there to kill my gay lover.</p>
<p>Then I called Channel 13 News about the gang war going down on West<br />34th Street.</p>
<p>I quickly got into my car and headed over to 34th street .</p>
<p>When I got there, I saw two assholes beating the crap out of each other<br />in front of six squad cars, a police helicopter, and the channel 13<br />news crew.</p>
<p>NOW, I feel better &#8211; This is &#8220;Anger Management&#8221; at its very best.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/133/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/133/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=133&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/05/23/anger-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>mysql multi-master replication &#8211; Act II</title>
		<link>http://grepme2.wordpress.com/2007/05/11/mysql-multi-master-replication-act-ii/</link>
		<comments>http://grepme2.wordpress.com/2007/05/11/mysql-multi-master-replication-act-ii/#comments</comments>
		<pubDate>Fri, 11 May 2007 06:40:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/05/11/mysql-multi-master-replication-act-ii/</guid>
		<description><![CDATA[SETUP PROCEDURE Created 4 instances of mysql on 2 machines running on different ports. Lets call these instances A, B, C and D. So A &#38; C are on one machine and B &#38; D are on another machine. B is slave of A, C is slave of B, D is slave of C and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=132&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight:bold;">SETUP PROCEDURE</span><br />    Created 4 instances of mysql on 2 machines running on different ports. Lets call these instances A, B, C and D. So A &amp; C are on one machine and B &amp; D are on another machine. B is slave of A, C is slave of B, D is slave of C and A is slave of D.</p>
<p>    (origin) A &#8211;&gt; B &#8211;&gt; C &#8211;&gt; D &#8211;&gt; A (origin) </p>
<p>Each instance has its own serverid. A query originating from any machine will travel through the loop replicating data on all the machines are return back to the origniating server &#8211; which in effect will identify that the query had originated from here and would not execute/replicate the query further.</p>
<p>To handle auto_increment field, two variables are defined in the configuraion of the server.</p>
<p>1. auto_increment_increment : controls the increment between successive AUTO_INCREMENT values.</p>
<p>2. auto_increment_offset : determines the starting point of AUTO_INCREMENT columns.</p>
<p>Using these two variables, the auto generated values of auto_increment columns can be controlled.</p>
<p>Once the replication loop is up and running, any data inserted in any node would automatically propagate to all the other nodes.</p>
<p><span style="font-weight:bold;">ISSUES WITH MULTI-MASTER REPLICATION &amp; AUTOMATIC FAILOVER</span></p>
<p><span style="font-style:italic;">1. LATENCY</span></p>
<p>    There is a definite latency between the first node and the last node. The replication steps lead to the slave reading the master&#8217;s binary log through the network and writing it to its own relay-bin log. It then executes the query and then writes it to its own binary log. So each node takes a small amount of time to execute and then propagate the query further.</p>
<p>    For a 4 node multi-master replication when i replicated a single insert query containing one int and one varchar field, the time taken for data to reach the last node is 5 ms.<br />    This latency would ofcourse depend on the following factors<br />      a) amount of data to be relicated. Latency increases with increase in data<br />      b) Network speed between the nodes. If the data is to replicated over internet, it will take more time as compared to that on nodes in LAN<br />      c) Amount of indexes on the tables being replicated. As the number of indexes increase, the time taken to insert data in tables also increases. Increasig the latency.<br />      d) The hardware of the machine and the load on the machine will also determine how fast the replication between master and slave will take place. </p>
<p><span style="font-style:italic;">2. AUTOMATIC FAILOVER</span></p>
<p>     Automatic failover can be accomplished using events and federated tables in mysql 5.1. Federated tables are created between master and slave and are used to check connection between master and slave. An event is used to trigger a query on the federated table which checks the connection between master and slave. If the query fails, then a stored procedure can be created which should chunk the master out of the replication loop.</p>
<p>So suppose in the loop shown above, A goes out, then the event on B would detect that A is out and would make D as a master of B.</p>
<p>This is the theoretical implementation of automatic failover. Practically there are a few issues with its implementation.</p>
<p>a) for failover, you need to know the position of master&#8217;s master from where the slave should take over. (So B should know the position on D from where it has to start replication). One of the ways to do this is that each slave logs its master&#8217;s position on a table which is replicated throughout the loop. But this again is not possible using events &amp; stored procedures &#8211; cause there is no query which can capture the information available from &#8220;SHOW SLAVE STATUS&#8221; query in a variable and write it in a table. Another way to do this is to have an external script running at an interval of say 10 seconds which logs this information and checks the federated tables for any disruption in the master-slave connection. With this methodology, the problem is that there could be a 10 second window period during which data can be lost.</p>
<p>b) You could also land into an infinite replication situation. Lets look how using the 4 node example above. Suppose &#8220;A&#8221; goes down and It has a query in its binary log which has to be replicated throught the loop. So the query propagates from &#8220;B&#8221; to &#8220;C&#8221; and finally to &#8220;D&#8221;. Now since &#8220;A&#8221; is down and failover has happened, &#8220;B&#8221; would be the slave of &#8220;D&#8221;. So the query which originated from &#8220;A&#8221; would go from &#8220;D&#8221; to &#8220;B&#8221;. Thats because if &#8220;A&#8221; would have been there, it would have identified its own query and stopped it. But since &#8220;A&#8221; is out of the loop, the query will not be stopped and it will propagate to &#8220;B&#8221; and will always be in the loop. This can result in either the query running in the loop indefinitely or an error on all the slaves and all the slaves going down. </p>
<p>These are the major issues with multi-master replication and automatic failover. Though one can still live with the automatic failover scenario &#8211; as it might occur once in a while. But the latency between first and last node during replication has no solution. This latency is due to physical constraints and cannot be avoided.</p>
<p>A work around would be distributing the queries based on tables on all the nodes. So that queries for a table would always be served from a single node. But this then would result in table locks on that node and again we would not be able to reap the benefits of multi-master replication.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/132/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/132/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=132&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/05/11/mysql-multi-master-replication-act-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>Indian railways</title>
		<link>http://grepme2.wordpress.com/2007/05/07/indian-railways/</link>
		<comments>http://grepme2.wordpress.com/2007/05/07/indian-railways/#comments</comments>
		<pubDate>Mon, 07 May 2007 01:09:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/05/07/indian-railways/</guid>
		<description><![CDATA[It has been almost 27 years since I was born and since i had been traveling in the indian railways. But with increase in time the indian railways has become from bad to worse. It is actually an ordeal to travel in railways. Then why am i writing the post today and not before. Well, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=131&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It has been almost 27 years since I was born and since i had been traveling in the indian railways. But with increase in time the indian railways has become from bad to worse. It is actually an ordeal to travel in railways. Then why am i writing the post today and not before. Well, i actually realized it yesterday. </p>
<p>At indian railways, the trains are never expected to arrive on time. All trains run late. And if you are standing at one of the platforms, you will constantly hear &#8211; <span style="font-style:italic;">&#8220;train x which was supposed to come at time y is delayed by delta minutes/hours. <span style="font-weight:bold;">The inconvenience caused is deeply regretted</span>&#8220;</span>. And the announcer would never sound as if he/she was regretting anything. It is said in a matter-of-fact way &#8211; as if we are supposed to know that the delay was naturally expected &#8211; just like you expect corruption in each and every section of the government of like you expect to get ketchup free with your samosa.</p>
<p>Let me brief you as to what happened last night. Had been to the delhi station to put my mom on the train for baroda. First of all &#8211; it had been a long time since i had been to the railways. So i had to enquire about where the parking was. And very few people seemed to know where it was. And since there is no visible board giving directions &#8211; i had to run here and there to get the location of parking space.</p>
<p>Well next &#8211; get information about the platform where the train would arrive. And the only way to get this information is to stand in queue &#8211; after about 100 people and wait your turn. The uncleji at the enquiry window &#8211; does not give a shit about who is on the other side of the window. I had time to enquire &#8211; what about people who arrived late and need the info &#8211; can they wait in queue for 30 minutes to enquire about which platform they should go. It seems the situation in delhi was worse. Its better in baroda &#8211; where there is less crowd and the information is properly displayed on the general information board.</p>
<p>Now &#8211; since i know which platform i have to go, i will have to spend rs 3/- to get a platform ticket &#8211; so that any Ticket Checker cannot catch me and ask for a 50/- or 100/- <span style="font-style:italic;">ghoos</span> for travelling without a ticket. They usually do. There has been so many instances with my friends where the TC simply asked for a Rs 50/- note to let them go. And the way to avoid this hassle is to get a platform ticket. And to get a platform ticket is another hassle. On new delhi station, it is really difficult first  to locate the window which gives platform ticket. Officially platform ticket should be available on all windows. But it seems due to scarcity &#8211; its there only on one window. And the queue in front of the window is huge. Hmm, there are always queues at all windows on indian railway stations. It seems that the indian railways is very low on manpower. Well actually thats how Laalu prasad yadav &#8211; our respected railway minister brought the operating cost of Indian railways to 78% &#8211; the best in the world.</p>
<p>And after getting the platform ticket, we proceeded to the platform. Wow, what a place. It seems that people like to live on the platform. Everywhere &#8211; there are people sitting, chatting, boozing, gambling. You have to look for space to put your foot to move forward. I think, this is what they mean by population explosion.</p>
<p>What happens in baroda station is that there is a display on the platform which says where each coach will come for the train. So it becomes easy to move and get placed right in front of the coach. But in Delhi &#8211; the capital of india, the numbers on the boards are misplaced so that you have to drag your luggage and run in between the crowded platform to your bogie.</p>
<p>And then the trains are always crowded. It is difficult to get a ticket in a train in indian railways. There is always a waiting list and extra people on the train for whom it is important to reach their destination, but were unable to get a reservation. There are people sleeping on the floor, outside the loo and sitting on your berths.</p>
<p>60 years of independence, and indian railways &#8211; it seems &#8211; stays where it was.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/131/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/131/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=131&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/05/07/indian-railways/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>ctrl C &amp; ctrl V</title>
		<link>http://grepme2.wordpress.com/2007/05/04/ctrl-c-ctrl-v/</link>
		<comments>http://grepme2.wordpress.com/2007/05/04/ctrl-c-ctrl-v/#comments</comments>
		<pubDate>Fri, 04 May 2007 09:37:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/05/04/ctrl-c-ctrl-v/</guid>
		<description><![CDATA[Your Colleague: Hey!! Kya yahan baitha mail forward karta rahta hai yaar!! Naye packages dekh&#8230;. Naye language seekh, Night out Maar&#8230;.Fundoo programming kar like me&#8230;.! Do something cool man!! You: Achha! To usse Kya hoga&#8230; You &#8216;re Colleague: Impression!! ! Appraisal!!! Har appraisal main tu No 1! Hike in salary!! Extra Stocks You: Phir kya [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=130&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Your Colleague: Hey!! Kya yahan baitha mail forward karta rahta hai yaar!! Naye packages dekh&#8230;. Naye language seekh, Night out Maar&#8230;.Fundoo programming kar like me&#8230;.! Do something cool man!!</p>
<p>You: Achha! To usse Kya hoga&#8230;</p>
<p>You &#8216;re Colleague: Impression!! ! Appraisal!!! Har appraisal main tu No 1! Hike in salary!! Extra Stocks</p>
<p>You: Phir kya hoga&#8230;</p>
<p>Your Colleague: Project Leader ban jaayega..Phir Project Manager!!! Phir Business Manager! One day U will be a Director of the Company man !!</p>
<p>You: Acchha to phir kya hoga&#8230;</p>
<p>Your Colleague: Abe phir tu aish karega! Koi kaam nahin karna padega! Araam se office aayega aur MAIL check karega.</p>
<p>You: To ab main kya kar raha hoon????</p>
<p>&#8220;Dikhawe pe na jao, apni akal lagao.</p>
<p>Programming hai waste, trust only copy-paste &#8220;</p>
<p>Powered by ctrl C</p>
<p>Driven by ctrl V</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/130/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/130/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=130&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/05/04/ctrl-c-ctrl-v/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
		<item>
		<title>philosophy</title>
		<link>http://grepme2.wordpress.com/2007/04/28/philosophy/</link>
		<comments>http://grepme2.wordpress.com/2007/04/28/philosophy/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 05:04:00 +0000</pubDate>
		<dc:creator>grepme2</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://grepme2.wordpress.com/2007/04/28/philosophy/</guid>
		<description><![CDATA[I would say that the root cause of all misunderstandings is expectations. It is human nature to expect more than what he is getting now. Either you are not satisfied with your job profile or your salary or your organizations work culture. You expect them to get better. And once they get better, you expect [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=129&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I would say that the root cause of all misunderstandings is expectations. It is human nature to expect more than what he is getting now. Either you are not satisfied with your job profile or your salary or your organizations work culture. You expect them to get better. And once they get better, you expect them to get even better. There is no end to the amount of expectations. </p>
<p>It is same in relationships, you expect that your close ones grow up in life. That your wife takes care of you. And your wife would expect you to take care of her, of her emotions, of her will. You expect that your wife or your hubby has great personality in front of others. That others say that you two are a nice couple. You expect that you both listen to each other and respect each other. Etc.. Etc..</p>
<p>The expectations never end, and so neither does the issues or misunderstandings that come out of it. </p>
<p>And the best and simplest way to get out of this is &#8220;<span style="font-style:italic;">not to expect</span>&#8220;. Wow, you would say &#8211; how is that possible. How can you not expect. How can you let go of your emotions. How can you say that &#8220;let things be as it is&#8221;.</p>
<p>It is the biggest thing to ask. But that is what the monks do. They just let go of their emotions. Lead a life where they dont care for anything. They meditate. Live with the bare minimum. And they are happy most of the times.</p>
<p>I dont know whether they believe in GOD or not. I dont. How can you believe something that you have not seen, not felt, not heard. Do you believe your friend if he says something odd. I wont. I will have to look at it to believe it. Oh, what would you say if i tell you that i met GOD yesterday. Would you believe me? No way&#8230; I think it is the same thing. People say that there is GOD, but where??</p>
<p>And then there is love. I think, i have written about it before. A feeling that cannot be defined. How can you expect something from someone you love. That is not love. That is possessiveness. You dont have expectations in love. All you intend is to give to the one you love. You take care of him/her. You forget and forgive all his/her mistakes. You want that person to be healthy. In all if you love someone, you would expect that person to be happy. And would do anything to make him/her happy. That i think is love.</p>
<p>So expectations dont come in between GOD(whom i dont believe in) and love. But in this materialistic world &#8211; you have to eat, you have to drink, and you have to live. And you have some materialistic/physical and emotional needs. And this is where expectations come in picture and they ruin everything. </p>
<p>Whenever you expect something from someone &#8211; you open a path to misunderstandings and issues. </p>
<p>Eventually everyone who is born has to die. Then why not make this miserable life happy for others and for self.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/grepme2.wordpress.com/129/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/grepme2.wordpress.com/129/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/grepme2.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/grepme2.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/grepme2.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=grepme2.wordpress.com&amp;blog=1353540&amp;post=129&amp;subd=grepme2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://grepme2.wordpress.com/2007/04/28/philosophy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fbc9e5045e0f91719828520da6d0788?s=96&#38;d=identicon" medium="image">
			<media:title type="html">grepme2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
