fast_jsonparser 0.1.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +5 -5
- data/README.md +66 -4
- data/Rakefile +1 -0
- data/ext/fast_jsonparser/fast_jsonparser.cpp +131 -41
- 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 +42 -4
- data/lib/fast_jsonparser/version.rb +1 -1
- metadata +22 -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,46 @@
|
|
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
|
+
parser._parse(source, symbolize_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def load(source, symbolize_keys: true)
|
19
|
+
parser._load(source, symbolize_keys)
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_many(source, symbolize_keys: true, batch_size: DEFAULT_BATCH_SIZE, &block)
|
23
|
+
Native.new._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
|
7
32
|
|
8
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def parser
|
36
|
+
@parser ||= Native.new
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Native
|
41
|
+
end
|
42
|
+
|
43
|
+
require "fast_jsonparser/fast_jsonparser" # loads cpp extension
|
44
|
+
|
45
|
+
private_constant :Native
|
46
|
+
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.5.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-08-25 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
|
@@ -88,8 +102,10 @@ extensions:
|
|
88
102
|
- ext/fast_jsonparser/extconf.rb
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
105
|
+
- ".github/workflows/ruby.yml"
|
91
106
|
- ".gitignore"
|
92
107
|
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
93
109
|
- CODE_OF_CONDUCT.md
|
94
110
|
- Gemfile
|
95
111
|
- Gemfile.lock
|
@@ -101,9 +117,10 @@ files:
|
|
101
117
|
- bin/setup
|
102
118
|
- ext/fast_jsonparser/extconf.rb
|
103
119
|
- ext/fast_jsonparser/fast_jsonparser.cpp
|
120
|
+
- ext/fast_jsonparser/simdjson.cpp
|
121
|
+
- ext/fast_jsonparser/simdjson.h
|
104
122
|
- fast_jsonparser.gemspec
|
105
123
|
- lib/fast_jsonparser.rb
|
106
|
-
- lib/fast_jsonparser/fast_jsonparser.bundle
|
107
124
|
- lib/fast_jsonparser/version.rb
|
108
125
|
homepage: https://github.com/anilmaurya/fast_jsonparser
|
109
126
|
licenses:
|
Binary file
|