lancelot 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cda5bd00de23ad9f4840b1cc7f6e96b7eb4ec124ba902d3901ef36b37594de97
4
- data.tar.gz: 23e84c317e5bcd0f52870c673d0b96f9abf4f3ab97f20eb4e5b8a8047dd1cf1f
3
+ metadata.gz: b6da55f7ccdf6c0b08d1e317e63a627573e9599af9fe2c2f7c93ab8cdefc755d
4
+ data.tar.gz: fd75f76de200412842b7ad963a54dff99e691cf6a4a9c4e1df37ea65587c23a1
5
5
  SHA512:
6
- metadata.gz: 32cb3e852ed77b8ec2831b08f93252b5ccb176942c217a366079e1cb2a2a97c4be74247b5f8410a2892852456278a5ec8e5b556bd9ca3379d740b292cc32c15b
7
- data.tar.gz: 718a99dbfcd51dce872feedb87265be86417faba152d6f2512a9391f28e5fc5e115deb0154be52dc029c2771611b71c685f1f143a4d2da5157aaafc28997ffa7
6
+ metadata.gz: 44762f80ae8374f6ecf930360ca30b7e6987bbd978ae40d1fdb0c69093cc22d68877f5af2d18e25d088a13d386a2cfaba663c48d118c310e061ad130d5d86f1f
7
+ data.tar.gz: 976fee93527713f6404d9a3057e2feaa2d9b2f38601280a961c30653e9706a762aab2d1bf729dcee0b3954d4c07103f2db02e788736853ae70cd026bda0f8021
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Lancelot
1
+ <img src="/docs/assets/lancelot-wide.png" alt="lancelot" height="80px">
2
2
 
