Class: Woods::CostModel::StorageCost
- Inherits:
-
Object
- Object
- Woods::CostModel::StorageCost
- Defined in:
- lib/woods/cost_model/storage_cost.rb
Overview
Calculates vector storage requirements based on embedding dimensions and chunk count.
Bytes per vector = dimensions × 4 (float32), with a 1.3× metadata overhead factor applied per BACKEND_MATRIX.md.
Constant Summary collapse
- BYTES_PER_FLOAT =
Bytes per float32 value.
4- METADATA_OVERHEAD =
Metadata overhead multiplier (JSONB payload, indexes, etc.).
1.3
Instance Method Summary collapse
-
#bytes_per_vector ⇒ Integer
Bytes per vector including metadata overhead.
-
#initialize(dimensions:) ⇒ StorageCost
constructor
A new instance of StorageCost.
-
#storage_bytes(chunks:) ⇒ Integer
Total storage in bytes for a given number of chunks.
-
#storage_mb(chunks:) ⇒ Float
Total storage in megabytes for a given number of chunks.
Constructor Details
#initialize(dimensions:) ⇒ StorageCost
Returns a new instance of StorageCost.
24 25 26 |
# File 'lib/woods/cost_model/storage_cost.rb', line 24 def initialize(dimensions:) @dimensions = dimensions end |
Instance Method Details
#bytes_per_vector ⇒ Integer
Bytes per vector including metadata overhead.
31 32 33 |
# File 'lib/woods/cost_model/storage_cost.rb', line 31 def bytes_per_vector @bytes_per_vector ||= (@dimensions * BYTES_PER_FLOAT * METADATA_OVERHEAD).ceil end |
#storage_bytes(chunks:) ⇒ Integer
Total storage in bytes for a given number of chunks.
39 40 41 |
# File 'lib/woods/cost_model/storage_cost.rb', line 39 def storage_bytes(chunks:) chunks * bytes_per_vector end |
#storage_mb(chunks:) ⇒ Float
Total storage in megabytes for a given number of chunks.
47 48 49 |
# File 'lib/woods/cost_model/storage_cost.rb', line 47 def storage_mb(chunks:) (storage_bytes(chunks: chunks).to_f / (1024 * 1024)).round(2) end |