Class: PartitionGardener::Layout::IntegerWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/partition_gardener/layout/integer_window.rb

Constant Summary collapse

DEFAULT_ACTIVE_ID_WIDTH =
Strategy::IntegerRange::DEFAULT_ACTIVE_ID_WIDTH

Class Method Summary collapse

Class Method Details

.active_end(active_start:, active_id_width: DEFAULT_ACTIVE_ID_WIDTH) ⇒ Object



7
8
9
# File 'lib/partition_gardener/layout/integer_window.rb', line 7

def active_end(active_start:, active_id_width: DEFAULT_ACTIVE_ID_WIDTH)
  active_start + active_id_width
end

.build_segments(config:, active_start:, active_end:, hot_buckets:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/partition_gardener/layout/integer_window.rb', line 11

def build_segments(config:, active_start:, active_end:, hot_buckets:)
  strategy = Strategy::IntegerRange.new(config)
  buckets = strategy.send(:each_bucket_in_range, active_start, active_end)

  ZoneSegments.build_filler_and_hot_segments(
    table_name: config[:table_name],
    buckets: buckets,
    hot_buckets: hot_buckets,
    active_start: active_start,
    active_end: active_end,
    hot_bucket_name: strategy.method(:hot_bucket_partition_name),
    bucket_end: ->(bucket) { [bucket + strategy.send(:current_band_size), active_end].min }
  )
end