You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by gb...@apache.org on 2005/05/21 14:35:20 UTC

svn commit: r171207 - in /incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper: MappedStatements/MappedStatement.cs TypeHandlers/ByteArrayTypeHandler.cs

Author: gbayon
Date: Sat May 21 05:35:19 2005
New Revision: 171207

URL: http://svn.apache.org/viewcvs?rev=171207&view=rev
Log:
- Redo ByteArrayTypeHandler

Modified:
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
    incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs?rev=171207&r1=171206&r2=171207&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/MappedStatements/MappedStatement.cs Sat May 21 05:35:19 2005
@@ -1043,8 +1043,6 @@
 						}
 						else
 						{
-							//IDalSession session = new SqlMapSession(_sqlMap.DataSource);
-
 							if (mapping.PropertyInfo.PropertyType == typeof(IList))
 							{
 								postSelect.Method = ExecuteMethod.ExecuteQueryForIList;

Modified: incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs
URL: http://svn.apache.org/viewcvs/incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs?rev=171207&r1=171206&r2=171207&view=diff
==============================================================================
--- incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs (original)
+++ incubator/ibatis/trunk/cs/mapper/IBatisNet.DataMapper/TypeHandlers/ByteArrayTypeHandler.cs Sat May 21 05:35:19 2005
@@ -79,37 +79,16 @@
 
 		private byte[] GetValueByIndex(int columnIndex, IDataReader dataReader) 
 		{
-			int bufferSize = 100;                  // Size of the BLOB buffer.
-			byte[] buffer = new byte[bufferSize];  // The BLOB byte[] buffer to be filled by GetBytes.
-			long size = bufferSize;                // The bytes returned from GetBytes.
-			long startIndex = 0;                   //  The data position in the BLOB output.
-			MemoryStream stream = null;                   // Writes the BLOB to a memory stream.
+			// determine the buffer size
+			int bufferLength = (int) dataReader.GetBytes(columnIndex, 0, null, 0, 0);
 
-			// Create a memory stream to hold the output.
-			stream = new MemoryStream();
+			// initialize it
+			byte[] byteArray = new byte[bufferLength];
 
-			// Reset the starting byte for the new BLOB.
-			startIndex  = 0;
+			// fill it
+			dataReader.GetBytes(columnIndex, 0, byteArray, 0, bufferLength);
 
-			// Read the bytes into outbyte[] and retain the number of bytes returned.
-			size  = dataReader.GetBytes(columnIndex, startIndex , buffer, 0, bufferSize);
-
-			// Continue reading and writing while there are bytes beyond the size of the buffer.
-			while (size  == bufferSize)
-			{
-				stream.Write(buffer, 0, (int)size);
-				stream.Flush();
-
-				// Reposition the start index to the end of the last buffer and fill the buffer.
-				startIndex += bufferSize;
-				size  = dataReader.GetBytes(columnIndex, startIndex, buffer, 0, bufferSize);
-			}
-
-			// Write the remaining buffer.
-			stream.Write(buffer, 0, (int)size);
-			stream.Flush();
-
-			return stream.ToArray();
+			return byteArray;
 		}