Skip to content

Commit 1ae3d35

Browse files
authored
Update C++ core (#135)
1 parent 2bfef9b commit 1ae3d35

File tree

5 files changed

+50
-19
lines changed

5 files changed

+50
-19
lines changed

ext/couchbase

ext/couchbase.cxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4143,7 +4143,7 @@ cb_Backend_document_scan_create(VALUE self, VALUE bucket, VALUE scope, VALUE col
41434143
rb_raise(eCouchbaseError, "Cannot perform scan operation. Unable to get bucket configuration");
41444144
return Qnil;
41454145
}
4146-
if (!config->supports_range_scan()) {
4146+
if (!config->capabilities.supports_range_scan()) {
41474147
rb_raise(eFeatureNotAvailable, "Server does not support key-value scan operations");
41484148
return Qnil;
41494149
}
@@ -5841,13 +5841,13 @@ cb_Backend_query_index_get_all(VALUE self, VALUE bucket_name, VALUE options)
58415841
}
58425842

58435843
static VALUE
5844-
cb_Backend_query_index_create(VALUE self, VALUE bucket_name, VALUE index_name, VALUE fields, VALUE options)
5844+
cb_Backend_query_index_create(VALUE self, VALUE bucket_name, VALUE index_name, VALUE keys, VALUE options)
58455845
{
58465846
const auto& cluster = cb_backend_to_cluster(self);
58475847

58485848
Check_Type(bucket_name, T_STRING);
58495849
Check_Type(index_name, T_STRING);
5850-
Check_Type(fields, T_ARRAY);
5850+
Check_Type(keys, T_ARRAY);
58515851
if (!NIL_P(options)) {
58525852
Check_Type(options, T_HASH);
58535853
}
@@ -5857,12 +5857,12 @@ cb_Backend_query_index_create(VALUE self, VALUE bucket_name, VALUE index_name, V
58575857
cb_extract_timeout(req, options);
58585858
req.bucket_name = cb_string_new(bucket_name);
58595859
req.index_name = cb_string_new(index_name);
5860-
auto fields_num = static_cast<std::size_t>(RARRAY_LEN(fields));
5861-
req.fields.reserve(fields_num);
5862-
for (std::size_t i = 0; i < fields_num; ++i) {
5863-
VALUE entry = rb_ary_entry(fields, static_cast<long>(i));
5860+
auto keys_num = static_cast<std::size_t>(RARRAY_LEN(keys));
5861+
req.keys.reserve(keys_num);
5862+
for (std::size_t i = 0; i < keys_num; ++i) {
5863+
VALUE entry = rb_ary_entry(keys, static_cast<long>(i));
58645864
cb_check_type(entry, T_STRING);
5865-
req.fields.emplace_back(RSTRING_PTR(entry), static_cast<std::size_t>(RSTRING_LEN(entry)));
5865+
req.keys.emplace_back(RSTRING_PTR(entry), static_cast<std::size_t>(RSTRING_LEN(entry)));
58665866
}
58675867
if (!NIL_P(options)) {
58685868
if (VALUE ignore_if_exists = rb_hash_aref(options, rb_id2sym(rb_intern("ignore_if_exists"))); ignore_if_exists == Qtrue) {
@@ -6292,7 +6292,7 @@ cb_Backend_collection_query_index_create(VALUE self,
62926292
VALUE scope_name,
62936293
VALUE collection_name,
62946294
VALUE index_name,
6295-
VALUE fields,
6295+
VALUE keys,
62966296
VALUE options)
62976297
{
62986298
const auto& cluster = cb_backend_to_cluster(self);
@@ -6301,7 +6301,7 @@ cb_Backend_collection_query_index_create(VALUE self,
63016301
Check_Type(scope_name, T_STRING);
63026302
Check_Type(collection_name, T_STRING);
63036303
Check_Type(index_name, T_STRING);
6304-
Check_Type(fields, T_ARRAY);
6304+
Check_Type(keys, T_ARRAY);
63056305
if (!NIL_P(options)) {
63066306
Check_Type(options, T_HASH);
63076307
}
@@ -6313,12 +6313,12 @@ cb_Backend_collection_query_index_create(VALUE self,
63136313
req.scope_name = cb_string_new(scope_name);
63146314
req.collection_name = cb_string_new(collection_name);
63156315
req.index_name = cb_string_new(index_name);
6316-
auto fields_num = static_cast<std::size_t>(RARRAY_LEN(fields));
6317-
req.fields.reserve(fields_num);
6318-
for (std::size_t i = 0; i < fields_num; ++i) {
6319-
VALUE entry = rb_ary_entry(fields, static_cast<long>(i));
6316+
auto keys_num = static_cast<std::size_t>(RARRAY_LEN(keys));
6317+
req.keys.reserve(keys_num);
6318+
for (std::size_t i = 0; i < keys_num; ++i) {
6319+
VALUE entry = rb_ary_entry(keys, static_cast<long>(i));
63206320
cb_check_type(entry, T_STRING);
6321-
req.fields.emplace_back(RSTRING_PTR(entry), static_cast<std::size_t>(RSTRING_LEN(entry)));
6321+
req.keys.emplace_back(RSTRING_PTR(entry), static_cast<std::size_t>(RSTRING_LEN(entry)));
63226322
}
63236323
if (!NIL_P(options)) {
63246324
if (VALUE ignore_if_exists = rb_hash_aref(options, rb_id2sym(rb_intern("ignore_if_exists"))); ignore_if_exists == Qtrue) {

lib/couchbase/protostellar/scope.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def query(statement, options = Couchbase::Options::Query::DEFAULT)
4444
resps = @client.send_request(req)
4545
ResponseConverter::Query.to_query_result(resps)
4646
end
47+
48+
def search_query(...)
49+
raise Error::FeatureNotAvailable, "scope search not supported in #{Protostellar::NAME} mode"
50+
end
51+
52+
def search(...)
53+
raise Error::FeatureNotAvailable, "scope search not supported in #{Protostellar::NAME} mode"
54+
end
4755
end
4856
end
4957
end

test/search_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def setup
2424
connect
2525
skip("#{name}: CAVES does not support query service yet") if use_caves?
2626
@bucket = @cluster.bucket(env.bucket)
27+
@scope = @bucket.default_scope
2728
@collection = @bucket.default_collection
2829
@index_name = "idx-#{@bucket.name}-#{rand(0..100_000)}"
2930

@@ -235,5 +236,23 @@ def test_vector_search_query_defaults_to_match_none
235236

236237
assert_equal SearchQuery.match_none.to_json, enc_query
237238
end
239+
240+
def test_vector_search_not_supported
241+
skip("#{name}: Server supports vector search") if !env.protostellar? && env.server_version.supports_vector_search?
242+
243+
req = SearchRequest.new(VectorSearch.new(VectorQuery.new("foo", [-1.1, 1.2])))
244+
assert_raises(Couchbase::Error::FeatureNotAvailable) do
245+
@cluster.search("index", req)
246+
end
247+
end
248+
249+
def test_scope_search_not_supported
250+
skip("#{name}: Server supports scope search") if !env.protostellar? && env.server_version.supports_scoped_search_indexes?
251+
252+
req = SearchRequest.new(SearchQuery.match_all)
253+
assert_raises(Couchbase::Error::FeatureNotAvailable) do
254+
@scope.search("index", req)
255+
end
256+
end
238257
end
239258
end

test/test_helper.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,19 @@ def supports_update_collection?
108108
end
109109

110110
def supports_update_collection_max_expiry?
111-
@version >= Gem::Version.create("7.5.0")
111+
trinity?
112112
end
113113

114114
def supports_collection_max_expiry_set_to_no_expiry?
115-
@version >= Gem::Version.create("7.6.0")
115+
trinity?
116116
end
117117

118118
def supports_scoped_search_indexes?
119-
@version >= Gem::Version.create("7.5.0")
119+
trinity?
120+
end
121+
122+
def supports_vector_search?
123+
trinity?
120124
end
121125
end
122126

0 commit comments

Comments
 (0)