Class: Pacer::Orient::FactoryContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/pacer-orient/factory_container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(f, url, args) ⇒ FactoryContainer

Returns a new instance of FactoryContainer.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pacer-orient/factory_container.rb', line 6

def initialize(f, url, args)
  @factory = f
  @url = url
  Pacer.open_graphs[url] = self
  if args
    @transactional     = args[:transactional]
    @lightweight_edges = args[:lightweight_edges]
    @edge_classes      = args[:edge_classes]
    @vertex_classes    = args[:vertex_classes]
    self.stay_open     = args[:stay_open]
    @encoder = args.fetch :encoder, Encoder
    min = args[:pool_min]
    max = args[:pool_max]
    if min and max
      setupPool min, max
    end
  else
    @encoder = Encoder
  end
end

Instance Attribute Details

#edge_classesObject

Returns the value of attribute edge_classes.



4
5
6
# File 'lib/pacer-orient/factory_container.rb', line 4

def edge_classes
  @edge_classes
end

#encoderObject

Returns the value of attribute encoder.



4
5
6
# File 'lib/pacer-orient/factory_container.rb', line 4

def encoder
  @encoder
end

#factoryObject (readonly)

Returns the value of attribute factory.



3
4
5
# File 'lib/pacer-orient/factory_container.rb', line 3

def factory
  @factory
end

#lightweight_edgesObject

Returns the value of attribute lightweight_edges.



4
5
6
# File 'lib/pacer-orient/factory_container.rb', line 4

def lightweight_edges
  @lightweight_edges
end

#transactionalObject

Returns the value of attribute transactional.



4
5
6
# File 'lib/pacer-orient/factory_container.rb', line 4

def transactional
  @transactional
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/pacer-orient/factory_container.rb', line 3

def url
  @url
end

#use_poolObject (readonly)

Returns the value of attribute use_pool.



3
4
5
# File 'lib/pacer-orient/factory_container.rb', line 3

def use_pool
  @use_pool
end

#vertex_classesObject

Returns the value of attribute vertex_classes.



4
5
6
# File 'lib/pacer-orient/factory_container.rb', line 4

def vertex_classes
  @vertex_classes
end

Instance Method Details

#getObject



56
57
58
59
60
61
62
# File 'lib/pacer-orient/factory_container.rb', line 56

def get
  if transactional == false
    getNoTx
  else
    getTx
  end
end

#getNoTxObject



68
69
70
# File 'lib/pacer-orient/factory_container.rb', line 68

def getNoTx
  configure factory.getNoTx
end

#getTxObject



64
65
66
# File 'lib/pacer-orient/factory_container.rb', line 64

def getTx
  configure factory.getTx
end

#graphObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pacer-orient/factory_container.rb', line 40

def graph
  # Shutdown releases the graph to the pool in this case.
  g = Graph.new encoder, proc { get }, proc { |g| g.blueprints_graph.shutdown }
  if block_given?
    r = yield g
    g.shutdown if use_pool
    r
  else
    g
  end
end

#setupPool(min, max) ⇒ Object



27
28
29
30
# File 'lib/pacer-orient/factory_container.rb', line 27

def setupPool(min, max)
  @use_pool = true
  factory.setupPool min, max
end

#shutdownObject

Pacer calls shutdown on all cached graphs when it exits. Orient caches this factory.



73
74
75
76
# File 'lib/pacer-orient/factory_container.rb', line 73

def shutdown
  factory.close
  Pacer.open_graphs.delete url
end

#stay_openObject



36
37
38
# File 'lib/pacer-orient/factory_container.rb', line 36

def stay_open
  #factory.getLeaveGraphsOpen
end

#stay_open=(b) ⇒ Object



32
33
34
# File 'lib/pacer-orient/factory_container.rb', line 32

def stay_open=(b)
  #factory.setLeaveGraphsOpen b
end

#surrender(g) ⇒ Object



52
53
54
# File 'lib/pacer-orient/factory_container.rb', line 52

def surrender(g)
  g.shutdown if use_pool
end