[ARVADOS] updated: f5638851ddb5a859a54a16fe963ee98591af17a9

Git user git at public.curoverse.com
Tue Apr 18 23:01:36 EDT 2017


Summary of changes:
 sdk/python/arvados/_ranges.py    |  6 +++---
 sdk/python/tests/test_arvfile.py | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

       via  f5638851ddb5a859a54a16fe963ee98591af17a9 (commit)
      from  04951581a941697d68cdaf9af6661c3c412f1bce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f5638851ddb5a859a54a16fe963ee98591af17a9
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Apr 18 17:54:57 2017 -0400

    11510: Fix longstanding bug in replace_range() when appending data from a
    buffer that was written out of order.

diff --git a/sdk/python/arvados/_ranges.py b/sdk/python/arvados/_ranges.py
index 8387416..5532ea0 100644
--- a/sdk/python/arvados/_ranges.py
+++ b/sdk/python/arvados/_ranges.py
@@ -109,7 +109,7 @@ def locators_and_ranges(data_locators, range_start, range_size, limit=None):
         block_size = dl.range_size
         block_end = block_start + block_size
         _logger.log(RANGES_SPAM,
-            "%s range_start %s block_start %s range_end %s block_end %s",
+            "L&R %s range_start %s block_start %s range_end %s block_end %s",
             dl.locator, range_start, block_start, range_end, block_end)
         if range_end <= block_start:
             # range ends before this block starts, so don't look at any more locators
@@ -165,7 +165,7 @@ def replace_range(data_locators, new_range_start, new_range_size, new_locator, n
 
     last = data_locators[-1]
     if (last.range_start+last.range_size) == new_range_start:
-        if last.locator == new_locator:
+        if last.locator == new_locator and (last.segment_offset+last.range_size) == new_segment_offset:
             # extend last segment
             last.range_size += new_range_size
         else:
@@ -183,7 +183,7 @@ def replace_range(data_locators, new_range_start, new_range_size, new_locator, n
         old_segment_start = dl.range_start
         old_segment_end = old_segment_start + dl.range_size
         _logger.log(RANGES_SPAM,
-            "%s range_start %s segment_start %s range_end %s segment_end %s",
+            "RR %s range_start %s segment_start %s range_end %s segment_end %s",
             dl, new_range_start, old_segment_start, new_range_end,
             old_segment_end)
         if new_range_end <= old_segment_start:
diff --git a/sdk/python/tests/test_arvfile.py b/sdk/python/tests/test_arvfile.py
index 95106a7..1a2c034 100644
--- a/sdk/python/tests/test_arvfile.py
+++ b/sdk/python/tests/test_arvfile.py
@@ -330,6 +330,23 @@ class ArvadosFileWriterTestCase(unittest.TestCase):
 
             self.assertEqual(c.manifest_text(), ". 7f614da9329cd3aebf59b91aadc30bf0+67108864 781e5e245d69b566979b86e28d23f2c7+10 0:67108864:count.txt 0:67108864:count.txt 0:2:count.txt 67108864:10:count.txt\n")
 
+
+    def test_sparse_write3(self):
+        keep = ArvadosFileWriterTestCase.MockKeep({})
+        api = ArvadosFileWriterTestCase.MockApi({}, {})
+        for r in [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [3, 2, 0, 4, 1]]:
+            with Collection() as c:
+                writer = c.open("count.txt", "r+")
+                self.assertEqual(writer.size(), 0)
+
+                for i in r:
+                    w = ("%s" % i) * 10
+                    writer.seek(i*10)
+                    writer.write(w)
+                writer.seek(0)
+                self.assertEqual(writer.read(), "00000000001111111111222222222233333333334444444444")
+
+
     def test_rewrite_on_empty_file(self):
         keep = ArvadosFileWriterTestCase.MockKeep({})
         with Collection('. ' + arvados.config.EMPTY_BLOCK_LOCATOR + ' 0:0:count.txt',

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list