Class: Roseflow::VectorStores::HNSWMemoryStore::HNSWNode

Inherits:
Object
  • Object
show all
Defined in:
lib/roseflow/vector_stores/hnsw_memory_store.rb

Overview

HNSW vector store node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, vector, level, m) ⇒ HNSWNode

Initializes a new node.

Parameters:

  • id (String)

    the node ID (ULID)

  • vector (Array)

    the node vector

  • level (Integer)

    the node level

  • m (Integer)

    the number of neighbors



324
325
326
327
328
329
# File 'lib/roseflow/vector_stores/hnsw_memory_store.rb', line 324

def initialize(id, vector, level, m)
  @id = id
  @vector = vector
  @level = level
  @neighbors = Array.new(level + 1) { Array.new(m) }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



314
315
316
# File 'lib/roseflow/vector_stores/hnsw_memory_store.rb', line 314

def id
  @id
end

#levelObject

Returns the value of attribute level.



315
316
317
# File 'lib/roseflow/vector_stores/hnsw_memory_store.rb', line 315

def level
  @level
end

#neighborsObject

Returns the value of attribute neighbors.



315
316
317
# File 'lib/roseflow/vector_stores/hnsw_memory_store.rb', line 315

def neighbors
  @neighbors
end

#vectorObject (readonly)

Returns the value of attribute vector.



314
315
316
# File 'lib/roseflow/vector_stores/hnsw_memory_store.rb', line 314

def vector
  @vector
end