Author: kathleen
Date: Wed May  9 22:38:55 2012
New Revision: 1336434

URL: http://svn.apache.org/viewvc?rev=1336434&view=rev
Log:
SQOOP-482. Import tool for mysql direct mode reports wrong
record number
(Nemon Lou via Kathleen Ting)

Modified:
    sqoop/trunk/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java

Modified: sqoop/trunk/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java
URL: 
http://svn.apache.org/viewvc/sqoop/trunk/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java?rev=1336434&r1=1336433&r2=1336434&view=diff
==============================================================================
--- sqoop/trunk/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java 
(original)
+++ sqoop/trunk/src/java/org/apache/sqoop/mapreduce/MySQLDumpMapper.java Wed 
May  9 22:38:55 2012
@@ -121,9 +121,8 @@ public class MySQLDumpMapper
             // chop off the leading and trailing text as we write the
             // output to HDFS.
             int len = inLine.length() - 2 - preambleLen;
-            context.write(inLine.substring(preambleLen, inLine.length() - 2),
-                null);
-            context.write("\n", null);
+            context.write(inLine.substring(preambleLen, inLine.length() - 2)
+                + "\n", null);
             counters.addBytes(1 + len);
           }
         } catch (IOException ioe) {
@@ -273,21 +272,23 @@ public class MySQLDumpMapper
             // For all of the output fields, emit them using the delimiters
             // the user chooses.
             boolean first = true;
+            StringBuilder sb = new StringBuilder();
             int recordLen = 1; // for the delimiter.
             for (String field : fields) {
               if (!first) {
-                context.write(outputFieldDelimStr, null);
+                sb.append(outputFieldDelimStr);
               } else {
                 first = false;
               }
 
               String fieldStr = FieldFormatter.escapeAndEnclose(field,
                   delimiters);
-              context.write(fieldStr, null);
+              sb.append(fieldStr);
               recordLen += fieldStr.length();
             }
 
-            context.write(outputRecordDelimStr, null);
+            sb.append(outputRecordDelimStr);
+            context.write(sb.toString(), null);
             counters.addBytes(recordLen);
           }
         } catch (IOException ioe) {


Reply via email to