Module: Sequel::Plugins::Pgvector::InstanceMethods
- Defined in:
- lib/sequel/plugins/pgvector.rb
Instance Method Summary collapse
Instance Method Details
#[](k) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/sequel/plugins/pgvector.rb', line 78 def [](k) v = super if self.class.vector_columns.key?(k.to_sym) && !v.nil? # to_s needed for JRuby ::Pgvector.decode(v.to_s) else v end end |
#[]=(k, v) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/sequel/plugins/pgvector.rb', line 70 def []=(k, v) if self.class.vector_columns.key?(k.to_sym) && !v.is_a?(String) && !v.nil? super(k, ::Pgvector.encode(v)) else super end end |
#nearest_neighbors(column, **options) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/sequel/plugins/pgvector.rb', line 60 def nearest_neighbors(column, **) column = column.to_sym # important! check if neighbor attribute before calling send raise ArgumentError, "Invalid column" unless self.class.vector_columns[column] self.class .nearest_neighbors(column, self[column], **) .exclude(primary_key => self[primary_key]) end |