class Evoc::HistoryStore

Attributes

history[RW]
svd[RW]
tag[RW]

Public Class Methods

base_history() click to toggle source
# File lib/evoc/history_store.rb, line 36
def self.base_history
    @@base_history
end
base_history=(tx_store) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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') click to toggle source
# 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

Private Class Methods

gen_tag(start_index,end_index,max_size) click to toggle source
# File lib/evoc/history_store.rb, line 49
def self.gen_tag(start_index,end_index,max_size)
  start_index.to_s+end_index.to_s+max_size.to_s
end