fast_jsonparser 0.1.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +5 -5
- data/README.md +57 -4
- data/Rakefile +1 -0
- data/ext/fast_jsonparser/extconf.rb +1 -1
- data/ext/fast_jsonparser/fast_jsonparser.cpp +94 -37
- data/ext/fast_jsonparser/simdjson.cpp +17654 -0
- data/ext/fast_jsonparser/simdjson.h +7716 -0
- data/fast_jsonparser.gemspec +3 -3
- data/lib/fast_jsonparser.rb +32 -4
- data/lib/fast_jsonparser/version.rb +1 -1
- metadata +21 -5
- data/lib/fast_jsonparser/fast_jsonparser.bundle +0 -0
data/fast_jsonparser.gemspec
CHANGED
@@ -30,9 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
# Specify which files should be added to the gem when it is released.
|
31
31
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
32
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark)/}) }
|
34
34
|
end
|
35
|
-
spec.files.reject! { |fn| fn.include? "simdjson" }
|
36
35
|
spec.bindir = "exe"
|
37
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
37
|
spec.require_paths = ["lib"]
|
@@ -40,8 +39,9 @@ Gem::Specification.new do |spec|
|
|
40
39
|
spec.extensions << "ext/fast_jsonparser/extconf.rb"
|
41
40
|
|
42
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
43
|
-
spec.add_development_dependency "rake", "~>
|
42
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
44
43
|
spec.add_development_dependency "minitest", "~> 5.0"
|
45
44
|
spec.add_development_dependency "rake-compiler"
|
46
45
|
spec.add_development_dependency 'oj'
|
46
|
+
spec.add_development_dependency 'yajl-ruby'
|
47
47
|
end
|
data/lib/fast_jsonparser.rb
CHANGED
@@ -1,8 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fast_jsonparser/version"
|
2
4
|
|
3
5
|
module FastJsonparser
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
Error = Class.new(StandardError)
|
7
|
+
ParseError = Class.new(Error)
|
8
|
+
UnknownError = Class.new(Error)
|
9
|
+
BatchSizeTooSmall = Class.new(Error)
|
10
|
+
|
11
|
+
DEFAULT_BATCH_SIZE = 1_000_000 # from include/simdjson/dom/parser.h
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def parse(source, symbolize_keys: true)
|
15
|
+
_parse(source, symbolize_keys)
|
16
|
+
end
|
7
17
|
|
8
|
-
|
18
|
+
def load(source, symbolize_keys: true)
|
19
|
+
_load(source, symbolize_keys)
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_many(source, symbolize_keys: true, batch_size: DEFAULT_BATCH_SIZE, &block)
|
23
|
+
_load_many(source, symbolize_keys, batch_size, &block)
|
24
|
+
rescue UnknownError => error
|
25
|
+
case error.message
|
26
|
+
when "This parser can't support a document that big"
|
27
|
+
raise BatchSizeTooSmall, "One of the documents was bigger than the batch size (#{batch_size}B), try increasing it."
|
28
|
+
else
|
29
|
+
raise
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require "fast_jsonparser/fast_jsonparser" # loads cpp extension
|
34
|
+
private :_parse, :_load, :_load_many
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_jsonparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anil Maurya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yajl-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Fast Json Parser
|
84
98
|
email:
|
85
99
|
- anilmaurya8dec@gmail.com
|
@@ -90,6 +104,7 @@ extra_rdoc_files: []
|
|
90
104
|
files:
|
91
105
|
- ".gitignore"
|
92
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
93
108
|
- CODE_OF_CONDUCT.md
|
94
109
|
- Gemfile
|
95
110
|
- Gemfile.lock
|
@@ -101,9 +116,10 @@ files:
|
|
101
116
|
- bin/setup
|
102
117
|
- ext/fast_jsonparser/extconf.rb
|
103
118
|
- ext/fast_jsonparser/fast_jsonparser.cpp
|
119
|
+
- ext/fast_jsonparser/simdjson.cpp
|
120
|
+
- ext/fast_jsonparser/simdjson.h
|
104
121
|
- fast_jsonparser.gemspec
|
105
122
|
- lib/fast_jsonparser.rb
|
106
|
-
- lib/fast_jsonparser/fast_jsonparser.bundle
|
107
123
|
- lib/fast_jsonparser/version.rb
|
108
124
|
homepage: https://github.com/anilmaurya/fast_jsonparser
|
109
125
|
licenses:
|
Binary file
|