arvados 1.4.1.20190320201707 → 1.4.1.20191121213920

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arvados/collection.rb +37 -41
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5c627de4e61d0b46d034ef9a814238d1fd6198b
4
- data.tar.gz: 325647e0d43f4a918608690f692daf92a128eeb9
3
+ metadata.gz: 15d77091d345a4654eddc8ae00a34ddf693b42fb
4
+ data.tar.gz: 978f05f368380307ee5152edbb23c224791d0b4c
5
5
  SHA512:
6
- metadata.gz: 754a5404e63fe56e2f1a3904e06f9e96c8ae28bb7a368078390d2b4aacaed4b4343f69b96fb2f25c1b7ceaeb115e161f19948933bf1d406224d01b1c86b46d87
7
- data.tar.gz: 56b475fce081fd8f42fa387043cc20a408482a359235c1a8393aa7aea36333c90a5dcc9d8acca7d8c4f724aba89217709ec75f5cfee7b9e8517a7f6a560b9ab2
6
+ metadata.gz: d7f48920c909fd7806db28313977002ccc75dece4ee97e9fdf8971387e9472ba8d7391cbc40e3dd84ec3d2ac5904938af09342130cda756f18fbbf4a0927aac2
7
+ data.tar.gz: 7ee63c14697c6276fd6d33ff982b552e869e4459dbe702173324911b7892dc352aa079d658effcd58810ebdc058ae136b008c2d5073314a9c651db5f1ccaa895
@@ -207,7 +207,7 @@ module Arv
207
207
  loop do
208
208
  ii = (lo + hi) / 2
209
209
  range = @ranges[ii]
210
- if range.include?(target)
210
+ if range.include?(target) && (target < range.end || ii == hi-1)
211
211
  return ii
212
212
  elsif ii == lo
213
213
  raise RangeError.new("%i not in segment" % target)
@@ -481,14 +481,13 @@ module Arv
481
481
 
482
482
  def initialize(name)
483
483
  @name = name
484
- @loc_ranges = {}
484
+ @loc_ranges = []
485
485
  @loc_range_start = 0
486
486
  @file_specs = []
487
487
  end
488
488
 
489
489
  def add_file(coll_file)
490
490
  coll_file.each_segment do |segment|
491
- extend_locator_ranges(segment.locators)
492
491
  extend_file_specs(coll_file.name, segment)
493
492
  end
494
493
  end
@@ -498,48 +497,51 @@ module Arv
498
497
  ""
499
498
  else
500
499
  "%s %s %s\n" % [escape_name(@name),
501
- @loc_ranges.keys.join(" "),
500
+ @loc_ranges.collect(&:locator).join(" "),
502
501
  @file_specs.join(" ")]
503
502
  end
504
503
  end
505
504
 
506
505
  private
507
506
 
508
- def extend_locator_ranges(locators)
509
- locators.
510
- select { |loc_s| not @loc_ranges.include?(loc_s) }.
511
- each do |loc_s|
512
- @loc_ranges[loc_s] = LocatorRange.new(loc_s, @loc_range_start)
513
- @loc_range_start = @loc_ranges[loc_s].end
507
+ def extend_file_specs(filename, segment)
508
+ found_overlap = false
509
+ # Find the longest prefix of segment.locators that's a suffix
510
+ # of the existing @loc_ranges. If we find one, drop those
511
+ # locators (they'll be added back below, when we're handling
512
+ # the normal/no-overlap case).
513
+ (1..segment.locators.length).each do |overlap|
514
+ if @loc_ranges.length >= overlap && @loc_ranges[-overlap..-1].collect(&:locator) == segment.locators[0..overlap-1]
515
+ (1..overlap).each do
516
+ discarded = @loc_ranges.pop
517
+ @loc_range_start -= (discarded.end - discarded.begin)
518
+ end
519
+ found_overlap = true
520
+ break
521
+ end
514
522
  end
515
- end
516
523
 
517
- def extend_file_specs(filename, segment)
518
- # Given a filename and a LocatorSegment, add the smallest
519
- # possible array of file spec strings to @file_specs that
520
- # builds the file from available locators.
521
- filename = escape_name(filename)
522
- start_pos = segment.start_pos
523
- length = segment.length
524
- start_loc = segment.locators.first
525
- prev_loc = start_loc
526
- # Build a list of file specs by iterating through the segment's
527
- # locators and preparing a file spec for each contiguous range.
528
- segment.locators[1..-1].each do |loc_s|
529
- range = @loc_ranges[loc_s]
530
- if range.begin != @loc_ranges[prev_loc].end
531
- range_start, range_length =
532
- start_and_length_at(start_loc, prev_loc, start_pos, length)
533
- @file_specs << "#{range_start}:#{range_length}:#{filename}"
534
- start_pos = 0
535
- length -= range_length
536
- start_loc = loc_s
524
+ # If there was no overlap at the end of our existing
525
+ # @loc_ranges, check whether the full set of segment.locators
526
+ # appears earlier in @loc_ranges. If so, use those instead of
527
+ # appending the same locators again.
528
+ if !found_overlap && segment.locators.length < @loc_ranges.length
529
+ segment_start = 0
530
+ (0..@loc_ranges.length-1).each do |ri|
531
+ if @loc_ranges[ri..ri+segment.locators.length-1].collect(&:locator) == segment.locators
532
+ @file_specs << "#{segment.start_pos + @loc_ranges[ri].begin}:#{segment.length}:#{escape_name(filename)}"
533
+ return
534
+ end
537
535
  end
538
- prev_loc = loc_s
539
536
  end
540
- range_start, range_length =
541
- start_and_length_at(start_loc, prev_loc, start_pos, length)
542
- @file_specs << "#{range_start}:#{range_length}:#{filename}"
537
+
538
+ segment_start = @loc_range_start
539
+ segment.locators.each do |loc_s|
540
+ r = LocatorRange.new(loc_s, @loc_range_start)
541
+ @loc_ranges << r
542
+ @loc_range_start = r.end
543
+ end
544
+ @file_specs << "#{segment.start_pos + segment_start}:#{segment.length}:#{escape_name(filename)}"
543
545
  end
544
546
 
545
547
  def escape_name(name)
@@ -547,12 +549,6 @@ module Arv
547
549
  s.each_byte.map { |c| "\\%03o" % c }.join("")
548
550
  end
549
551
  end
550
-
551
- def start_and_length_at(start_key, end_key, start_pos, length)
552
- range_begin = @loc_ranges[start_key].begin + start_pos
553
- range_length = [@loc_ranges[end_key].end - range_begin, length].min
554
- [range_begin, range_length]
555
- end
556
552
  end
557
553
  end
558
554
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvados
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1.20190320201707
4
+ version: 1.4.1.20191121213920
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvados Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -98,6 +98,20 @@ dependencies:
98
98
  - - "<"
99
99
  - !ruby/object:Gem::Version
100
100
  version: '3'
101
+ - !ruby/object:Gem::Dependency
102
+ name: faraday
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "<"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.16'
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: '0.16'
101
115
  - !ruby/object:Gem::Dependency
102
116
  name: jwt
103
117
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +132,7 @@ dependencies:
118
132
  - - ">="
119
133
  - !ruby/object:Gem::Version
120
134
  version: 0.1.5
121
- description: Arvados client library, git commit a07891c7ac7e90ebdf35ae1812ec03c818fe2a67
135
+ description: Arvados client library, git commit 40eb23ae00935f93310051e659201f9f7738c0a0
122
136
  email: gem-dev@curoverse.com
123
137
  executables: []
124
138
  extensions: []