Class: NoSE::Serialize::IndexBuilder
- Includes:
- Uber::Callable
- Defined in:
- lib/nose/serialize.rb
Overview
Reconstruct indexes with fields from an existing workload
Instance Method Summary collapse
Instance Method Details
#call(_, represented:, fragment:) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/nose/serialize.rb', line 101 def call(_, represented:, fragment:, **) # Extract the entities from the workload model = represented.workload.model # Pull the fields from each entity f = lambda do |fields| fields.map { |dict| model[dict['parent']][dict['name']] } end graph_entities = fragment['graph']['nodes'].map { |n| model[n] } graph_keys = f.call(fragment['graph']['edges']) graph = QueryGraph::Graph.new graph_entities graph_keys.each { |k| graph.add_edge k.parent, k.entity, k } Index.new f.call(fragment['hash_fields']), f.call(fragment['order_fields']), f.call(fragment['extra']), graph, saved_key: fragment['key'] end |