bson 5.0.1-java → 5.1.1-java
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 +4 -4
- data/Rakefile +16 -26
- data/lib/bson/array.rb +1 -1
- data/lib/bson/binary.rb +142 -5
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +1 -1
- data/lib/bson/db_pointer.rb +1 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/document.rb +8 -0
- data/lib/bson/ext_json.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +1 -1
- data/lib/bson/int32.rb +1 -1
- data/lib/bson/int64.rb +1 -1
- data/lib/bson/integer.rb +1 -1
- data/lib/bson/max_key.rb +1 -1
- data/lib/bson/min_key.rb +1 -1
- data/lib/bson/object.rb +2 -2
- data/lib/bson/object_id.rb +2 -2
- data/lib/bson/regexp.rb +4 -4
- data/lib/bson/symbol.rb +2 -2
- data/lib/bson/time.rb +1 -1
- data/lib/bson/timestamp.rb +1 -1
- data/lib/bson/undefined.rb +1 -1
- data/lib/bson/vector.rb +44 -0
- data/lib/bson/version.rb +5 -16
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson.rb +1 -0
- data/spec/bson/binary_spec.rb +46 -7
- data/spec/bson/document_as_spec.rb +14 -0
- data/spec/bson/vector_spec.rb +33 -0
- data/spec/runners/binary_vector.rb +78 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +231 -0
- data/spec/shared/lib/mrss/constraints.rb +378 -0
- data/spec/shared/lib/mrss/docker_runner.rb +298 -0
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +210 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +238 -0
- data/spec/shared/lib/mrss/release/candidate.rb +281 -0
- data/spec/shared/lib/mrss/release/product_data.rb +144 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +113 -0
- data/spec/shared/lib/mrss/session_registry.rb +69 -0
- data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +37 -0
- data/spec/shared/lib/tasks/candidate.rake +64 -0
- data/spec/shared/share/Dockerfile.erb +251 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/config.sh +27 -0
- data/spec/shared/shlib/distro.sh +84 -0
- data/spec/shared/shlib/server.sh +423 -0
- data/spec/shared/shlib/set_env.sh +110 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_tests/binary_vector_spec.rb +82 -0
- data/spec/spec_tests/data/binary_vector/README.md +61 -0
- data/spec/spec_tests/data/binary_vector/float32.json +65 -0
- data/spec/spec_tests/data/binary_vector/int8.json +57 -0
- data/spec/spec_tests/data/binary_vector/packed_bit.json +83 -0
- data/spec/spec_tests/data/corpus/binary.json +30 -0
- metadata +70 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a03675c43010414728b7b3f7467cd61e62d005698eefd9ef7006ac3a537cb7f
|
4
|
+
data.tar.gz: 95c1ff2578dd11e54aeae596ad7c96610fa91580608ff27d6d1c83c6777e7fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a29fa72227a6ea6da104d6153d9a1e77cce2844399e22a96233562b25b722c673a8517ca2ff31ef4a237415687f808768b9870612dc7f225274c9b7f3a83070e
|
7
|
+
data.tar.gz: 6b343f9a87f89165e1acefac5f698dbe748c8d3dc853553606ccf1f116af8fb4a7ff2ab03f52df1dab351649cfee98bbf5ce8387257f4df050e091ec7b9c2adb
|
data/Rakefile
CHANGED
@@ -25,6 +25,8 @@ require "rake/extensiontask"
|
|
25
25
|
require "rspec/core/rake_task"
|
26
26
|
require 'fileutils'
|
27
27
|
|
28
|
+
load 'spec/shared/lib/tasks/candidate.rake'
|
29
|
+
|
28
30
|
def jruby?
|
29
31
|
defined?(JRUBY_VERSION)
|
30
32
|
end
|
@@ -51,8 +53,10 @@ RSpec::Core::RakeTask.new(:rspec)
|
|
51
53
|
|
52
54
|
desc 'Build the bson gem'
|
53
55
|
task :build => [ :clean_all, *(jruby? ? :compile : nil) ] do
|
54
|
-
|
55
|
-
|
56
|
+
command = [ 'gem', 'build' ]
|
57
|
+
command << "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
|
58
|
+
command << ENV['GEMSPEC'] || 'bson.gemspec'
|
59
|
+
system(*command)
|
56
60
|
end
|
57
61
|
|
58
62
|
# `rake version` is used by the deployment system so get the release version
|
@@ -64,22 +68,10 @@ task :version do
|
|
64
68
|
puts BSON::VERSION
|
65
69
|
end
|
66
70
|
|
67
|
-
# `rake gem_file_name` is used by the deployment system so get the name of
|
68
|
-
# the gem file to be generated. It must do nothing more than just print the
|
69
|
-
# name of the gem file to generate.
|
70
|
-
desc 'Print the name of the gem file to generate.'
|
71
|
-
task :gem_file_name do
|
72
|
-
require 'bson/version'
|
73
|
-
base = "bson-#{BSON::VERSION}"
|
74
|
-
base << '-java' if jruby?
|
75
|
-
puts "#{base}.gem"
|
76
|
-
end
|
77
|
-
|
78
71
|
task :clean_all => :clean do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson-ruby.jar"))
|
72
|
+
%w[ bson-ruby.jar bson_native.bundle bson_native.so bson_native.o ].each do |file|
|
73
|
+
FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', file))
|
74
|
+
end
|
83
75
|
end
|
84
76
|
|
85
77
|
task :spec => :compile do
|
@@ -91,15 +83,6 @@ end
|
|
91
83
|
# been built (and signed via GPG), so we just need `rake release` to
|
92
84
|
# push the gem to rubygems.
|
93
85
|
task :release do
|
94
|
-
require 'bson/version'
|
95
|
-
|
96
|
-
# confirm: there ought to be two gems, one for MRI, and one for Java. These
|
97
|
-
# will have been previously generated by the 'BSON Release' GitHub action.
|
98
|
-
gems = Dir['*.gem']
|
99
|
-
if gems.length != 2
|
100
|
-
abort "Expected two gem files to be ready to release; got #{gems.length}"
|
101
|
-
end
|
102
|
-
|
103
86
|
if ENV['GITHUB_ACTION'].nil?
|
104
87
|
abort <<~WARNING
|
105
88
|
`rake release` must be invoked from the `BSON Release` GitHub action,
|
@@ -114,6 +97,13 @@ task :release do
|
|
114
97
|
WARNING
|
115
98
|
end
|
116
99
|
|
100
|
+
# confirm: there ought to be two gems, one for MRI, and one for Java. These
|
101
|
+
# will have been previously generated by the 'build' job.
|
102
|
+
gems = Dir['*.gem']
|
103
|
+
if gems.length != 2
|
104
|
+
abort "Expected two gem files to be ready to release; got #{gems.inspect}"
|
105
|
+
end
|
106
|
+
|
117
107
|
gems.each do |gem|
|
118
108
|
system 'gem', 'push', gem
|
119
109
|
end
|
data/lib/bson/array.rb
CHANGED
@@ -92,7 +92,7 @@ module BSON
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Converts this object to a representation directly serializable to
|
95
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
95
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
96
96
|
#
|
97
97
|
# This method recursively invokes +as_extended_json+ with the provided
|
98
98
|
# options on each array element.
|
data/lib/bson/binary.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
# rubocop:todo all
|
3
3
|
# Copyright (C) 2009-2020 MongoDB Inc.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -24,6 +24,7 @@ module BSON
|
|
24
24
|
# @since 2.0.0
|
25
25
|
class Binary
|
26
26
|
include JSON
|
27
|
+
include Comparable
|
27
28
|
|
28
29
|
# A binary is type 0x05 in the BSON spec.
|
29
30
|
#
|
@@ -49,6 +50,7 @@ module BSON
|
|
49
50
|
ciphertext: 6.chr,
|
50
51
|
column: 7.chr,
|
51
52
|
sensitive: 8.chr,
|
53
|
+
vector: 9.chr,
|
52
54
|
user: 128.chr,
|
53
55
|
}.freeze
|
54
56
|
|
@@ -60,6 +62,16 @@ module BSON
|
|
60
62
|
# @since 2.0.0
|
61
63
|
TYPES = SUBTYPES.invert.freeze
|
62
64
|
|
65
|
+
# Types of vector data.
|
66
|
+
VECTOR_DATA_TYPES = {
|
67
|
+
int8: '0x03'.hex,
|
68
|
+
float32: '0x27'.hex,
|
69
|
+
packed_bit: '0x10'.hex
|
70
|
+
}.freeze
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
VECTOR_DATA_TYPES_INVERSE = VECTOR_DATA_TYPES.invert.freeze
|
74
|
+
|
63
75
|
# @return [ String ] The raw binary data.
|
64
76
|
#
|
65
77
|
# The string is always stored in BINARY encoding.
|
@@ -88,8 +100,23 @@ module BSON
|
|
88
100
|
|
89
101
|
type == other.type && data == other.data
|
90
102
|
end
|
103
|
+
|
91
104
|
alias eql? ==
|
92
105
|
|
106
|
+
# Compare this binary object to another object. The two objects must have
|
107
|
+
# the same type for any meaningful comparison.
|
108
|
+
#
|
109
|
+
# @param [ Object ] other The object to compare against.
|
110
|
+
#
|
111
|
+
# @return [ Integer | nil ] If the objects have the same type, the result
|
112
|
+
# is -1 if self < other, 0 if self == other, and 1 if self > other. If
|
113
|
+
# other is not a Binary, or is a Binary of a different type, returns nil.
|
114
|
+
def <=>(other)
|
115
|
+
return nil unless other.is_a?(Binary) && type == other.type
|
116
|
+
|
117
|
+
data <=> other.data
|
118
|
+
end
|
119
|
+
|
93
120
|
# Generates a Fixnum hash value for this object.
|
94
121
|
#
|
95
122
|
# Allows using Binary as hash keys.
|
@@ -98,7 +125,7 @@ module BSON
|
|
98
125
|
#
|
99
126
|
# @since 2.3.1
|
100
127
|
def hash
|
101
|
-
[
|
128
|
+
[data, type].hash
|
102
129
|
end
|
103
130
|
|
104
131
|
# Return a representation of the object for use in
|
@@ -112,7 +139,7 @@ module BSON
|
|
112
139
|
end
|
113
140
|
|
114
141
|
# Converts this object to a representation directly serializable to
|
115
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
142
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
116
143
|
#
|
117
144
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
118
145
|
# (default is canonical extended JSON)
|
@@ -131,6 +158,26 @@ module BSON
|
|
131
158
|
end
|
132
159
|
end
|
133
160
|
|
161
|
+
# Decode the binary data as a vector data type.
|
162
|
+
#
|
163
|
+
# @return [ BSON::Vector ] The decoded vector data.
|
164
|
+
def as_vector
|
165
|
+
raise BSON::Error, "Cannot decode subtype #{type} as vector" unless type == :vector
|
166
|
+
|
167
|
+
dtype_value, padding, = data[0..1].unpack('CC')
|
168
|
+
dtype = VECTOR_DATA_TYPES_INVERSE[dtype_value]
|
169
|
+
raise ArgumentError, "Unsupported vector type: #{dtype_value}" unless dtype
|
170
|
+
|
171
|
+
format = case dtype
|
172
|
+
when :int8 then 'c*'
|
173
|
+
when :float32 then 'f*'
|
174
|
+
when :packed_bit then 'C*'
|
175
|
+
else
|
176
|
+
raise ArgumentError, "Unsupported type: #{dtype}"
|
177
|
+
end
|
178
|
+
BSON::Vector.new(data[2..-1].unpack(format), dtype, padding)
|
179
|
+
end
|
180
|
+
|
134
181
|
# Instantiate the new binary object.
|
135
182
|
#
|
136
183
|
# This method accepts a string in any encoding; however, if a string is
|
@@ -353,8 +400,97 @@ module BSON
|
|
353
400
|
new(uuid_binary, :uuid_old)
|
354
401
|
end
|
355
402
|
|
403
|
+
# Constructs a new binary object from a binary vector.
|
404
|
+
|
405
|
+
# @param [ BSON::Vector | Array ] vector The vector data.
|
406
|
+
# @param [ Symbol | nil ] dtype The vector data type, must be nil if vector is a BSON::Vector.
|
407
|
+
# @param [ Integer ] padding The number of bits in the final byte that are to
|
408
|
+
# be ignored when a vector element's size is less than a byte. Must be 0 if vector is a BSON::Vector.
|
409
|
+
# @param [ Boolean ] validate_vector_data Whether to validate the vector data.
|
410
|
+
#
|
411
|
+
# @return [ BSON::Binary ] The binary object.
|
412
|
+
def self.from_vector(vector, dtype = nil, padding = 0, validate_vector_data: false)
|
413
|
+
data, dtype, padding = extract_args_for_vector(vector, dtype, padding)
|
414
|
+
validate_args_for_vector!(data, dtype, padding)
|
415
|
+
|
416
|
+
format = case dtype
|
417
|
+
when :int8 then 'c*'
|
418
|
+
when :float32 then 'f*'
|
419
|
+
when :packed_bit then 'C*'
|
420
|
+
else raise ArgumentError, "Unsupported type: #{dtype}"
|
421
|
+
end
|
422
|
+
if validate_vector_data
|
423
|
+
validate_vector_data!(data, dtype)
|
424
|
+
end
|
425
|
+
metadata = [ VECTOR_DATA_TYPES[dtype], padding ].pack('CC')
|
426
|
+
data = data.pack(format)
|
427
|
+
new(metadata.concat(data), :vector)
|
428
|
+
end
|
429
|
+
|
356
430
|
private
|
357
431
|
|
432
|
+
# Extracts the arguments for a binary vector.
|
433
|
+
#
|
434
|
+
# @param [ BSON::Vector | Array ] vector The vector data.
|
435
|
+
# @param [ ::Symbol | nil ] dtype The vector data type, must be nil if vector is a BSON::Vector.
|
436
|
+
# @param [ Integer ] padding The padding. Must be 0 if vector is a BSON::Vector.
|
437
|
+
#
|
438
|
+
# @return [ Array ] The extracted data, dtype, and padding.
|
439
|
+
def self.extract_args_for_vector(vector, dtype, padding)
|
440
|
+
if vector.is_a?(BSON::Vector)
|
441
|
+
if dtype || padding != 0
|
442
|
+
raise ArgumentError, 'Do not specify dtype and padding if the first argument is BSON::Vector'
|
443
|
+
end
|
444
|
+
|
445
|
+
data = vector.data
|
446
|
+
dtype = vector.dtype
|
447
|
+
padding = vector.padding
|
448
|
+
else
|
449
|
+
data = vector
|
450
|
+
end
|
451
|
+
[ data, dtype, padding ]
|
452
|
+
end
|
453
|
+
private_class_method :extract_args_for_vector
|
454
|
+
|
455
|
+
# Validate the arguments for a binary vector.
|
456
|
+
# @param [ Array ] data The vector data.
|
457
|
+
# @param [ ::Symbol ] dtype The vector data type.
|
458
|
+
# @param [ Integer ] padding The padding. Must be 0 if vector is a BSON::Vector.
|
459
|
+
# @raise [ ArgumentError ] If the arguments are invalid.
|
460
|
+
def self.validate_args_for_vector!(data, dtype, padding)
|
461
|
+
raise ArgumentError, "Unknown dtype #{dtype}" unless VECTOR_DATA_TYPES.key?(dtype)
|
462
|
+
|
463
|
+
if %i[int8 float32].include?(dtype)
|
464
|
+
raise ArgumentError, 'Padding applies only to packed_bit' if padding != 0
|
465
|
+
elsif padding.positive? && data.empty?
|
466
|
+
raise ArgumentError, 'Padding must be zero when the vector is empty for PACKED_BIT'
|
467
|
+
elsif padding.negative? || padding > 7
|
468
|
+
raise ArgumentError, "Padding must be between 0 and 7, got #{padding}"
|
469
|
+
end
|
470
|
+
end
|
471
|
+
private_class_method :validate_args_for_vector!
|
472
|
+
|
473
|
+
# Validate that all the values in the vector data are valid for the given dtype.
|
474
|
+
#
|
475
|
+
# @param [ Array ] data The vector data.
|
476
|
+
# @param [ ::Symbol ] dtype The vector data type.
|
477
|
+
def self.validate_vector_data!(data, dtype)
|
478
|
+
validator = case dtype
|
479
|
+
when :int8
|
480
|
+
->(v) { v.is_a?(Integer) && v.between?(-128, 127) }
|
481
|
+
when :float32
|
482
|
+
->(v) { v.is_a?(Float) }
|
483
|
+
when :packed_bit
|
484
|
+
->(v) { v.is_a?(Integer) && v.between?(0, 255) }
|
485
|
+
else
|
486
|
+
raise ArgumentError, "Unsupported type: #{dtype}"
|
487
|
+
end
|
488
|
+
data.each do |v|
|
489
|
+
raise ArgumentError, "Invalid value #{v} for type #{dtype}" unless validator.call(v)
|
490
|
+
end
|
491
|
+
end
|
492
|
+
private_class_method :validate_vector_data!
|
493
|
+
|
358
494
|
# initializes an instance of BSON::Binary.
|
359
495
|
#
|
360
496
|
# @param [ String ] data the data to initialize the object with
|
@@ -383,7 +519,7 @@ module BSON
|
|
383
519
|
if representation != :standard
|
384
520
|
raise ArgumentError,
|
385
521
|
'Binary of type :uuid can only be stringified to :standard representation, ' \
|
386
|
-
|
522
|
+
"requested: #{representation.inspect}"
|
387
523
|
end
|
388
524
|
|
389
525
|
data
|
@@ -475,7 +611,8 @@ module BSON
|
|
475
611
|
validate_integer_type!(type.bytes.first)
|
476
612
|
end
|
477
613
|
when Symbol then validate_symbol_type!(type)
|
478
|
-
else
|
614
|
+
else
|
615
|
+
raise BSON::Error::InvalidBinaryType, type
|
479
616
|
end
|
480
617
|
end
|
481
618
|
|
data/lib/bson/code.rb
CHANGED
@@ -60,7 +60,7 @@ module BSON
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# Converts this object to a representation directly serializable to
|
63
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
63
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
64
64
|
#
|
65
65
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
66
66
|
# (default is canonical extended JSON)
|
data/lib/bson/code_with_scope.rb
CHANGED
@@ -64,7 +64,7 @@ module BSON
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Converts this object to a representation directly serializable to
|
67
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
67
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
68
68
|
#
|
69
69
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
70
70
|
# (default is canonical extended JSON)
|
data/lib/bson/db_pointer.rb
CHANGED
@@ -66,7 +66,7 @@ module BSON
|
|
66
66
|
end
|
67
67
|
|
68
68
|
# Converts this object to a representation directly serializable to
|
69
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
69
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
70
70
|
#
|
71
71
|
# @return [ Hash ] The extended json representation.
|
72
72
|
def as_extended_json(**_options)
|
data/lib/bson/decimal128.rb
CHANGED
@@ -73,7 +73,7 @@ module BSON
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Converts this object to a representation directly serializable to
|
76
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
76
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
77
77
|
#
|
78
78
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
79
79
|
# (default is canonical extended JSON)
|
data/lib/bson/document.rb
CHANGED
@@ -321,6 +321,14 @@ module BSON
|
|
321
321
|
raise ArgumentError, 'symbolize_keys! is not supported on BSON::Document instances. Please convert the document to hash first (using #to_h), then call #symbolize_keys! on the Hash instance'
|
322
322
|
end
|
323
323
|
|
324
|
+
def deep_symbolize_keys!
|
325
|
+
warn <<~WARN
|
326
|
+
[DEPRECATION] `deep_symbolize_keys!` is not supported on BSON::Document instances.
|
327
|
+
Please convert the document to a Hash first (using `#to_h`), then call `#deep_symbolize_keys!` on the Hash.
|
328
|
+
This will raise an error starting with the v6.0.0 release.
|
329
|
+
WARN
|
330
|
+
end
|
331
|
+
|
324
332
|
# Override the Hash implementation of to_bson_normalized_value.
|
325
333
|
#
|
326
334
|
# BSON::Document is already of the correct type and already provides
|
data/lib/bson/ext_json.rb
CHANGED
@@ -19,7 +19,7 @@ require 'json'
|
|
19
19
|
module BSON
|
20
20
|
|
21
21
|
# This module contains methods for parsing Extended JSON 2.0.
|
22
|
-
# https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
22
|
+
# https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md
|
23
23
|
module ExtJSON
|
24
24
|
|
25
25
|
# Parses JSON in a string into a Ruby object tree.
|
data/lib/bson/float.rb
CHANGED
@@ -49,7 +49,7 @@ module BSON
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# Converts this object to a representation directly serializable to
|
52
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
52
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
53
53
|
#
|
54
54
|
# This method returns the float itself if relaxed representation is
|
55
55
|
# requested and the value is finite, otherwise a $numberDouble hash.
|
data/lib/bson/hash.rb
CHANGED
@@ -53,7 +53,7 @@ module BSON
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# Converts this object to a representation directly serializable to
|
56
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
56
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
57
57
|
#
|
58
58
|
# This method recursively invokes +as_extended_json+ with the provided
|
59
59
|
# options on each hash value.
|
data/lib/bson/int32.rb
CHANGED
@@ -131,7 +131,7 @@ module BSON
|
|
131
131
|
end
|
132
132
|
|
133
133
|
# Converts this object to a representation directly serializable to
|
134
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
134
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
135
135
|
#
|
136
136
|
# This method returns the integer value if relaxed representation is
|
137
137
|
# requested, otherwise a $numberInt hash.
|
data/lib/bson/int64.rb
CHANGED
@@ -131,7 +131,7 @@ module BSON
|
|
131
131
|
end
|
132
132
|
|
133
133
|
# Converts this object to a representation directly serializable to
|
134
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
134
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
135
135
|
#
|
136
136
|
# This method returns the integer value if relaxed representation is
|
137
137
|
# requested, otherwise a $numberLong hash.
|
data/lib/bson/integer.rb
CHANGED
@@ -160,7 +160,7 @@ module BSON
|
|
160
160
|
end
|
161
161
|
|
162
162
|
# Converts this object to a representation directly serializable to
|
163
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
163
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
164
164
|
#
|
165
165
|
# This method returns the integer itself if relaxed representation is
|
166
166
|
# requested, otherwise a $numberInt hash if the value fits in 32 bits
|
data/lib/bson/max_key.rb
CHANGED
@@ -63,7 +63,7 @@ module BSON
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Converts this object to a representation directly serializable to
|
66
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
66
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
67
67
|
#
|
68
68
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
69
69
|
# (default is canonical extended JSON)
|
data/lib/bson/min_key.rb
CHANGED
@@ -63,7 +63,7 @@ module BSON
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Converts this object to a representation directly serializable to
|
66
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
66
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
67
67
|
#
|
68
68
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
69
69
|
# (default is canonical extended JSON)
|
data/lib/bson/object.rb
CHANGED
@@ -62,7 +62,7 @@ module BSON
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Serializes this object to Extended JSON
|
65
|
-
# (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
65
|
+
# (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
66
66
|
#
|
67
67
|
# Subclasses should override +as_extended_json+ rather than this method.
|
68
68
|
#
|
@@ -75,7 +75,7 @@ module BSON
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# Converts this object to a representation directly serializable to
|
78
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
78
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
79
79
|
#
|
80
80
|
# Subclasses should override this method to provide custom serialization
|
81
81
|
# to Extended JSON.
|
data/lib/bson/object_id.rb
CHANGED
@@ -75,7 +75,7 @@ module BSON
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# Converts this object to a representation directly serializable to
|
78
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
78
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
79
79
|
#
|
80
80
|
# @return [ Hash ] The extended json representation.
|
81
81
|
def as_extended_json(**_)
|
@@ -360,7 +360,7 @@ module BSON
|
|
360
360
|
# NUM2UINT. Further, the spec dictates that the time component of an
|
361
361
|
# ObjectID must be no more than 4 bytes long, so the spec itself is
|
362
362
|
# constrained in this regard.
|
363
|
-
MAX_INTEGER = 2
|
363
|
+
MAX_INTEGER = 2**32
|
364
364
|
|
365
365
|
# Returns an integer timestamp (seconds since the Epoch). Primarily used
|
366
366
|
# by the generator to produce object ids.
|
data/lib/bson/regexp.rb
CHANGED
@@ -99,16 +99,16 @@ module BSON
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def bson_extended
|
102
|
-
(
|
102
|
+
options.nobits?(::Regexp::EXTENDED) ? NO_VALUE : EXTENDED_VALUE
|
103
103
|
end
|
104
104
|
|
105
105
|
def bson_ignorecase
|
106
|
-
(
|
106
|
+
options.nobits?(::Regexp::IGNORECASE) ? NO_VALUE : IGNORECASE_VALUE
|
107
107
|
end
|
108
108
|
|
109
109
|
def bson_dotall
|
110
110
|
# Ruby Regexp's MULTILINE is equivalent to BSON's dotall value
|
111
|
-
(
|
111
|
+
options.nobits?(::Regexp::MULTILINE) ? NO_VALUE : NEWLINE_VALUE
|
112
112
|
end
|
113
113
|
|
114
114
|
# Represents the raw values for the regular expression.
|
@@ -200,7 +200,7 @@ module BSON
|
|
200
200
|
end
|
201
201
|
|
202
202
|
# Converts this object to a representation directly serializable to
|
203
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
203
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
204
204
|
#
|
205
205
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
206
206
|
# (default is canonical extended JSON)
|
data/lib/bson/symbol.rb
CHANGED
@@ -89,7 +89,7 @@ module BSON
|
|
89
89
|
end
|
90
90
|
|
91
91
|
# Converts this object to a representation directly serializable to
|
92
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
92
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
93
93
|
#
|
94
94
|
# @return [ Hash ] The extended json representation.
|
95
95
|
def as_extended_json(**_options)
|
@@ -166,7 +166,7 @@ module BSON
|
|
166
166
|
end
|
167
167
|
|
168
168
|
# Converts this object to a representation directly serializable to
|
169
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
169
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
170
170
|
#
|
171
171
|
# @return [ Hash ] The extended json representation.
|
172
172
|
def as_extended_json(**_options)
|
data/lib/bson/time.rb
CHANGED
@@ -61,7 +61,7 @@ module BSON
|
|
61
61
|
end
|
62
62
|
|
63
63
|
# Converts this object to a representation directly serializable to
|
64
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
64
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
65
65
|
#
|
66
66
|
# @note The time is floored to the nearest millisecond.
|
67
67
|
#
|
data/lib/bson/timestamp.rb
CHANGED
@@ -92,7 +92,7 @@ module BSON
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Converts this object to a representation directly serializable to
|
95
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
95
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
96
96
|
#
|
97
97
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
98
98
|
# (default is canonical extended JSON)
|
data/lib/bson/undefined.rb
CHANGED
@@ -57,7 +57,7 @@ module BSON
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# Converts this object to a representation directly serializable to
|
60
|
-
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json.
|
60
|
+
# Extended JSON (https://github.com/mongodb/specifications/blob/master/source/extended-json/extended-json.md).
|
61
61
|
#
|
62
62
|
# @option opts [ nil | :relaxed | :legacy ] :mode Serialization mode
|
63
63
|
# (default is canonical extended JSON)
|
data/lib/bson/vector.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2025-present MongoDB Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
module BSON
|
18
|
+
# Vector of numbers along with metadata for binary interoperability.
|
19
|
+
class Vector < ::Array
|
20
|
+
# @return [ Integer ] The data type stored in the vector.
|
21
|
+
attr_reader :dtype
|
22
|
+
|
23
|
+
# @return [ Integer ] The number of bits in the final byte that are to
|
24
|
+
# be ignored when a vector element's size is less than a byte
|
25
|
+
# and the length of the vector is not a multiple of 8.
|
26
|
+
attr_reader :padding
|
27
|
+
|
28
|
+
# @return [ BSON::ByteBuffer ] The data in the vector.
|
29
|
+
def data
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [ ::Array ] data The data to initialize the vector with.
|
34
|
+
# @param [ Integer ] dtype The data type of the vector.
|
35
|
+
# @param [ Integer ] padding The number of bits in the final byte that are to
|
36
|
+
# be ignored when a vector element's size is less than a byte
|
37
|
+
# and the length of the vector is not a multiple of 8.
|
38
|
+
def initialize(data, dtype, padding = 0)
|
39
|
+
@dtype = dtype
|
40
|
+
@padding = padding
|
41
|
+
super(data.dup)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/bson/version.rb
CHANGED
@@ -1,20 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# rubocop:todo all
|
3
|
-
|
4
|
-
# Copyright (C) 2009-2020 MongoDB Inc.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
2
|
|
18
3
|
module BSON
|
19
|
-
|
4
|
+
# The current version of the library.
|
5
|
+
#
|
6
|
+
# NOTE: this file is automatically updated via `rake candidate:create`.
|
7
|
+
# Manual changes to this file may be overwritten by that rake task.
|
8
|
+
VERSION = '5.1.1'
|
20
9
|
end
|
data/lib/bson-ruby.jar
CHANGED
Binary file
|