Class: Manifold::API::SchemaManager
- Inherits:
-
Object
- Object
- Manifold::API::SchemaManager
- Defined in:
- lib/manifold/api/schema_manager.rb
Overview
Handles schema generation and writing for Manifold tables rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
-
#dimensions_schema ⇒ Object
Returns the dimensions schema structure.
-
#initialize(name, vectors, vector_service, manifold_yaml, logger) ⇒ SchemaManager
constructor
A new instance of SchemaManager.
-
#manifold_schema ⇒ Object
Returns the manifold schema structure.
-
#write_schemas(tables_directory) ⇒ Object
Generates and writes schemas to the specified directory.
Constructor Details
#initialize(name, vectors, vector_service, manifold_yaml, logger) ⇒ SchemaManager
Returns a new instance of SchemaManager.
8 9 10 11 12 13 14 |
# File 'lib/manifold/api/schema_manager.rb', line 8 def initialize(name, vectors, vector_service, manifold_yaml, logger) @name = name @vectors = vectors @vector_service = vector_service @manifold_yaml = manifold_yaml @logger = logger end |
Instance Method Details
#dimensions_schema ⇒ Object
Returns the dimensions schema structure
25 26 27 28 29 30 31 |
# File 'lib/manifold/api/schema_manager.rb', line 25 def dimensions_schema [ { "type" => "STRING", "name" => "id", "mode" => "REQUIRED" }, { "type" => "RECORD", "name" => "dimensions", "mode" => "REQUIRED", "fields" => dimensions_fields } ] end |
#manifold_schema ⇒ Object
Returns the manifold schema structure
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/manifold/api/schema_manager.rb', line 34 def manifold_schema [ { "type" => "STRING", "name" => "id", "mode" => "REQUIRED" }, { "type" => "TIMESTAMP", "name" => "timestamp", "mode" => "REQUIRED" }, { "type" => "RECORD", "name" => "dimensions", "mode" => "REQUIRED", "fields" => dimensions_fields }, { "type" => "RECORD", "name" => "metrics", "mode" => "REQUIRED", "fields" => metrics_fields } ] end |
#write_schemas(tables_directory) ⇒ Object
Generates and writes schemas to the specified directory
17 18 19 20 21 22 |
# File 'lib/manifold/api/schema_manager.rb', line 17 def write_schemas(tables_directory) tables_directory.mkpath write_dimensions_schema(tables_directory) write_manifold_schema(tables_directory) write_metrics_schemas(tables_directory) end |