Class: SolidCache::Entry::Size::Estimate

Inherits:
Object
  • Object
show all
Defined in:
app/models/solid_cache/entry/size/estimate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(samples:) ⇒ Estimate

Returns a new instance of Estimate.



53
54
55
56
# File 'app/models/solid_cache/entry/size/estimate.rb', line 53

def initialize(samples:)
  @samples = samples
  @max_records ||= Entry.id_range
end

Instance Attribute Details

#max_recordsObject (readonly)

Returns the value of attribute max_records.



51
52
53
# File 'app/models/solid_cache/entry/size/estimate.rb', line 51

def max_records
  @max_records
end

#samplesObject (readonly)

Returns the value of attribute samples.



51
52
53
# File 'app/models/solid_cache/entry/size/estimate.rb', line 51

def samples
  @samples
end

Instance Method Details

#exact?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/solid_cache/entry/size/estimate.rb', line 62

def exact?
  outliers_count < samples || sampled_fraction == 1
end

#sizeObject



58
59
60
# File 'app/models/solid_cache/entry/size/estimate.rb', line 58

def size
  outliers_size + non_outlier_estimated_size
end