Module: ActiveHll::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_hll/model.rb

Instance Method Summary collapse

Instance Method Details

#hll_add(attributes) ⇒ Object

doesn’t update in-memory record attribute for performance



86
87
88
89
# File 'lib/active_hll/model.rb', line 86

def hll_add(attributes)
  self.class.where(id: id).hll_add(attributes)
  nil
end

#hll_count(attribute) ⇒ Object



91
92
93
94
# File 'lib/active_hll/model.rb', line 91

def hll_count(attribute)
  quoted_column = self.class.connection.quote_column_name(attribute)
  self.class.where(id: id).pluck("hll_cardinality(#{quoted_column})").first || 0.0
end