Class: DruidConfig::Entities::Segment

Inherits:
Object
  • Object
show all
Defined in:
lib/druid_config/entities/segment.rb

Overview

Segment class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ Segment

Initialize it with received info

Parameters:

metadata

Hash with returned metadata from Druid



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/druid_config/entities/segment.rb', line 18

def initialize()
  @id = ['identifier']
  @interval = ['interval'].split('/').map { |t| Time.parse t }
  @version = Time.parse ['version']
  @load_spec = ['loadSpec']
  @dimensions = ['dimensions'].split(',').map(&:to_sym)
  @metrics = ['metrics'].split(',').map(&:to_sym)
  @shard_spec = ['shardSpec']
  @binary_version = ['binaryVersion']
  @size = ['size']
end

Instance Attribute Details

#binary_versionObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def binary_version
  @binary_version
end

#dimensionsObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def dimensions
  @dimensions
end

#idObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def id
  @id
end

#intervalObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def interval
  @interval
end

#load_specObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def load_spec
  @load_spec
end

#metricsObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def metrics
  @metrics
end

#shard_specObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def shard_spec
  @shard_spec
end

#sizeObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def size
  @size
end

#versionObject (readonly)

Readers



8
9
10
# File 'lib/druid_config/entities/segment.rb', line 8

def version
  @version
end

Instance Method Details

#store_typeObject

Return the store type

Returns:

Store type as symbol



47
48
49
50
# File 'lib/druid_config/entities/segment.rb', line 47

def store_type
  return nil if load_spec.empty?
  load_spec['type'].to_sym
end

#store_uriObject

Return direct link to the store

Returns:

String with the URI



36
37
38
39
# File 'lib/druid_config/entities/segment.rb', line 36

def store_uri
  return '' if load_spec.empty?
  "s3://#{load_spec['bucket']}/#{load_spec['key']}"
end

#to_sObject

By default, show the identifier in To_s



55
56
57
# File 'lib/druid_config/entities/segment.rb', line 55

def to_s
  @id
end