monotonic_grouper 1.0.2 → 1.0.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 +4 -4
- data/ext/monotonic_grouper/monotonic_grouper.c +3 -13
- data/lib/monotonic_grouper/version.rb +1 -1
- data/lib/monotonic_grouper.rb +1 -35
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 819f3771c8e8b3153fece915aa61a2fdf43704303a32da8df659956e73e0c96c
|
|
4
|
+
data.tar.gz: fe9f394e978b8891707820596796b5afb8fdf582d8161c53d35a6ba26e9f1705
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8857b22b3eb7c359024e2d51553f1cac2eed3fccdacfff17683ff7b562af4e2bb4c0815e4ee43b613ecfc98daeb4bd473d456d8a2fe5aacff37e2a63ee34655c
|
|
7
|
+
data.tar.gz: 3c631ea4f2e72fc3142ec3acf16a94b8f1b7bdbf78170b6e4b84fb1de44e59dec79e2cdcc4060b5a1edc0430ca919d0be73ff0b0b1e3073f351d0b6504ac343a
|
|
@@ -123,8 +123,6 @@ process_date_array(VALUE self, long len, long min_range_size, VALUE first_elem)
|
|
|
123
123
|
VALUE first_class = CLASS_OF(first_elem);
|
|
124
124
|
long current_size = 1;
|
|
125
125
|
long i;
|
|
126
|
-
|
|
127
|
-
/* Cache the jd of the previous element to avoid double rb_funcall */
|
|
128
126
|
long prev_jd = NUM2LONG(rb_funcall(first_elem, id_jd, 0));
|
|
129
127
|
|
|
130
128
|
for (i = 1; i < len; i++) {
|
|
@@ -134,7 +132,7 @@ process_date_array(VALUE self, long len, long min_range_size, VALUE first_elem)
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
long curr_jd = NUM2LONG(rb_funcall(curr_value, id_jd, 0));
|
|
137
|
-
|
|
135
|
+
|
|
138
136
|
if (curr_jd == prev_jd + 1) {
|
|
139
137
|
group_end = curr_value;
|
|
140
138
|
current_size++;
|
|
@@ -213,17 +211,14 @@ rb_array_group_monotonic(int argc, VALUE *argv, VALUE self)
|
|
|
213
211
|
first_elem = RARRAY_AREF(self, 0);
|
|
214
212
|
first_class = CLASS_OF(first_elem);
|
|
215
213
|
|
|
216
|
-
/* Fast path for integers */
|
|
217
214
|
if (FIXNUM_P(first_elem) || RB_BIGNUM_TYPE_P(first_elem)) {
|
|
218
215
|
return process_integer_array(self, len, min_range_size);
|
|
219
216
|
}
|
|
220
217
|
|
|
221
|
-
/* Fast path for Date objects - use rb_obj_is_kind_of for safer checking */
|
|
222
218
|
if (rb_cDate != Qnil && rb_obj_is_kind_of(first_elem, rb_cDate)) {
|
|
223
219
|
return process_date_array(self, len, min_range_size, first_elem);
|
|
224
220
|
}
|
|
225
221
|
|
|
226
|
-
/* Generic path for other Comparable types */
|
|
227
222
|
if (!rb_respond_to(first_elem, id_succ)) {
|
|
228
223
|
rb_raise(rb_eTypeError, "Elements must respond to :succ method");
|
|
229
224
|
}
|
|
@@ -241,20 +236,15 @@ void
|
|
|
241
236
|
Init_monotonic_grouper(void)
|
|
242
237
|
{
|
|
243
238
|
int state = 0;
|
|
244
|
-
|
|
245
239
|
id_succ = rb_intern("succ");
|
|
246
240
|
id_eq = rb_intern("==");
|
|
247
241
|
id_jd = rb_intern("jd");
|
|
248
|
-
|
|
249
242
|
rb_mMonotonicGrouper = rb_define_module("MonotonicGrouper");
|
|
250
|
-
|
|
251
|
-
/* Try to get Date class if it's loaded - use rb_protect to handle NameError */
|
|
252
243
|
rb_cDate = rb_protect(get_date_class, rb_cObject, &state);
|
|
253
244
|
if (state != 0) {
|
|
254
|
-
/* Date class not found, will use generic path */
|
|
255
245
|
rb_cDate = Qnil;
|
|
256
|
-
rb_set_errinfo(Qnil);
|
|
246
|
+
rb_set_errinfo(Qnil);
|
|
257
247
|
}
|
|
258
|
-
|
|
248
|
+
|
|
259
249
|
rb_define_method(rb_cArray, "group_monotonic", rb_array_group_monotonic, -1);
|
|
260
250
|
}
|
data/lib/monotonic_grouper.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'monotonic_grouper/version'
|
|
2
2
|
|
|
3
3
|
# Load the compiled extension (.so on Linux, .bundle on macOS)
|
|
4
4
|
begin
|
|
@@ -14,37 +14,3 @@ rescue LoadError
|
|
|
14
14
|
raise LoadError, "Could not find compiled extension"
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
|
|
18
|
-
module FastBloomFilter
|
|
19
|
-
class Filter
|
|
20
|
-
def add_all(items)
|
|
21
|
-
items.each { |item| add(item.to_s) }
|
|
22
|
-
self
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def count_possible_matches(items)
|
|
26
|
-
items.count { |item| include?(item.to_s) }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def inspect
|
|
30
|
-
s = stats
|
|
31
|
-
total_kb = (s[:total_bytes] / 1024.0).round(2)
|
|
32
|
-
fill_pct = (s[:fill_ratio] * 100).round(2)
|
|
33
|
-
|
|
34
|
-
"#<FastBloomFilter::Filter v2 layers=#{s[:num_layers]} " \
|
|
35
|
-
"count=#{s[:total_count]} size=#{total_kb}KB fill=#{fill_pct}%>"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def to_s
|
|
39
|
-
inspect
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def self.for_emails(error_rate: 0.001, initial_capacity: 10_000)
|
|
44
|
-
Filter.new(error_rate: error_rate, initial_capacity: initial_capacity)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def self.for_urls(error_rate: 0.01, initial_capacity: 10_000)
|
|
48
|
-
Filter.new(error_rate: error_rate, initial_capacity: initial_capacity)
|
|
49
|
-
end
|
|
50
|
-
end
|