mongory 2.1.1-aarch64-linux → 2.2.0-aarch64-linux
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/CHANGELOG.md +22 -0
- data/README.md +45 -74
- data/docs/clang_bridge.md +2 -2
- data/docs/performance.md +28 -1
- data/lib/core/2.6/mongory_ext.so +0 -0
- data/lib/core/2.7/mongory_ext.so +0 -0
- data/lib/core/3.0/mongory_ext.so +0 -0
- data/lib/core/3.1/mongory_ext.so +0 -0
- data/lib/core/3.2/mongory_ext.so +0 -0
- data/lib/core/3.3/mongory_ext.so +0 -0
- data/lib/core/3.4/mongory_ext.so +0 -0
- data/lib/core/4.0/mongory_ext.so +0 -0
- data/lib/mongory/converters/abstract_converter.rb +5 -5
- data/lib/mongory/converters/converted.rb +0 -4
- data/lib/mongory/converters/key_converter.rb +13 -36
- data/lib/mongory/converters/value_converter.rb +4 -4
- data/lib/mongory/matchers.rb +8 -7
- data/lib/mongory/query_builder.rb +9 -0
- data/lib/mongory/utils/context.rb +0 -6
- data/lib/mongory/utils/singleton_builder.rb +1 -4
- data/lib/mongory/version.rb +1 -1
- data/lib/mongory.rb +0 -1
- data/mongory.gemspec +13 -12
- data/script/coverage.rb +84 -0
- metadata +9 -54
- data/ext/mongory_ext/extconf.rb +0 -115
- data/ext/mongory_ext/mongory-core/include/mongory-core/adapters/json.h +0 -62
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/array.h +0 -122
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/config.h +0 -217
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/error.h +0 -82
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/memory_pool.h +0 -115
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/table.h +0 -127
- data/ext/mongory_ext/mongory-core/include/mongory-core/foundations/value.h +0 -175
- data/ext/mongory_ext/mongory-core/include/mongory-core/matchers/matcher.h +0 -103
- data/ext/mongory_ext/mongory-core/include/mongory-core.h +0 -12
- data/ext/mongory_ext/mongory-core/src/foundations/array.c +0 -336
- data/ext/mongory_ext/mongory-core/src/foundations/array_private.h +0 -20
- data/ext/mongory_ext/mongory-core/src/foundations/config.c +0 -335
- data/ext/mongory_ext/mongory-core/src/foundations/config_private.h +0 -49
- data/ext/mongory_ext/mongory-core/src/foundations/error.c +0 -48
- data/ext/mongory_ext/mongory-core/src/foundations/memory_pool.c +0 -406
- data/ext/mongory_ext/mongory-core/src/foundations/memory_pool_private.h +0 -45
- data/ext/mongory_ext/mongory-core/src/foundations/string_buffer.c +0 -117
- data/ext/mongory_ext/mongory-core/src/foundations/string_buffer.h +0 -43
- data/ext/mongory_ext/mongory-core/src/foundations/table.c +0 -502
- data/ext/mongory_ext/mongory-core/src/foundations/utils.c +0 -206
- data/ext/mongory_ext/mongory-core/src/foundations/utils.h +0 -77
- data/ext/mongory_ext/mongory-core/src/foundations/value.c +0 -548
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.c +0 -193
- data/ext/mongory_ext/mongory-core/src/matchers/base_matcher.h +0 -117
- data/ext/mongory_ext/mongory-core/src/matchers/compare_matcher.c +0 -241
- data/ext/mongory_ext/mongory-core/src/matchers/compare_matcher.h +0 -83
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.c +0 -730
- data/ext/mongory_ext/mongory-core/src/matchers/composite_matcher.h +0 -131
- data/ext/mongory_ext/mongory-core/src/matchers/existence_matcher.c +0 -158
- data/ext/mongory_ext/mongory-core/src/matchers/existence_matcher.h +0 -48
- data/ext/mongory_ext/mongory-core/src/matchers/external_matcher.c +0 -199
- data/ext/mongory_ext/mongory-core/src/matchers/external_matcher.h +0 -58
- data/ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.c +0 -204
- data/ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.h +0 -47
- data/ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c +0 -483
- data/ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.h +0 -46
- data/ext/mongory_ext/mongory-core/src/matchers/matcher.c +0 -529
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c +0 -117
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h +0 -29
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c +0 -61
- data/ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h +0 -23
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.c +0 -416
- data/ext/mongory_ext/mongory-core/src/matchers/value_matcher.h +0 -97
- data/ext/mongory_ext/mongory_ext.c +0 -66
- data/ext/mongory_ext/mongory_ext_internal.h +0 -74
- data/ext/mongory_ext/rb_mongory_adapters.c +0 -140
- data/ext/mongory_ext/rb_mongory_matcher.c +0 -440
- data/ext/mongory_ext/rb_mongory_value.c +0 -327
data/script/coverage.rb
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'coverage'
|
|
4
|
+
|
|
5
|
+
# Prints per-file and total Ruby line/branch coverage using stdlib Coverage (zero gem deps).
|
|
6
|
+
module MongoryCoverageReporter
|
|
7
|
+
ROW_FORMAT = "%<label>-42s Line: %<lp>5.1f%% (%<hit_l>3d/%<tot_l>3d) Branch: %<bp>5.1f%% (%<hit_b>3d/%<tot_b>3d)\n"
|
|
8
|
+
|
|
9
|
+
def self.summarize(result, lib_root)
|
|
10
|
+
totals = { hit_l: 0, tot_l: 0, hit_b: 0, tot_b: 0 }
|
|
11
|
+
result.select { |path, _| path.start_with?(lib_root) }.sort.each do |file, data|
|
|
12
|
+
print_file_row(file.sub("#{lib_root}/", ''), data, totals)
|
|
13
|
+
end
|
|
14
|
+
print_row('TOTAL', totals)
|
|
15
|
+
totals
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.print_file_row(rel, data, totals)
|
|
19
|
+
row = count_hits(data)
|
|
20
|
+
row.each { |k, v| totals[k] += v }
|
|
21
|
+
print_row(rel, row)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.count_hits(data)
|
|
25
|
+
lines = data[:lines].compact
|
|
26
|
+
branches = data[:branches].values.flat_map(&:values)
|
|
27
|
+
{ hit_l: lines.count(&:positive?), tot_l: lines.size, hit_b: branches.count(&:positive?), tot_b: branches.size }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.pct(hit, total)
|
|
31
|
+
total.positive? ? (hit * 100.0 / total) : 100.0
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.print_row(label, counts)
|
|
35
|
+
printf(ROW_FORMAT, counts.merge(label: label,
|
|
36
|
+
lp: pct(counts[:hit_l], counts[:tot_l]),
|
|
37
|
+
bp: pct(counts[:hit_b], counts[:tot_b])))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.write_lcov(result, lib_root, out_path)
|
|
41
|
+
return if out_path.nil? || out_path.empty?
|
|
42
|
+
|
|
43
|
+
repo_root = File.expand_path('..', lib_root)
|
|
44
|
+
File.open(out_path, 'w') do |io|
|
|
45
|
+
result.select { |path, _| path.start_with?(lib_root) }.sort.each do |file, data|
|
|
46
|
+
write_lcov_record(io, file.sub("#{repo_root}/", ''), data[:lines])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.write_lcov_record(io, rel_path, lines)
|
|
52
|
+
io.puts("SF:#{rel_path}")
|
|
53
|
+
lines.each_with_index { |hits, idx| io.puts("DA:#{idx + 1},#{hits}") unless hits.nil? }
|
|
54
|
+
io.puts('end_of_record')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.enforce_threshold!(totals)
|
|
58
|
+
min_line = Float(ENV.fetch('MIN_LINE_COVERAGE', '0'))
|
|
59
|
+
return if min_line <= 0 || totals[:tot_l].zero?
|
|
60
|
+
|
|
61
|
+
actual = totals[:hit_l] * 100.0 / totals[:tot_l]
|
|
62
|
+
return if actual >= min_line
|
|
63
|
+
|
|
64
|
+
warn format('ERROR: Ruby line coverage %<actual>.1f%% is below threshold %<min>.1f%%',
|
|
65
|
+
actual: actual, min: min_line)
|
|
66
|
+
exit(1)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
Coverage.start(lines: true, branches: true)
|
|
71
|
+
|
|
72
|
+
at_exit do
|
|
73
|
+
status = $ERROR_INFO
|
|
74
|
+
next if status.is_a?(SystemExit) && !status.success?
|
|
75
|
+
|
|
76
|
+
result = Coverage.result
|
|
77
|
+
lib_root = File.expand_path('../lib', __dir__)
|
|
78
|
+
totals = MongoryCoverageReporter.summarize(result, lib_root)
|
|
79
|
+
MongoryCoverageReporter.write_lcov(result, lib_root, ENV.fetch('LCOV_OUT', nil))
|
|
80
|
+
MongoryCoverageReporter.enforce_threshold!(totals)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
ARGV.replace(%w(spec --format progress)) if ARGV.empty?
|
|
84
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- koten0224
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A Mongo-like in-memory query DSL for Ruby
|
|
14
14
|
email:
|
|
@@ -34,55 +34,6 @@ files:
|
|
|
34
34
|
- examples/README.md
|
|
35
35
|
- examples/benchmark-rails.rb
|
|
36
36
|
- examples/benchmark.rb
|
|
37
|
-
- ext/mongory_ext/extconf.rb
|
|
38
|
-
- ext/mongory_ext/mongory-core/include/mongory-core.h
|
|
39
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/adapters/json.h
|
|
40
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/array.h
|
|
41
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/config.h
|
|
42
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/error.h
|
|
43
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/memory_pool.h
|
|
44
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/table.h
|
|
45
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/foundations/value.h
|
|
46
|
-
- ext/mongory_ext/mongory-core/include/mongory-core/matchers/matcher.h
|
|
47
|
-
- ext/mongory_ext/mongory-core/src/foundations/array.c
|
|
48
|
-
- ext/mongory_ext/mongory-core/src/foundations/array_private.h
|
|
49
|
-
- ext/mongory_ext/mongory-core/src/foundations/config.c
|
|
50
|
-
- ext/mongory_ext/mongory-core/src/foundations/config_private.h
|
|
51
|
-
- ext/mongory_ext/mongory-core/src/foundations/error.c
|
|
52
|
-
- ext/mongory_ext/mongory-core/src/foundations/memory_pool.c
|
|
53
|
-
- ext/mongory_ext/mongory-core/src/foundations/memory_pool_private.h
|
|
54
|
-
- ext/mongory_ext/mongory-core/src/foundations/string_buffer.c
|
|
55
|
-
- ext/mongory_ext/mongory-core/src/foundations/string_buffer.h
|
|
56
|
-
- ext/mongory_ext/mongory-core/src/foundations/table.c
|
|
57
|
-
- ext/mongory_ext/mongory-core/src/foundations/utils.c
|
|
58
|
-
- ext/mongory_ext/mongory-core/src/foundations/utils.h
|
|
59
|
-
- ext/mongory_ext/mongory-core/src/foundations/value.c
|
|
60
|
-
- ext/mongory_ext/mongory-core/src/matchers/base_matcher.c
|
|
61
|
-
- ext/mongory_ext/mongory-core/src/matchers/base_matcher.h
|
|
62
|
-
- ext/mongory_ext/mongory-core/src/matchers/compare_matcher.c
|
|
63
|
-
- ext/mongory_ext/mongory-core/src/matchers/compare_matcher.h
|
|
64
|
-
- ext/mongory_ext/mongory-core/src/matchers/composite_matcher.c
|
|
65
|
-
- ext/mongory_ext/mongory-core/src/matchers/composite_matcher.h
|
|
66
|
-
- ext/mongory_ext/mongory-core/src/matchers/existence_matcher.c
|
|
67
|
-
- ext/mongory_ext/mongory-core/src/matchers/existence_matcher.h
|
|
68
|
-
- ext/mongory_ext/mongory-core/src/matchers/external_matcher.c
|
|
69
|
-
- ext/mongory_ext/mongory-core/src/matchers/external_matcher.h
|
|
70
|
-
- ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.c
|
|
71
|
-
- ext/mongory_ext/mongory-core/src/matchers/implicit_array_matcher.h
|
|
72
|
-
- ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.c
|
|
73
|
-
- ext/mongory_ext/mongory-core/src/matchers/inclusion_matcher.h
|
|
74
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher.c
|
|
75
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.c
|
|
76
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_explainable.h
|
|
77
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.c
|
|
78
|
-
- ext/mongory_ext/mongory-core/src/matchers/matcher_traversable.h
|
|
79
|
-
- ext/mongory_ext/mongory-core/src/matchers/value_matcher.c
|
|
80
|
-
- ext/mongory_ext/mongory-core/src/matchers/value_matcher.h
|
|
81
|
-
- ext/mongory_ext/mongory_ext.c
|
|
82
|
-
- ext/mongory_ext/mongory_ext_internal.h
|
|
83
|
-
- ext/mongory_ext/rb_mongory_adapters.c
|
|
84
|
-
- ext/mongory_ext/rb_mongory_matcher.c
|
|
85
|
-
- ext/mongory_ext/rb_mongory_value.c
|
|
86
37
|
- lib/core/2.6/mongory_ext.so
|
|
87
38
|
- lib/core/2.7/mongory_ext.so
|
|
88
39
|
- lib/core/3.0/mongory_ext.so
|
|
@@ -118,6 +69,7 @@ files:
|
|
|
118
69
|
- mongory.gemspec
|
|
119
70
|
- renovate.json
|
|
120
71
|
- script/bench.rb
|
|
72
|
+
- script/coverage.rb
|
|
121
73
|
- scripts/build_with_core.sh
|
|
122
74
|
- sig/mongory.rbs
|
|
123
75
|
homepage: https://mongoryhq.github.io/mongory-rb/
|
|
@@ -129,7 +81,7 @@ metadata:
|
|
|
129
81
|
homepage_uri: https://mongoryhq.github.io/mongory-rb/
|
|
130
82
|
source_code_uri: https://github.com/mongoryhq/mongory-rb
|
|
131
83
|
changelog_uri: https://github.com/mongoryhq/mongory-rb/blob/main/CHANGELOG.md
|
|
132
|
-
post_install_message:
|
|
84
|
+
post_install_message:
|
|
133
85
|
rdoc_options: []
|
|
134
86
|
require_paths:
|
|
135
87
|
- lib
|
|
@@ -138,6 +90,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
138
90
|
- - ">="
|
|
139
91
|
- !ruby/object:Gem::Version
|
|
140
92
|
version: 2.6.0
|
|
93
|
+
- - "<"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 4.1.0
|
|
141
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
97
|
requirements:
|
|
143
98
|
- - ">="
|
|
@@ -145,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
100
|
version: '0'
|
|
146
101
|
requirements: []
|
|
147
102
|
rubygems_version: 3.4.19
|
|
148
|
-
signing_key:
|
|
103
|
+
signing_key:
|
|
149
104
|
specification_version: 4
|
|
150
105
|
summary: MongoDB-like in-memory query DSL for Ruby
|
|
151
106
|
test_files: []
|
data/ext/mongory_ext/extconf.rb
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# rubocop:disable Style/GlobalVars
|
|
4
|
-
|
|
5
|
-
require 'mkmf'
|
|
6
|
-
require 'rbconfig'
|
|
7
|
-
|
|
8
|
-
# Set the path to mongory-core
|
|
9
|
-
core_dir = File.expand_path('mongory-core', __dir__)
|
|
10
|
-
core_src_dir = File.join(core_dir, 'src')
|
|
11
|
-
core_include_dir = File.join(core_dir, 'include')
|
|
12
|
-
|
|
13
|
-
# Check if mongory-core submodule exists
|
|
14
|
-
unless Dir.exist?(core_dir)
|
|
15
|
-
puts "Error: mongory-core submodule not found at #{core_dir}"
|
|
16
|
-
puts 'Please run: git submodule update --init --recursive'
|
|
17
|
-
exit 1
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# mongory-core itself has zero third-party C library dependencies; extconf.rb compiles it directly
|
|
21
|
-
|
|
22
|
-
# Normalize compiler flags across GCC/Clang on CI (Ruby 2.6 on Ubuntu may inject clang-only warn flags)
|
|
23
|
-
def scrub_flags_from_config!(keys, patterns)
|
|
24
|
-
[RbConfig::CONFIG, RbConfig::MAKEFILE_CONFIG].uniq.each do |cfg|
|
|
25
|
-
keys.each do |k|
|
|
26
|
-
next unless cfg[k]
|
|
27
|
-
|
|
28
|
-
patterns.each do |pat|
|
|
29
|
-
cfg[k] = cfg[k].gsub(/\b#{Regexp.escape(pat)}\b/, '')
|
|
30
|
-
end
|
|
31
|
-
cfg[k] = cfg[k].squeeze(' ').strip
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
gcc_like = RbConfig::CONFIG['GCC'] == 'yes' || RbConfig::CONFIG['CC'].to_s =~ /(gcc|cc)/
|
|
37
|
-
if gcc_like
|
|
38
|
-
scrub_flags_from_config!(%w(warnflags cflags optflags debugflags), [
|
|
39
|
-
'-Wno-self-assign',
|
|
40
|
-
'-Wno-parentheses-equality',
|
|
41
|
-
'-Wno-constant-logical-operand'
|
|
42
|
-
])
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Add include paths
|
|
46
|
-
$INCFLAGS << " -I#{core_include_dir}"
|
|
47
|
-
|
|
48
|
-
# Collect source files to compile directly into the extension
|
|
49
|
-
foundations_src = Dir.glob(File.join(core_src_dir, 'foundations', '*.c'))
|
|
50
|
-
matchers_src = Dir.glob(File.join(core_src_dir, 'matchers', '*.c'))
|
|
51
|
-
|
|
52
|
-
$CFLAGS << ' -std=c99 -Wall -Wextra -Wno-incompatible-pointer-types -Wno-int-conversion'
|
|
53
|
-
# Silence C90-style warnings on older GCC when standard flags are not fully applied by toolchains
|
|
54
|
-
$CFLAGS << ' -Wno-declaration-after-statement -Wno-discarded-qualifiers'
|
|
55
|
-
$CFLAGS << ' -O2' unless ENV['DEBUG']
|
|
56
|
-
$CFLAGS << ' -g -O0 -DDEBUG' if ENV['DEBUG']
|
|
57
|
-
|
|
58
|
-
# --- macOS (darwin) linking: avoid hard-linking libruby, let symbols resolve at load time
|
|
59
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
60
|
-
# Use dynamic_lookup so Ruby symbols (rb_*) are resolved by the host interpreter at dlopen time
|
|
61
|
-
$LDFLAGS << ' -Wl,-undefined,dynamic_lookup'
|
|
62
|
-
$DLDFLAGS << ' -Wl,-undefined,dynamic_lookup'
|
|
63
|
-
elsif RbConfig::CONFIG['host_os'] !~ /mswin|mingw|android|haiku/
|
|
64
|
-
# Avoid mkmf link probes (`have_library` -> `have_devel?` executable link test) which can fail
|
|
65
|
-
# on prebuilt toolcache Rubies; pass -lpthread directly where POSIX pthreads may be separate.
|
|
66
|
-
$LOCAL_LIBS << ' -lpthread' unless $LIBS.include?('-lpthread') || $LOCAL_LIBS.include?('-lpthread')
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Let mkmf generate rules by listing all sources and corresponding objects
|
|
70
|
-
$INCFLAGS << ' -I.'
|
|
71
|
-
$INCFLAGS << " -I#{File.join(core_src_dir, 'foundations')}"
|
|
72
|
-
$INCFLAGS << " -I#{File.join(core_src_dir, 'matchers')}"
|
|
73
|
-
ext_src = Dir.glob(File.join(__dir__, '*.c')).map { |src| File.basename(src) }.sort
|
|
74
|
-
all_sources = ext_src + foundations_src + matchers_src
|
|
75
|
-
$srcs = all_sources
|
|
76
|
-
$objs = all_sources.map { |src| "#{File.basename(src, '.c')}.o" }
|
|
77
|
-
|
|
78
|
-
# Generate Makefile
|
|
79
|
-
create_makefile('mongory_ext')
|
|
80
|
-
|
|
81
|
-
puts 'extconf.rb completed successfully'
|
|
82
|
-
puts "Found #{foundations_src.length} foundation sources"
|
|
83
|
-
puts "Found #{matchers_src.length} matcher sources"
|
|
84
|
-
puts "Use 'make' to build the extension"
|
|
85
|
-
|
|
86
|
-
# Append Makefile rules: explicit compilation rules for submodule sources to avoid copying/linking files
|
|
87
|
-
mk = File.read('Makefile')
|
|
88
|
-
|
|
89
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
90
|
-
# --- sanitize Makefile to ensure no hard link against Ruby framework/libruby ---
|
|
91
|
-
mk << <<~'MAKE'
|
|
92
|
-
# --- darwin: force unlink from libruby (final override) ---
|
|
93
|
-
LIBRUBYARG =
|
|
94
|
-
LIBRUBYARG_SHARED =
|
|
95
|
-
LIBRUBYARG_STATIC =
|
|
96
|
-
LIBRUBY =
|
|
97
|
-
LIBS =
|
|
98
|
-
MAKE
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# rubocop:disable Layout/HeredocIndentation
|
|
102
|
-
rules = +"\n# --- custom rules for mongory-core submodule sources ---\n"
|
|
103
|
-
(foundations_src + matchers_src).each do |src|
|
|
104
|
-
obj = "#{File.basename(src, '.c')}.o"
|
|
105
|
-
rules << <<~MAKE
|
|
106
|
-
#{obj}: #{src}
|
|
107
|
-
$(ECHO) compiling $<
|
|
108
|
-
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
|
109
|
-
|
|
110
|
-
MAKE
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
File.write('Makefile', mk + rules)
|
|
114
|
-
# rubocop:enable Layout/HeredocIndentation
|
|
115
|
-
# rubocop:enable Style/GlobalVars
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#ifndef MONGORY_ADAPTERS_JSON_H
|
|
2
|
-
#define MONGORY_ADAPTERS_JSON_H
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file json.h
|
|
6
|
-
* @brief Optional raw JSON adapter for mongory-core (enabled via -DMONGORY_WITH_JSON=ON).
|
|
7
|
-
*
|
|
8
|
-
* Provides lazy, shallow-wrapped matching directly over raw UTF-8 JSON bytes
|
|
9
|
-
* backed by yyjson, avoiding full DOM-to-mongory_table materialization.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
#include "mongory-core/foundations/memory_pool.h"
|
|
13
|
-
#include "mongory-core/foundations/value.h"
|
|
14
|
-
#include "mongory-core/matchers/matcher.h"
|
|
15
|
-
#include <stdbool.h>
|
|
16
|
-
#include <stddef.h>
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @brief Compiles a mongory_matcher directly from a raw JSON condition string.
|
|
20
|
-
*
|
|
21
|
-
* Parses `json_str` (`len` bytes) and builds a matcher in `pool`.
|
|
22
|
-
* On parse or compile failure, sets `pool->error` and returns NULL.
|
|
23
|
-
*/
|
|
24
|
-
mongory_matcher *mongory_matcher_new_from_json(mongory_memory_pool *pool,
|
|
25
|
-
const char *json_str,
|
|
26
|
-
size_t len,
|
|
27
|
-
void *extern_ctx);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @brief Matches a raw UTF-8 JSON document string directly against `matcher`.
|
|
31
|
-
*
|
|
32
|
-
* Uses a lazy shallow wrapper so only keys/elements actually accessed by
|
|
33
|
-
* `matcher` are wrapped on demand. Safe to call concurrently from multiple
|
|
34
|
-
* threads on a shared `matcher`.
|
|
35
|
-
*
|
|
36
|
-
* @param matcher Compiled matcher (must be non-NULL).
|
|
37
|
-
* @param json_str Pointer to UTF-8 JSON bytes (NUL-termination not required).
|
|
38
|
-
* @param len Byte length of `json_str`.
|
|
39
|
-
* @return true if `json_str` is valid JSON and satisfies `matcher`, false otherwise.
|
|
40
|
-
*/
|
|
41
|
-
bool mongory_matcher_match_json(mongory_matcher *matcher, const char *json_str, size_t len);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @brief Reusable scratch context for high-throughput batch JSON filtering.
|
|
45
|
-
*
|
|
46
|
-
* Reuses a single internal scratch memory pool and yyjson buffer across calls
|
|
47
|
-
* to avoid per-record heap allocations. Create one context per thread.
|
|
48
|
-
*/
|
|
49
|
-
typedef struct mongory_json_match_ctx mongory_json_match_ctx;
|
|
50
|
-
|
|
51
|
-
mongory_json_match_ctx *mongory_json_match_ctx_new(void);
|
|
52
|
-
void mongory_json_match_ctx_free(mongory_json_match_ctx *ctx);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @brief Matches a raw UTF-8 JSON document using a reusable `ctx`.
|
|
56
|
-
*/
|
|
57
|
-
bool mongory_matcher_match_json_with_ctx(mongory_matcher *matcher,
|
|
58
|
-
mongory_json_match_ctx *ctx,
|
|
59
|
-
const char *json_str,
|
|
60
|
-
size_t len);
|
|
61
|
-
|
|
62
|
-
#endif /* MONGORY_ADAPTERS_JSON_H */
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
#ifndef MONGORY_ARRAY
|
|
2
|
-
#define MONGORY_ARRAY
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file array.h
|
|
6
|
-
* @brief Defines the mongory_array structure and its associated operations.
|
|
7
|
-
*
|
|
8
|
-
* mongory_array is a dynamic array implementation that stores mongory_value
|
|
9
|
-
* pointers. It handles its own memory management for the array storage using a
|
|
10
|
-
* provided mongory_memory_pool. The array can grow automatically as new
|
|
11
|
-
* elements are added.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
#include "mongory-core/foundations/memory_pool.h"
|
|
15
|
-
#include "mongory-core/foundations/value.h"
|
|
16
|
-
#include <stdbool.h>
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @brief Forward declaration for the mongory_array structure.
|
|
20
|
-
*/
|
|
21
|
-
typedef struct mongory_array mongory_array;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @brief Callback function type used by mongory_array_each_func.
|
|
25
|
-
*
|
|
26
|
-
* This function is called for each item in the array during an iteration.
|
|
27
|
-
*
|
|
28
|
-
* @param item A pointer to the current mongory_value item in the array.
|
|
29
|
-
* @param acc An accumulator or context pointer passed through the iteration.
|
|
30
|
-
* @return bool Return true to continue iteration, false to stop.
|
|
31
|
-
*/
|
|
32
|
-
typedef bool (*mongory_array_callback_func)(mongory_value *item, void *acc);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @brief Function pointer type for iterating over the array.
|
|
36
|
-
* @param self A pointer to the mongory_array instance.
|
|
37
|
-
* @param acc An accumulator or context pointer to be passed to the callback.
|
|
38
|
-
* @param func The callback function to be executed for each item.
|
|
39
|
-
* @return bool Returns true if the iteration completed fully, false if it was
|
|
40
|
-
* stopped by a callback.
|
|
41
|
-
*/
|
|
42
|
-
typedef bool (*mongory_array_each_func)(mongory_array *self, void *acc, mongory_array_callback_func func);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @brief Function pointer type for adding an element to the end of the array.
|
|
46
|
-
* @param self A pointer to the mongory_array instance.
|
|
47
|
-
* @param value A pointer to the mongory_value to add.
|
|
48
|
-
* @return bool Returns true if the value was successfully added, false
|
|
49
|
-
* otherwise (e.g., memory allocation failure).
|
|
50
|
-
*/
|
|
51
|
-
typedef bool (*mongory_array_push_func)(mongory_array *self, mongory_value *value);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @brief Function pointer type for retrieving an element at a specific index.
|
|
55
|
-
* @param self A pointer to the mongory_array instance.
|
|
56
|
-
* @param index The index of the element to retrieve.
|
|
57
|
-
* @return mongory_value* A pointer to the mongory_value at the given index, or
|
|
58
|
-
* NULL if the index is out of bounds.
|
|
59
|
-
*/
|
|
60
|
-
typedef mongory_value *(*mongory_array_get_func)(mongory_array *self, size_t index);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @brief Function pointer type for setting or replacing an element at a
|
|
64
|
-
* specific index.
|
|
65
|
-
*
|
|
66
|
-
* If the index is beyond the current count, the array will be grown, and
|
|
67
|
-
* intermediate elements will be initialized to NULL.
|
|
68
|
-
*
|
|
69
|
-
* @param self A pointer to the mongory_array instance.
|
|
70
|
-
* @param index The index at which to set the value.
|
|
71
|
-
* @param value A pointer to the mongory_value to set.
|
|
72
|
-
* @return bool Returns true if the value was successfully set, false otherwise
|
|
73
|
-
* (e.g., memory allocation failure).
|
|
74
|
-
*/
|
|
75
|
-
typedef bool (*mongory_array_set_func)(mongory_array *self, size_t index, mongory_value *value);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @brief Creates a new mongory_array instance.
|
|
79
|
-
*
|
|
80
|
-
* The array is initialized with a default capacity and will use the provided
|
|
81
|
-
* memory pool for all its internal allocations related to storing elements.
|
|
82
|
-
*
|
|
83
|
-
* @param pool A pointer to the mongory_memory_pool to be used for allocations.
|
|
84
|
-
* @return mongory_array* A pointer to the newly created mongory_array, or NULL
|
|
85
|
-
* if creation fails (e.g., memory allocation failure).
|
|
86
|
-
*/
|
|
87
|
-
mongory_array *mongory_array_new(mongory_memory_pool *pool);
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @brief Creates a new mongory_array instance with a nested array.
|
|
91
|
-
*
|
|
92
|
-
* This function is used to create a new mongory_array instance with a nested
|
|
93
|
-
* array. The nested array is created with the given memory pool and the given
|
|
94
|
-
* values. The nested array is returned as a pointer to the mongory_array
|
|
95
|
-
* structure.
|
|
96
|
-
*
|
|
97
|
-
* @param pool A pointer to the mongory_memory_pool to be used for allocations.
|
|
98
|
-
* @param argc The number of values to be set.
|
|
99
|
-
* @param ... The values to be set.
|
|
100
|
-
* @return mongory_array* A pointer to the newly created mongory_array, or NULL
|
|
101
|
-
* if creation fails (e.g., memory allocation failure).
|
|
102
|
-
*/
|
|
103
|
-
mongory_array *mongory_array_nested_wrap(mongory_memory_pool *pool, int argc, ...);
|
|
104
|
-
#define MG_ARRAY_WRAP(pool, n, ...) mongory_value_wrap_a(pool, mongory_array_nested_wrap(pool, n, __VA_ARGS__))
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @struct mongory_array
|
|
108
|
-
* @brief Represents a dynamic array of mongory_value pointers.
|
|
109
|
-
*
|
|
110
|
-
* This structure provides function pointers for common array operations,
|
|
111
|
-
* allowing for a somewhat object-oriented interface in C.
|
|
112
|
-
*/
|
|
113
|
-
struct mongory_array {
|
|
114
|
-
size_t count; /**< The current number of elements in the array. */
|
|
115
|
-
mongory_memory_pool *pool; /**< The memory pool used for allocations. */
|
|
116
|
-
mongory_array_each_func each; /**< Function to iterate over elements in the array. */
|
|
117
|
-
mongory_array_push_func push; /**< Function to add an element to the end of the array. */
|
|
118
|
-
mongory_array_get_func get; /**< Function to retrieve an element by index. */
|
|
119
|
-
mongory_array_set_func set; /**< Function to set or replace an element at an index. */
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
#endif /* MONGORY_ARRAY */
|