fast_filter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/ext/fast_filter/fast_filter.c +23 -15
- data/lib/fast_filter/fast_filter.bundle +0 -0
- data/lib/fast_filter/fast_filter.so +0 -0
- data/lib/fast_filter/version.rb +1 -1
- metadata +4 -5
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -19
- data/fast_filter.gemspec +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b7c59fd7fa385ec7291e61361f69873c7472fed
|
4
|
+
data.tar.gz: 789194ec48d08a7a37492486e7866308e1f39b85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3463ecc5ce24290345f02c508582691551adae0426439fe5c721ad2b0ec8e77e3b5d4e1a38bf01598d95e97732b82fc649436c47a4faf802f68906f5c382ca93
|
7
|
+
data.tar.gz: 45f403782a6bc5e8428c92c732429a69d895e622bca6234e8021b087eab1926ed47c7f0326fa91da8a5a63e56fe1c0e9b4b8166035f27065eb72b9762cc0cbd0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.0.2] - 2017-05-05
|
10
|
+
### Fixed
|
11
|
+
- Ruby versions before 2.3.0 now supported
|
12
|
+
- Compiling correctly on Linux
|
13
|
+
|
14
|
+
[Unreleased]: https://github.com/TandaHQ/fast_filter/compare/v0.0.2...HEAD
|
15
|
+
[0.0.2]: https://github.com/TandaHQ/fast_filter/compare/v0.0.1...v0.0.2
|
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -10,11 +10,13 @@ static int asc_comp_fn(const void *a, const void *b) {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
static int bin_lower_bound(long **a, int lo, int hi, long x) {
|
13
|
+
int mid;
|
14
|
+
|
13
15
|
if (lo > hi) {
|
14
16
|
return lo;
|
15
17
|
}
|
16
18
|
|
17
|
-
|
19
|
+
mid = lo + (hi - lo) / 2;
|
18
20
|
if (a[mid][0] == x) {
|
19
21
|
return bin_lower_bound(a, lo, mid - 1, x);
|
20
22
|
} else if (a[mid][0] > x) {
|
@@ -25,11 +27,13 @@ static int bin_lower_bound(long **a, int lo, int hi, long x) {
|
|
25
27
|
}
|
26
28
|
|
27
29
|
static int bin_upper_bound(long **a, int lo, int hi, long x) {
|
30
|
+
int mid;
|
31
|
+
|
28
32
|
if (lo > hi) {
|
29
33
|
return lo;
|
30
34
|
}
|
31
35
|
|
32
|
-
|
36
|
+
mid = lo + (hi - lo) / 2;
|
33
37
|
if (a[mid][0] == x) {
|
34
38
|
return bin_upper_bound(a, mid + 1, hi, x);
|
35
39
|
} else if (a[mid][0] > x) {
|
@@ -42,9 +46,11 @@ static int bin_upper_bound(long **a, int lo, int hi, long x) {
|
|
42
46
|
// ============== BUILD AND FREE FUNCTIONS ==============
|
43
47
|
|
44
48
|
static void build_c_arr(long ***c_arr, VALUE *rb_array, int *len) {
|
45
|
-
|
49
|
+
int i;
|
50
|
+
*len = (int) RARRAY_LEN(*rb_array);
|
46
51
|
*c_arr = (long **) malloc(*len * sizeof(long *));
|
47
|
-
|
52
|
+
|
53
|
+
for (i = 0; i < *len; i++) {
|
48
54
|
(*c_arr)[i] = (long *) malloc(2 * sizeof(long));
|
49
55
|
(*c_arr)[i][0] = FIX2LONG(rb_ary_entry(*rb_array, i));
|
50
56
|
(*c_arr)[i][1] = i;
|
@@ -54,17 +60,19 @@ static void build_c_arr(long ***c_arr, VALUE *rb_array, int *len) {
|
|
54
60
|
}
|
55
61
|
|
56
62
|
static void free_c_arr(long **c_arr, int len) {
|
57
|
-
|
63
|
+
int i;
|
64
|
+
for (i = 0; i < len; i++) {
|
58
65
|
free(c_arr[i]);
|
59
66
|
}
|
60
67
|
free(c_arr);
|
61
68
|
}
|
62
69
|
|
63
70
|
static void build_rb_arr(VALUE *r_arr, long **c_arr, int start, int finish, int index_mode) {
|
64
|
-
|
71
|
+
int ci, ri;
|
65
72
|
int c_arr_index = index_mode;
|
73
|
+
*r_arr = rb_ary_new2(finish - start);
|
66
74
|
|
67
|
-
for (
|
75
|
+
for (ci = start, ri = 0; ci < finish; ci++, ri++) {
|
68
76
|
rb_ary_store(*r_arr, ri, LONG2FIX(c_arr[ci][c_arr_index]));
|
69
77
|
}
|
70
78
|
}
|
@@ -74,41 +82,41 @@ static void build_rb_arr(VALUE *r_arr, long **c_arr, int start, int finish, int
|
|
74
82
|
// public filter functions
|
75
83
|
|
76
84
|
static void lt_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
|
77
|
-
int len;
|
85
|
+
int len, last;
|
78
86
|
long **c_arr;
|
79
87
|
build_c_arr(&c_arr, input_rb_array, &len);
|
80
88
|
|
81
|
-
|
89
|
+
last = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
|
82
90
|
build_rb_arr(output_rb_array, c_arr, 0, last, index_mode);
|
83
91
|
free_c_arr(c_arr, len);
|
84
92
|
}
|
85
93
|
|
86
94
|
static void lte_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
|
87
|
-
int len;
|
95
|
+
int len, last;
|
88
96
|
long **c_arr;
|
89
97
|
build_c_arr(&c_arr, input_rb_array, &len);
|
90
98
|
|
91
|
-
|
99
|
+
last = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
|
92
100
|
build_rb_arr(output_rb_array, c_arr, 0, last, index_mode);
|
93
101
|
free_c_arr(c_arr, len);
|
94
102
|
}
|
95
103
|
|
96
104
|
static void gt_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
|
97
|
-
int len;
|
105
|
+
int len, first;
|
98
106
|
long **c_arr;
|
99
107
|
build_c_arr(&c_arr, input_rb_array, &len);
|
100
108
|
|
101
|
-
|
109
|
+
first = bin_upper_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
|
102
110
|
build_rb_arr(output_rb_array, c_arr, first, len, index_mode);
|
103
111
|
free_c_arr(c_arr, len);
|
104
112
|
}
|
105
113
|
|
106
114
|
static void gte_filter_with_mode(VALUE *input_rb_array, VALUE *max_value, int index_mode, VALUE *output_rb_array) {
|
107
|
-
int len;
|
115
|
+
int len, first;
|
108
116
|
long **c_arr;
|
109
117
|
build_c_arr(&c_arr, input_rb_array, &len);
|
110
118
|
|
111
|
-
|
119
|
+
first = bin_lower_bound(c_arr, 0, len - 1, FIX2LONG(*max_value));
|
112
120
|
build_rb_arr(output_rb_array, c_arr, first, len, index_mode);
|
113
121
|
free_c_arr(c_arr, len);
|
114
122
|
}
|
Binary file
|
Binary file
|
data/lib/fast_filter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Allie
|
@@ -74,9 +74,7 @@ extensions:
|
|
74
74
|
- ext/fast_filter/extconf.rb
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
-
|
78
|
-
- ".rspec"
|
79
|
-
- ".travis.yml"
|
77
|
+
- CHANGELOG.md
|
80
78
|
- CODE_OF_CONDUCT.md
|
81
79
|
- Gemfile
|
82
80
|
- LICENSE.txt
|
@@ -86,8 +84,9 @@ files:
|
|
86
84
|
- bin/setup
|
87
85
|
- ext/fast_filter/extconf.rb
|
88
86
|
- ext/fast_filter/fast_filter.c
|
89
|
-
- fast_filter.gemspec
|
90
87
|
- lib/fast_filter.rb
|
88
|
+
- lib/fast_filter/fast_filter.bundle
|
89
|
+
- lib/fast_filter/fast_filter.so
|
91
90
|
- lib/fast_filter/version.rb
|
92
91
|
homepage: https://github.com/TandaHQ/fast_filter
|
93
92
|
licenses:
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
sudo: required
|
2
|
-
language: ruby
|
3
|
-
matrix:
|
4
|
-
include:
|
5
|
-
- rvm: 2.0.0
|
6
|
-
- rvm: 2.1.10
|
7
|
-
- rvm: 2.2.6
|
8
|
-
- rvm: 2.3.3
|
9
|
-
- rvm: 2.4.1
|
10
|
-
- rvm: ruby-head
|
11
|
-
allow_failures:
|
12
|
-
- rvm: ruby-head
|
13
|
-
before_install:
|
14
|
-
- sudo apt-get update -qq
|
15
|
-
- sudo apt-get install -y build-essential cmake libpopt-dev libbz2-dev libruby ruby-dev
|
16
|
-
- gem install bundler -v 1.12.5
|
17
|
-
install:
|
18
|
-
- bundle install --jobs=3 --retry=3
|
19
|
-
- bundle exec rake compile
|
data/fast_filter.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'fast_filter/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'fast_filter'
|
8
|
-
spec.version = FastFilter::VERSION
|
9
|
-
spec.authors = ['Dave Allie']
|
10
|
-
spec.email = ['dave@tanda.co']
|
11
|
-
|
12
|
-
spec.summary = 'Native Ruby extension to filter a list quickly.'
|
13
|
-
spec.description = 'Native Ruby extension to filter a list quickly.'
|
14
|
-
spec.homepage = 'https://github.com/TandaHQ/fast_filter'
|
15
|
-
spec.license = 'MIT'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = 'exe'
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
spec.extensions = ['ext/fast_filter/extconf.rb']
|
22
|
-
|
23
|
-
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
-
spec.add_development_dependency 'rake-compiler', '~> 1.0'
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
-
end
|