Class: Wayfarer::Frontiers::MemoryFrontier Private

Inherits:
Frontier
  • Object
show all
Defined in:
lib/wayfarer/frontiers/memory_frontier.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A naive in-memory frontier.

Direct Known Subclasses

MemoryBloomfilter, MemoryTrieFrontier

Instance Attribute Summary

Attributes inherited from Frontier

#config

Instance Method Summary collapse

Methods inherited from Frontier

#cycle

Constructor Details

#initialize(config) ⇒ MemoryFrontier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MemoryFrontier.


11
12
13
14
15
16
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 11

def initialize(config)
  @current_uris = Set.new([])
  @staged_uris  = Set.new([])
  @cached_uris  = Set.new([])
  super(config)
end

Instance Method Details

#cache(*uris) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


43
44
45
46
47
48
49
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 43

def cache(*uris)
  @cached_uris |= if JAVA_PLATFORM == "java"
                    uris.map(&:to_s)
                  else
                    Parallel.map(uris, &:to_s)
                  end
end

#cached?(uri) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

52
53
54
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 52

def cached?(uri)
  @cached_uris.include?(uri.to_s)
end

#current_urisObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


19
20
21
22
23
24
25
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 19

def current_uris
  if JAVA_PLATFORM == "java"
    @current_uris.map { |uri| URI(uri) }
  else
    Parallel.map(@current_uris) { |uri| URI(uri) }
  end
end

#freeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


57
58
59
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 57

def free
  @current_uris = @staged_uris = @cached_uris = nil
end

#stage(*uris) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


33
34
35
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 33

def stage(*uris)
  @staged_uris |= uris
end

#staged?(uri) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

38
39
40
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 38

def staged?(uri)
  @staged_uris.include?(uri.to_s)
end

#staged_urisObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


28
29
30
# File 'lib/wayfarer/frontiers/memory_frontier.rb', line 28

def staged_uris
  @staged_uris.to_a # These are assumed to be URIs already, so no map
end