Module: Pgvector
- Defined in:
- lib/pgvector.rb,
lib/pgvector/pg.rb,
lib/pgvector/bit.rb,
lib/pgvector/vector.rb,
lib/pgvector/version.rb,
lib/pgvector/half_vector.rb,
lib/pgvector/sparse_vector.rb
Defined Under Namespace
Modules: PG
Classes: Bit, HalfVector, SparseVector, Vector
Constant Summary
collapse
- VERSION =
"0.3.2"
Class Method Summary
collapse
Class Method Details
.decode(string) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/pgvector.rb', line 19
def self.decode(string)
if string[0] == "["
Vector.from_text(string).to_a
elsif string[0] == "{"
SparseVector.from_text(string)
else
string
end
end
|
.encode(data) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/pgvector.rb', line 11
def self.encode(data)
if data.is_a?(Vector) || data.is_a?(HalfVector) || data.is_a?(SparseVector)
data.to_s
else
Vector.new(data).to_s
end
end
|