Author: jmhodges
Date: Tue Jun  1 03:37:29 2010
New Revision: 949917

URL: http://svn.apache.org/viewvc?rev=949917&view=rev
Log:
AVRO-554 Fixing syncing in ruby data file writing.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/ruby/lib/avro/data_file.rb
    avro/trunk/lang/ruby/test/test_datafile.rb

Modified: avro/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=949917&r1=949916&r2=949917&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Jun  1 03:37:29 2010
@@ -73,7 +73,10 @@ Avro 1.4.0 (unreleased)
 
     AVR0-555 Missing license headers in some ruby source
     files. (jmhodges)
- 
+
+    AVRO-554 Fixing syncing in ruby data file writing. (Grant Rodgers
+    via jmhodges)
+
 Avro 1.3.3 (Unreleased)
 
 Avro 1.3.2 (31 March 2010)

Modified: avro/trunk/lang/ruby/lib/avro/data_file.rb
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/data_file.rb?rev=949917&r1=949916&r2=949917&view=diff
==============================================================================
--- avro/trunk/lang/ruby/lib/avro/data_file.rb (original)
+++ avro/trunk/lang/ruby/lib/avro/data_file.rb Tue Jun  1 03:37:29 2010
@@ -173,6 +173,7 @@ module Avro
 
           # reset buffer
           buffer_writer.truncate(0)
+          buffer_writer.rewind
           self.block_count = 0
         end
       end

Modified: avro/trunk/lang/ruby/test/test_datafile.rb
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/ruby/test/test_datafile.rb?rev=949917&r1=949916&r2=949917&view=diff
==============================================================================
--- avro/trunk/lang/ruby/test/test_datafile.rb (original)
+++ avro/trunk/lang/ruby/test/test_datafile.rb Tue Jun  1 03:37:29 2010
@@ -118,4 +118,26 @@ JSON
       end
     end
   end
+
+  def test_data_writer_handles_sync_interval
+    writer_schema = <<-JSON
+{ "type": "record",
+  "name": "something",
+  "fields": [
+    {"name": "something_boolean", "type": "boolean"}
+]}
+JSON
+
+    data = {"something_boolean" => true }
+
+    Avro::DataFile.open('data.avr', 'w', writer_schema) do |dw|
+      while dw.writer.tell < Avro::DataFile::SYNC_INTERVAL
+        dw << data
+      end
+      block_count = dw.block_count
+      dw << data
+      # ensure we didn't just write another block
+      assert_equal(block_count+1, dw.block_count)
+    end
+  end
 end


Reply via email to