Class: Evoc::HistoryStore

Inherits:
Object
  • Object
show all
Extended by:
Logging
Defined in:
lib/evoc/history_store.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Logging

configure_logger_for, logger, logger_for, set_level

Class Attribute Details

.historyObject

Returns the value of attribute history.



7
8
9
# File 'lib/evoc/history_store.rb', line 7

def history
  @history
end

.svdObject

Returns the value of attribute svd.



7
8
9
# File 'lib/evoc/history_store.rb', line 7

def svd
  @svd
end

.tagObject

Returns the value of attribute tag.



7
8
9
# File 'lib/evoc/history_store.rb', line 7

def tag
  @tag
end

Class Method Details

.base_historyObject



36
37
38
# File 'lib/evoc/history_store.rb', line 36

def self.base_history
    @@base_history
end

.base_history=(tx_store) ⇒ Object



32
33
34
# File 'lib/evoc/history_store.rb', line 32

def self.base_history=tx_store
    @@base_history = tx_store.freeze
end

.get_history(start_index, end_index, max_size = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/evoc/history_store.rb', line 16

def self.get_history(start_index,end_index,max_size=nil)
  tag = gen_tag(start_index,end_index,max_size)
  if self.tag.nil?
      raise Evoc::Exceptions::NotInitialized.new, "The history store must be initialized with a base history before fetching subhistories"
  elsif self.tag != tag
    # new history
    self.tag = tag
    # create new subset
    self.history = self.base_history.clone_with_subset(start_index,end_index,max_size)
    logger.info "Caching new history | start_index: #{start_index}, end_index: #{end_index}, max_size: #{max_size}, actual filtered size: #{self.history.size}"
    # make the history unmutable
    self.history.freeze
  end
  self.history
end

.get_svd(start_index, end_index, max_size = nil) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/evoc/history_store.rb', line 40

def self.get_svd(start_index,end_index,max_size=nil)
  tag = self.gen_tag(start_index,end_index,max_size)
  if self.svd.nil? || (self.tag != tag)
    self.svd = Evoc::SVD.new(get_history(start_index,end_index,max_size)) 
  end
  self.svd
end

.initialize(path:, case_id: 'CASEID_NOT_PROVIDED', granularity: 'mixed') ⇒ Object



10
11
12
13
14
# File 'lib/evoc/history_store.rb', line 10

def self.initialize(path:,case_id: 'CASEID_NOT_PROVIDED', granularity: 'mixed')
    self.base_history = Evoc::TxStore.new(path: path,case_id: case_id, granularity: granularity)
    self.tag = gen_tag(0,self.base_history.size,"all")
    return self
end