beagle r4515 - in branches/beagle-lucene2_1/beagled/Lucene.Net: Analysis/Standard upstream-changes



Author: dbera
Date: Fri Feb 22 00:23:23 2008
New Revision: 4515
URL: http://svn.gnome.org/viewvc/beagle?rev=4515&view=rev

Log:
Add old patch 11_charstream-no-exceptions.patch


Added:
   branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/06_charstream-no-exceptions.patch
Modified:
   branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/CharStream.cs
   branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/FastCharStream.cs
   branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/StandardTokenizerTokenManager.cs

Modified: branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/CharStream.cs
==============================================================================
--- branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/CharStream.cs	(original)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/CharStream.cs	Fri Feb 22 00:23:23 2008
@@ -41,7 +41,7 @@
         /// of selecting the input is the responsibility of the class
         /// implementing this interface.  Can throw any java.io.IOException.
         /// </summary>
-        char ReadChar();
+        int ReadChar();
 		
         /// <summary> Returns the column position of the character last read.</summary>
         /// <deprecated> 
@@ -88,7 +88,7 @@
         /// All characters must remain in the buffer between two successive calls
         /// to this method to implement backup correctly.
         /// </summary>
-        char BeginToken();
+        int BeginToken();
 		
         /// <summary> Returns a string made up of characters from the marked token beginning 
         /// to the current buffer position. Implementations have the choice of returning
@@ -116,4 +116,4 @@
         /// </summary>
         void  Done();
     }
-}
\ No newline at end of file
+}

Modified: branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/FastCharStream.cs
==============================================================================
--- branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/FastCharStream.cs	(original)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/FastCharStream.cs	Fri Feb 22 00:23:23 2008
@@ -42,14 +42,15 @@
             input = r;
         }
 		
-        public char ReadChar()
+        public int ReadChar()
         {
             if (bufferPosition >= bufferLength)
-                Refill();
+		if (!Refill())
+			return -1;
             return buffer[bufferPosition++];
         }
 		
-        private void  Refill()
+        private bool  Refill()
         {
             int newPosition = bufferLength - tokenStart;
 			
@@ -82,12 +83,13 @@
 			
             int charsRead = input.Read(buffer, newPosition, buffer.Length - newPosition);
             if (charsRead <= 0)
-                throw new System.IO.IOException("read past eof");
-            else
-                bufferLength += charsRead;
+		return false;
+
+            bufferLength += charsRead;
+	    return true;
         }
 		
-        public char BeginToken()
+        public int BeginToken()
         {
             tokenStart = bufferPosition;
             return ReadChar();
@@ -147,4 +149,4 @@
             return 1;
         }
     }
-}
\ No newline at end of file
+}

Modified: branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/StandardTokenizerTokenManager.cs
==============================================================================
--- branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/StandardTokenizerTokenManager.cs	(original)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/Analysis/Standard/StandardTokenizerTokenManager.cs	Fri Feb 22 00:23:23 2008
@@ -1183,14 +1183,11 @@
 				++curPos;
 				if ((i = jjnewStateCnt) == (startsAt = 75 - (jjnewStateCnt = startsAt)))
 					return curPos;
-				try
-				{
-					curChar = input_stream.ReadChar();
-				}
-				catch (System.IO.IOException)
-				{
+    				int ret = input_stream.ReadChar();
+    				if (ret != -1)
+    					curChar = (char) ret;
+    				else
 					return curPos;
-				}
 			}
 		}
 		internal static readonly int[] jjnextStates = new int[]{30, 31, 32, 34, 38, 39, 41, 42, 46, 47, 53, 54, 5, 6, 10, 11, 19, 20, 3, 4, 8, 9, 17, 18, 31, 32, 34, 32, 33, 34, 65, 66, 68, 69, 72, 73, 5, 6, 19, 20, 25, 26, 50, 51, 70, 71, 12, 13, 14, 15, 23, 24, 43, 44, 48, 49, 55, 56, 59, 60, 61, 62};
@@ -1378,11 +1375,11 @@
 			
 			for (; ; )
 			{
-				try
-				{
-					curChar = input_stream.BeginToken();
-				}
-				catch (System.IO.IOException)
+				
+				int ret = input_stream.BeginToken();
+				if (ret != -1)
+					curChar = (char) ret;
+				else
 				{
 					jjmatchedKind = 0;
 					matchedToken = JjFillToken();
@@ -1414,11 +1411,7 @@
 				int error_column = input_stream.GetEndColumn();
 				System.String error_after = null;
 				bool EOFSeen = false;
-				try
-				{
-					input_stream.ReadChar(); input_stream.Backup(1);
-				}
-				catch (System.IO.IOException)
+				if (input_stream.ReadChar() == -1)
 				{
 					EOFSeen = true;
 					error_after = curPos <= 1?"":input_stream.GetImage();
@@ -1430,6 +1423,9 @@
 					else
 						error_column++;
 				}
+				else
+					input_stream.Backup(1);
+
 				if (!EOFSeen)
 				{
 					input_stream.Backup(1);
@@ -1441,4 +1437,4 @@
 			}
 		}
 	}
-}
\ No newline at end of file
+}