3
3
  Ruby bindings for [Lance](https://github.com/lancedb/lance), a modern columnar data format for ML. Lancelot provides a Ruby-native interface to Lance, enabling efficient storage and search of multimodal data including text, vectors, and more.
4
4
 
@@ -57,6 +57,25 @@ dataset.vector_search(query_embedding, column: "embedding", limit: 5).each { |r|
57
57
 
58
58
  ## Installation
59
59
 
60
+ ### System Requirements
61
+
62
+ Lancelot requires the Protocol Buffers compiler (`protoc`) to build from source:
63
+
64
+ ```bash
65
+ # macOS (via Homebrew)
66
+ brew install protobuf
67
+
68
+ # Ubuntu/Debian
69
+ sudo apt-get install protobuf-compiler
70
+
71
+ # Other systems
72
+ # Download from https://github.com/protocolbuffers/protobuf/releases
73
+ ```
74
+
75
+ **Note**: The `protoc` compiler is only needed when building the gem from source. Pre-built gems distributed through RubyGems.org do not require `protoc` to be installed.
76
+
77
+ ### Install the Gem
78
+
60
79
  Install the gem and add to the application's Gemfile by executing:
61
80
 
62
81
  ```bash
@@ -276,7 +295,7 @@ bundle exec rake compile
276
295
 
277
296
  ## Contributing
278
297
 
279
- Bug reports and pull requests are welcome on GitHub at https://github.com/cpetersen/lancelot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/cpetersen/lancelot/blob/main/CODE_OF_CONDUCT.md).
298
+ Bug reports and pull requests are welcome on GitHub at https://github.com/scientist-labs/lancelot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/scientist-labs/lancelot/blob/main/CODE_OF_CONDUCT.md).
280
299
 
281
300
  ## License
282
301
 
@@ -284,4 +303,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
284
303
 
285
304
  ## Code of Conduct
286
305
 
287
- Everyone interacting in the Lancelot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cpetersen/lancelot/blob/main/CODE_OF_CONDUCT.md).
306
+ Everyone interacting in the Lancelot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/scientist-labs/lancelot/blob/main/CODE_OF_CONDUCT.md).
Binary file
Binary file
@@ -11,6 +11,26 @@ use futures::stream::TryStreamExt;
11
11
 
12
12
  use crate::schema::build_arrow_schema;
13
13
  use crate::conversion::{build_record_batch, convert_batch_to_ruby};
14
+ use arrow_schema::DataType;
15
+
16
+ /// Convert Arrow DataType to Ruby-friendly string representation
17
+ fn datatype_to_ruby_string(dtype: &DataType) -> &'static str {
18
+ match dtype {
19
+ DataType::Utf8 | DataType::LargeUtf8 => "string",
20
+ DataType::Boolean => "boolean",
21
+ DataType::Int8 | DataType::Int16 | DataType::Int32 => "int32",
22
+ DataType::Int64 => "int64",
23
+ DataType::UInt8 | DataType::UInt16 | DataType::UInt32 => "int32",
24
+ DataType::UInt64 => "int64",
25
+ DataType::Float32 => "float32",
26
+ DataType::Float64 => "float64",
27
+ DataType::Date32 => "date",
28
+ DataType::Date64 => "datetime",
29
+ DataType::Timestamp(_, _) => "datetime",
30
+ DataType::FixedSizeList(_, _) => "vector", // Will be handled specially
31
+ _ => "unknown"
32
+ }
33
+ }
14
34
 
15
35
  #[magnus::wrap(class = "Lancelot::Dataset", free_immediately, size)]
16
36
  pub struct LancelotDataset {
@@ -121,16 +141,40 @@ impl LancelotDataset {
121
141
 
122
142
  pub fn schema(&self) -> Result<RHash, Error> {
123
143
  let dataset = self.dataset.borrow();
124
- let _dataset = dataset.as_ref()
144
+ let dataset = dataset.as_ref()
125
145
  .ok_or_else(|| Error::new(magnus::exception::runtime_error(), "Dataset not opened"))?;
126
146
 
147
+ // Get the actual schema from the Lance dataset
148
+ let schema = self.runtime.borrow_mut().block_on(async {
149
+ dataset.schema()
150
+ });
151
+
152
+ // Convert Lance schema to Arrow schema
153
+ let arrow_schema: arrow_schema::Schema = schema.into();
154
+ let arrow_schema = Arc::new(arrow_schema);
155
+
127
156
  let ruby = Ruby::get().unwrap();
128
157
  let hash = ruby.hash_new();
129
158
 
130
- // TODO: Read actual schema from Lance dataset once we figure out the 0.31 API
131
- // For now, return a hardcoded schema that matches what we support
132
- hash.aset(Symbol::new("text"), "string")?;
133
- hash.aset(Symbol::new("score"), "float32")?;
159
+ // Iterate over Arrow schema fields
160
+ for field in arrow_schema.fields() {
161
+ let field_name = Symbol::new(&field.name());
162
+
163
+ // Handle vector columns specially
164
+ if let DataType::FixedSizeList(inner_field, dimension) = field.data_type() {
165
+ // Check if it's a vector (float list)
166
+ if matches!(inner_field.data_type(), DataType::Float32 | DataType::Float16) {
167
+ let vector_info = ruby.hash_new();
168
+ vector_info.aset(Symbol::new("type"), "vector")?;
169
+ vector_info.aset(Symbol::new("dimension"), *dimension)?;
170
+ hash.aset(field_name, vector_info)?;
171
+ continue;
172
+ }
173
+ }
174
+
175
+ let field_type = datatype_to_ruby_string(field.data_type());
176
+ hash.aset(field_name, field_type)?;
177
+ }
134
178
 
135
179
  Ok(hash)
136
180
  }
@@ -62,8 +62,16 @@ module Lancelot
62
62
  count_rows
63
63
  end
64
64
 
65
- alias_method :count, :size
66
65
  alias_method :length, :size
66
+
67
+ # Override Enumerable's count to use our efficient count_rows when no block given
68
+ def count(&block)
69
+ if block_given?
70
+ super(&block) # Use Enumerable's count with block
71
+ else
72
+ count_rows # Use our efficient count without block
73
+ end
74
+ end
67
75
 
68
76
  def all
69
77
  scan_all
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lancelot
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lancelot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Petersen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-21 00:00:00.000000000 Z
11
+ date: 2025-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -111,6 +111,8 @@ files:
111
111
  - LICENSE.txt
112
112
  - README.md
113
113
  - Rakefile
114
+ - docs/assets/lancelot-wide.png
115
+ - docs/assets/lancelot.png
114
116
  - examples/basic_usage.rb
115
117
  - examples/full_text_search.rb
116
118
  - examples/idempotent_create.rb
@@ -129,13 +131,13 @@ files:
129
131
  - lib/lancelot/rank_fusion.rb
130
132
  - lib/lancelot/version.rb
131
133
  - sig/lancelot.rbs
132
- homepage: https://github.com/cpetersen/lancelot
134
+ homepage: https://github.com/scientist-labs/lancelot
133
135
  licenses:
134
136
  - MIT
135
137
  metadata:
136
- homepage_uri: https://github.com/cpetersen/lancelot
137
- source_code_uri: https://github.com/cpetersen/lancelot
138
- changelog_uri: https://github.com/cpetersen/lancelot/blob/main/CHANGELOG.md
138
+ homepage_uri: https://github.com/scientist-labs/lancelot
139
+ source_code_uri: https://github.com/scientist-labs/lancelot
140
+ changelog_uri: https://github.com/scientist-labs/lancelot/blob/main/CHANGELOG.md
139
141
  post_install_message:
140
142
  rdoc_options: []
141
143
  require_paths: