Author: cutting
Date: Thu Jul 28 13:08:10 2005
New Revision: 225864

URL: http://svn.apache.org/viewcvs?rev=225864&view=rev
Log:
Add buffer-level write to NDFSOutputStream.

Modified:
    lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java

Modified: 
lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java
URL: 
http://svn.apache.org/viewcvs/lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java?rev=225864&r1=225863&r2=225864&view=diff
==============================================================================
--- lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java 
(original)
+++ lucene/nutch/branches/mapred/src/java/org/apache/nutch/ndfs/NDFSClient.java 
Thu Jul 28 13:08:10 2005
@@ -719,7 +719,6 @@
                        
         /**
          * Writes the specified byte to this output stream.
-         * This is the only write method that needs to be implemented.
          */
         public synchronized void write(int b) throws IOException {
             if (closed) {
@@ -732,6 +731,29 @@
             }
             outBuf[pos++] = (byte) b;
             filePos++;
+        }
+
+        /**
+         * Writes the specified bytes to this output stream.
+         */
+      public synchronized void write(byte b[], int off, int len)
+        throws IOException {
+            if (closed) {
+                throw new IOException("Stream closed");
+            }
+            while (len > 0) {
+              int remaining = BUFFER_SIZE - pos;
+              int toWrite = Math.min(remaining, len);
+              System.arraycopy(b, off, outBuf, pos, toWrite);
+              pos += toWrite;
+              off += toWrite;
+              len -= toWrite;
+
+              if ((bytesWrittenToBlock + pos >= BLOCK_SIZE) ||
+                  (pos == BUFFER_SIZE)) {
+                flush();
+              }
+            }
         }
 
         /**


Reply via email to