Added: branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/06_charstream-no-exceptions.patch
==============================================================================
--- (empty file)
+++ branches/beagle-lucene2_1/beagled/Lucene.Net/upstream-changes/06_charstream-no-exceptions.patch	Fri Feb 22 00:23:23 2008
@@ -0,0 +1,154 @@
+From: Daniel Drake <dsd gentoo org>
+
+Tracing shows that the exception thrown inside Refill() is thrown hundreds of
+times when indexing a small amount of files.
+
+Reduce overhead by removing exceptions from handling of this particular error.
+
+Index: Analysis/Standard/FastCharStream.cs
+===================================================================
+--- Analysis/Standard/FastCharStream.cs	(revision 4506)
++++ Analysis/Standard/FastCharStream.cs	(working copy)
+@@ -42,14 +42,15 @@
+             input = r;
+         }
+ 		
+-        public char ReadChar()
++        public int ReadChar()
+         {
+             if (bufferPosition >= bufferLength)
+-                Refill();
++		if (!Refill())
++			return -1;
+             return buffer[bufferPosition++];
+         }
+ 		
+-        private void  Refill()
++        private bool  Refill()
+         {
+             int newPosition = bufferLength - tokenStart;
+ 			
+@@ -82,12 +83,13 @@
+ 			
+             int charsRead = input.Read(buffer, newPosition, buffer.Length - newPosition);
+             if (charsRead <= 0)
+-                throw new System.IO.IOException("read past eof");
+-            else
+-                bufferLength += charsRead;
++		return false;
++
++            bufferLength += charsRead;
++	    return true;
+         }
+ 		
+-        public char BeginToken()
++        public int BeginToken()
+         {
+             tokenStart = bufferPosition;
+             return ReadChar();
+@@ -147,4 +149,4 @@
+             return 1;
+         }
+     }
+-}
+\ No newline at end of file
++}
+Index: Analysis/Standard/StandardTokenizerTokenManager.cs
+===================================================================
+--- Analysis/Standard/StandardTokenizerTokenManager.cs	(revision 4506)
++++ Analysis/Standard/StandardTokenizerTokenManager.cs	(working copy)
+@@ -1183,14 +1183,11 @@
+ 				++curPos;
+ 				if ((i = jjnewStateCnt) == (startsAt = 75 - (jjnewStateCnt = startsAt)))
+ 					return curPos;
+-				try
+-				{
+-					curChar = input_stream.ReadChar();
+-				}
+-				catch (System.IO.IOException)
+-				{
++    				int ret = input_stream.ReadChar();
++    				if (ret != -1)
++    					curChar = (char) ret;
++    				else
+ 					return curPos;
+-				}
+ 			}
+ 		}
+ 		internal static readonly int[] jjnextStates = new int[]{30, 31, 32, 34, 38, 39, 41, 42, 46, 47, 53, 54, 5, 6, 10, 11, 19, 20, 3, 4, 8, 9, 17, 18, 31, 32, 34, 32, 33, 34, 65, 66, 68, 69, 72, 73, 5, 6, 19, 20, 25, 26, 50, 51, 70, 71, 12, 13, 14, 15, 23, 24, 43, 44, 48, 49, 55, 56, 59, 60, 61, 62};
+@@ -1378,11 +1375,11 @@
+ 			
+ 			for (; ; )
+ 			{
+-				try
+-				{
+-					curChar = input_stream.BeginToken();
+-				}
+-				catch (System.IO.IOException)
++				
++				int ret = input_stream.BeginToken();
++				if (ret != -1)
++					curChar = (char) ret;
++				else
+ 				{
+ 					jjmatchedKind = 0;
+ 					matchedToken = JjFillToken();
+@@ -1414,11 +1411,7 @@
+ 				int error_column = input_stream.GetEndColumn();
+ 				System.String error_after = null;
+ 				bool EOFSeen = false;
+-				try
+-				{
+-					input_stream.ReadChar(); input_stream.Backup(1);
+-				}
+-				catch (System.IO.IOException)
++				if (input_stream.ReadChar() == -1)
+ 				{
+ 					EOFSeen = true;
+ 					error_after = curPos <= 1?"":input_stream.GetImage();
+@@ -1430,6 +1423,9 @@
+ 					else
+ 						error_column++;
+ 				}
++				else
++					input_stream.Backup(1);
++
+ 				if (!EOFSeen)
+ 				{
+ 					input_stream.Backup(1);
+@@ -1441,4 +1437,4 @@
+ 			}
+ 		}
+ 	}
+-}
+\ No newline at end of file
++}
+Index: Analysis/Standard/CharStream.cs
+===================================================================
+--- Analysis/Standard/CharStream.cs	(revision 4506)
++++ Analysis/Standard/CharStream.cs	(working copy)
+@@ -41,7 +41,7 @@
+         /// of selecting the input is the responsibility of the class
+         /// implementing this interface.  Can throw any java.io.IOException.
+         /// </summary>
+-        char ReadChar();
++        int ReadChar();
+ 		
+         /// <summary> Returns the column position of the character last read.</summary>
+         /// <deprecated> 
+@@ -88,7 +88,7 @@
+         /// All characters must remain in the buffer between two successive calls
+         /// to this method to implement backup correctly.
+         /// </summary>
+-        char BeginToken();
++        int BeginToken();
+ 		
+         /// <summary> Returns a string made up of characters from the marked token beginning 
+         /// to the current buffer position. Implementations have the choice of returning
+@@ -116,4 +116,4 @@
+         /// </summary>
+         void  Done();
+     }
+-}
+\ No newline at end of file
++}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]