pgvector 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1699eea3d6ebb0ede69e22c38fe8596482577b2258904a76c877295bc9008e8f
4
+ data.tar.gz: d7ecf8fb6dc2d3bf781a5d65d07bc5abea5f768a268720fd93e6de6e4b778885
5
+ SHA512:
6
+ metadata.gz: 010f1f0c74ac1ef69bba4953a50b24d106f359b9e77c8f7bc282d1272008b0376f1b9d8fe72a67c1325bf49b1bd0fa29f6fb5aa139966a46eda0478b3957d56a
7
+ data.tar.gz: e21326c03271c19bd8babcf43d29b3896ef30f0bd1011284c52e6f980e40400f9bc4b56345130968d401075d615ab3d5df7198730899bebaab8e36b6ccfb6f47
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 (2022-02-07)
2
+
3
+ - First release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Andrew Kane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # pgvector-ruby
2
+
3
+ [pgvector](https://github.com/pgvector/pgvector) support for Ruby
4
+
5
+ Supports the [pg](https://github.com/ged/ruby-pg) gem
6
+
7
+ For Rails, check out [Neighbor](https://github.com/ankane/neighbor)
8
+
9
+ [![Build Status](https://github.com/pgvector/pgvector-ruby/workflows/build/badge.svg?branch=master)](https://github.com/pgvector/pgvector-ruby/actions)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application’s Gemfile:
14
+
15
+ ```ruby
16
+ gem "pgvector"
17
+ ```
18
+
19
+ And follow the instructions for your database library:
20
+
21
+ - [pg](#pg)
22
+
23
+ ## pg
24
+
25
+ Register the vector type with your connection
26
+
27
+ ```ruby
28
+ require "pgvector/pg"
29
+
30
+ registry = PG::BasicTypeRegistry.new.define_default_types
31
+ Pgvector::PG.register_vector(registry)
32
+ conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn, registry: registry)
33
+ ```
34
+
35
+ Insert a vector
36
+
37
+ ```ruby
38
+ factors = [1, 2, 3]
39
+ conn.exec_params("INSERT INTO items (factors) VALUES ($1)", [factors])
40
+ ```
41
+
42
+ Get the nearest neighbors to a vector
43
+
44
+ ```ruby
45
+ conn.exec_params("SELECT * FROM items ORDER BY factors <-> $1 LIMIT 5", [factors]).to_a
46
+ ```
47
+
48
+ ## History
49
+
50
+ View the [changelog](https://github.com/pgvector/pgvector-ruby/blob/master/CHANGELOG.md)
51
+
52
+ ## Contributing
53
+
54
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
55
+
56
+ - [Report bugs](https://github.com/pgvector/pgvector-ruby/issues)
57
+ - Fix bugs and [submit pull requests](https://github.com/pgvector/pgvector-ruby/pulls)
58
+ - Write, clarify, or fix documentation
59
+ - Suggest or add new features
60
+
61
+ To get started with development:
62
+
63
+ ```sh
64
+ git clone https://github.com/pgvector/pgvector-ruby.git
65
+ cd pgvector-ruby
66
+ createdb pgvector_ruby_test
67
+ bundle install
68
+ bundle exec rake test
69
+ ```
@@ -0,0 +1,17 @@
1
+ require "pg"
2
+
3
+ module Pgvector
4
+ module PG
5
+ def self.register_vector(registry)
6
+ registry.register_type(0, "vector", nil, TextDecoder::Vector)
7
+ end
8
+
9
+ module TextDecoder
10
+ class Vector < ::PG::SimpleDecoder
11
+ def decode(string, tuple = nil, field = nil)
12
+ string[1..-2].split(",").map(&:to_f)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Pgvector
2
+ VERSION = "0.1.0"
3
+ end
data/lib/pgvector.rb ADDED
@@ -0,0 +1 @@
1
+ require "pgvector/version"
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pgvector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: andrew@ankane.org
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - CHANGELOG.md
20
+ - LICENSE.txt
21
+ - README.md
22
+ - lib/pgvector.rb
23
+ - lib/pgvector/pg.rb
24
+ - lib/pgvector/version.rb
25
+ homepage: https://github.com/pgvector/pgvector-ruby
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '2.6'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.3.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: pgvector support for Ruby
48
+ test_files: []