simdjson 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae827b3ab453c465a3af9475086adf557092daefab0a66efae9df97e3c941244
4
- data.tar.gz: 8a10ce70ecfedfd7d9df703796ebc6872f53b124c22fe542b9fed2088f028711
3
+ metadata.gz: 60fb178b1b5ecb6e64bf62a4c2dd8eff606f84d5165588d1c09050ba2034dc0f
4
+ data.tar.gz: 1aeebbf0945925d29e49dc2bfd9c60bd0fbb8d88a05c3f933f8d289dbf615cb4
5
5
  SHA512:
6
- metadata.gz: 1dd643c0d3a467211c54f52394701b2aa534a831ed9c3d2b29f54b160e978bcc4bd5e651280fb6f770fe28ed5daf5a25c1ff188e53af2b79dd1b650e0cc8fb76
7
- data.tar.gz: a1eb3aa2f62cd17f29f23492e2060d0c10f1df886df0cb6d3cff08613a50f93c302475203093e3052a4fb1a3ceeffb61113ec15958ffe69b34dfe8245076156b
6
+ metadata.gz: fbe1f178fafbf6afabaa4240cbde24f1e6be875c03c7634daf23ff2278766acc167f6b2f3bbd5e6596e5f469bbfab74b65cc0fb7d571b96efe954ee85d700fed
7
+ data.tar.gz: defd9f50ffd8e0161d4330740a81d43a3e27f30ead61fd83e5cbc0e9d727d1a11442dec6e93afe615377658d44c2ac616f0f9977f51fdd047f1678fa23de83f5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # simdjson gem
2
2
 
3
- Experimental binding for [simdjson](https://github.com/lemire/simdjson).
3
+ A Ruby bindings for [simdjson](https://github.com/lemire/simdjson).
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,7 +20,14 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ `Simdjson.parse` returns a Hash (if successful).
24
+
25
+ ```ruby
26
+ require 'simdjson'
27
+
28
+ p Simdjson.parse %|{"a": 12345}| # => {"a"=>12345}
29
+ Simdjson.parse %|abcd| # => raise Simdjson::ParseError
30
+ ```
24
31
 
25
32
  ## Contributing
26
33
 
data/Rakefile CHANGED
@@ -12,9 +12,8 @@ end
12
12
 
13
13
  require 'rake/extensiontask'
14
14
 
15
- task build: :compile
16
-
17
- Rake::ExtensionTask.new('simdjson') do |ext|
15
+ gemspec = Gem::Specification.load(File.expand_path('simdjson.gemspec', __dir__))
16
+ Rake::ExtensionTask.new('simdjson', gemspec) do |ext|
18
17
  ext.lib_dir = 'lib/simdjson'
19
18
  end
20
19
 
@@ -2,8 +2,7 @@
2
2
  #include <string>
3
3
  #include <string_view>
4
4
 
5
- #include "simdjson.h"
6
- #include "simdjson.hpp" // internal header
5
+ #include "simdjson.hpp"
7
6
 
8
7
  VALUE rb_mSimdjson;
9
8
 
@@ -44,11 +43,11 @@ static VALUE make_ruby_object(ParsedJson::Iterator &it) {
44
43
  return LONG2NUM(it.get_integer());
45
44
  } else if (it.is_double()) {
46
45
  return DBL2NUM(it.get_double());
47
- } else if (it.get_type() == 'n') { // TODO replace get_type()
46
+ } else if (it.is_null()) {
48
47
  return Qnil;
49
- } else if (it.get_type() == 't') { // TODO replace get_type()
48
+ } else if (it.is_true()) {
50
49
  return Qtrue;
51
- } else if (it.get_type() == 'f') { // TODO replace get_type()
50
+ } else if (it.is_false()) {
52
51
  return Qfalse;
53
52
  }
54
53
  // unknown case (bug)
@@ -56,6 +55,8 @@ static VALUE make_ruby_object(ParsedJson::Iterator &it) {
56
55
  }
57
56
 
58
57
  static VALUE rb_simdjson_parse(VALUE self, VALUE arg) {
58
+ Check_Type(arg, T_STRING);
59
+
59
60
  const padded_string p{RSTRING_PTR(arg)};
60
61
  ParsedJson pj = build_parsed_json(p);
61
62
  if (!pj.is_valid()) {
@@ -74,3 +75,4 @@ void Init_simdjson(void) {
74
75
  rb_define_module_function(rb_mSimdjson, "parse", reinterpret_cast<VALUE (*)(...)>(rb_simdjson_parse), 1);
75
76
  }
76
77
  }
78
+
@@ -1,6 +1,13 @@
1
1
  #ifndef SIMDJSON_RUBY_H
2
- #define SIMDJSON_RUBY_H 1
2
+ #define SIMDJSON_RUBY_H
3
3
 
4
4
  #include "ruby.h"
5
+ #include "simdjson.h"
6
+
7
+ extern "C" {
8
+
9
+ void Init_simdjson(void);
10
+ }
5
11
 
6
12
  #endif /* SIMDJSON_RUBY_H */
13
+
@@ -1,3 +1,3 @@
1
1
  module Simdjson
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simdjson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - saka1
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-09 00:00:00.000000000 Z
11
+ date: 2019-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips