Class: PartitionGardener::Layout::SlidingWindow

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

Class Method Summary collapse

Class Method Details

.active_end(active_start:, bucket: :month, active_span: nil) ⇒ Object



5
6
7
8
# File 'lib/partition_gardener/layout/sliding_window.rb', line 5

def active_end(active_start:, bucket: :month, active_span: nil)
  span = active_span || DateBucket.default_active_span(bucket)
  DateBucket.add_buckets(active_start, span, bucket)
end

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



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

def build_segments(config:, active_start:, active_end:, hot_months:)
  strategy = Strategy::DateRange.new(config)
  buckets = strategy.send(:each_bucket_in_range, active_start, active_end)
  bucket = config.fetch(:bucket, :month)

  ZoneSegments.build_filler_and_hot_segments(
    table_name: config[:table_name],
    buckets: buckets,
    hot_buckets: hot_months,
    active_start: active_start,
    active_end: active_end,
    hot_bucket_name: config[:partition_name_format],
    bucket_end: ->(bucket_start) { DateBucket.end_of_bucket(bucket_start, bucket) }
  )
end