Class: Longleaf::IndexManager

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/indexing/index_manager.rb

Overview

Manager configures and provides access to a metadata index if one is specified

Instance Method Summary collapse

Constructor Details

#initialize(config, app_config_manager) ⇒ IndexManager

Returns a new instance of IndexManager.

Parameters:

  • config (Hash)

    The system configuration as a hash

  • app_config_manager (ApplicationConfigManager)

    the application config



12
13
14
15
16
# File 'lib/longleaf/indexing/index_manager.rb', line 12

def initialize(config, app_config_manager)
  @config = config
  @app_config_manager = app_config_manager
  init_index_driver if @config&.key?(SYS_FIELDS::MD_INDEX)
end

Instance Method Details

#clear_index(older_than = nil) ⇒ Object



36
37
38
# File 'lib/longleaf/indexing/index_manager.rb', line 36

def clear_index(older_than = nil)
  @index_driver.clear_index(older_than)
end

#each_registered_path(file_selector, older_than: nil, &block) ⇒ Object



71
72
73
# File 'lib/longleaf/indexing/index_manager.rb', line 71

def each_registered_path(file_selector, older_than: nil, &block)
  @index_driver.each_registered_path(file_selector, older_than: older_than, &block)
end

#index(file_rec) ⇒ Object

Index the provided file_rec and its metadata

Parameters:



26
27
28
# File 'lib/longleaf/indexing/index_manager.rb', line 26

def index(file_rec)
  @index_driver.index(file_rec)
end

#index_stale?Boolean

Returns true if the index should be reindexed.

Returns:

  • (Boolean)

    true if the index should be reindexed



41
42
43
# File 'lib/longleaf/indexing/index_manager.rb', line 41

def index_stale?
  @index_driver.is_stale?
end

#paths_with_stale_services(file_selector, stale_datetime) ⇒ Array

Retrieves a set of which have one or more services which need to run.

Parameters:

  • file_selector (FileSelector)

    selector for paths to search for files

  • stale_datetime (DateTime)

    find file_paths with services needing to be run before this value

Returns:

  • (Array)

    array of file paths that need one or more services run, in ascending order by timestamp.



60
61
62
# File 'lib/longleaf/indexing/index_manager.rb', line 60

def paths_with_stale_services(file_selector, stale_datetime)
  @index_driver.paths_with_stale_services(file_selector, stale_datetime)
end

#registered_paths(file_selector) ⇒ Array

Retrieves a page of paths for registered files.

Parameters:

  • file_selector (FileSelector)

    selector for what paths to search for files

Returns:

  • (Array)

    array of file paths that are registered



67
68
69
# File 'lib/longleaf/indexing/index_manager.rb', line 67

def registered_paths(file_selector)
  @index_driver.registered_paths(file_selector)
end

#remove(remove_me) ⇒ Object

Remove an entry from the index

Parameters:

  • remove_me

    The record to remove from the index



32
33
34
# File 'lib/longleaf/indexing/index_manager.rb', line 32

def remove(remove_me)
  @index_driver.remove(remove_me)
end

#setup_indexObject

Setup initial structure of index implementation



46
47
48
# File 'lib/longleaf/indexing/index_manager.rb', line 46

def setup_index
  @index_driver.setup_index
end

#update_index_stateObject



50
51
52
# File 'lib/longleaf/indexing/index_manager.rb', line 50

def update_index_state
  @index_driver.update_index_state
end

#using_index?Boolean

Returns true if the system is configured to use a metadata index.

Returns:

  • (Boolean)

    true if the system is configured to use a metadata index



19
20
21
# File 'lib/longleaf/indexing/index_manager.rb', line 19

def using_index?
  !@index_driver.nil?
end