aerospike_native 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: db2328ae0aa1a80fd33b38b62556564a73e815fc
4
+ data.tar.gz: 8eb2678eab7ba4b55f7529138610a3548cab5ba6
5
+ SHA512:
6
+ metadata.gz: ef3662918b196ae698f15c501ce7a47c8d965ee91a3759c9309d5c9159f48e5de7601e447e554c99eb7d9f81ade85747093ef0888760c7d4bebf5a695203fd22
7
+ data.tar.gz: 0c62bf669ae521a85148f42ebb5de9a18e1ec8afe7343216afdaeb8fc04e0d373d9eeb853cb764127b4dd096e524670ebe8acd8e6cc092d9107c672a87e59e9d
@@ -0,0 +1,26 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ ext/aerospike_native/Makefile
16
+ ext/aerospike_native/aerospike-client-c/
17
+ ext/aerospike_native/lib/
18
+ ext/aerospike_native/include/
19
+
20
+ .idea/
21
+ aerospike_native.config
22
+ aerospike_native.creator
23
+ aerospike_native.files
24
+ aerospike_native.includes
25
+ *.creator.user
26
+ run.sh
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aerospike_native.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Vladimir Ziablitskii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Vladimir Zyablitskiy
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # AerospikeNative
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'aerospike_native'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install aerospike_native
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/aerospike_native/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,47 @@
1
+ #require "bundler/gem_tasks"
2
+
3
+ require 'rake/extensiontask'
4
+ require 'rubygems/package_task'
5
+
6
+ ##
7
+ # Rake::ExtensionTask comes from the rake-compiler and understands how to
8
+ # build and cross-compile extensions.
9
+ #
10
+ # See https://github.com/luislavena/rake-compiler for details
11
+
12
+ Rake::ExtensionTask.new 'aerospike_native' do |ext|
13
+
14
+ # This causes the shared object to be placed in lib/my_malloc/my_malloc.so
15
+ #
16
+ # It allows lib/my_malloc.rb to load different versions if you ship a
17
+ # precompiled extension that supports multiple ruby versions.
18
+
19
+ ext.lib_dir = 'lib/aerospike_native'
20
+ end
21
+
22
+ s = Gem::Specification.new 'aerospike_native', '0.0.1' do |s|
23
+ s.summary = 'simple aerospike extenstion'
24
+ s.authors = %w[zyablitskiy@gmail.com]
25
+
26
+ # this tells RubyGems to build an extension upon install
27
+
28
+ s.extensions = %w[ext/aerospike_native/extconf.rb]
29
+
30
+ # naturally you must include the extension source in the gem
31
+
32
+ s.files = `git ls-files`.split($/)
33
+ end
34
+
35
+ # The package task builds the gem in pkg/my_malloc-1.0.gem so you can test
36
+ # installing it.
37
+
38
+ Gem::PackageTask.new s do end
39
+
40
+ # This isn't a good test, but does provide a sanity check
41
+
42
+ task test: %w[compile] do
43
+ ruby '-Ilib', '-raerospike_native', '-e', "p AerospikeNative::Key.new('namespace', 'set', 'value')"
44
+ end
45
+
46
+ task default: :test
47
+
@@ -0,0 +1,193 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE QtCreatorProject>
3
+ <!-- Written by QtCreator 3.3.1, 2015-06-27T00:06:17. -->
4
+ <qtcreator>
5
+ <data>
6
+ <variable>EnvironmentId</variable>
7
+ <value type="QByteArray">{93aa60d5-4a13-46a0-a50b-d8053e37d65a}</value>
8
+ </data>
9
+ <data>
10
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
11
+ <value type="int">0</value>
12
+ </data>
13
+ <data>
14
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
15
+ <valuemap type="QVariantMap">
16
+ <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
17
+ <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
18
+ <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
19
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
20
+ <value type="QString" key="language">Cpp</value>
21
+ <valuemap type="QVariantMap" key="value">
22
+ <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
23
+ </valuemap>
24
+ </valuemap>
25
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
26
+ <value type="QString" key="language">QmlJS</value>
27
+ <valuemap type="QVariantMap" key="value">
28
+ <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
29
+ </valuemap>
30
+ </valuemap>
31
+ <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
32
+ <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
33
+ <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
34
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
35
+ <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36
+ <value type="int" key="EditorConfiguration.MarginColumn">80</value>
37
+ <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
38
+ <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
39
+ <value type="int" key="EditorConfiguration.PaddingMode">1</value>
40
+ <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41
+ <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
42
+ <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
43
+ <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
44
+ <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
45
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
46
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
47
+ <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
48
+ <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
49
+ <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
50
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
51
+ <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
52
+ </valuemap>
53
+ </data>
54
+ <data>
55
+ <variable>ProjectExplorer.Project.PluginSettings</variable>
56
+ <valuemap type="QVariantMap"/>
57
+ </data>
58
+ <data>
59
+ <variable>ProjectExplorer.Project.Target.0</variable>
60
+ <valuemap type="QVariantMap">
61
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
62
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
63
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{67e3e301-82cd-498d-a671-f86202cae2db}</value>
64
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
65
+ <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66
+ <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
67
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
68
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/rain/projects/aerospike_native</value>
69
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
70
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
71
+ <valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
72
+ <value type="QString">all</value>
73
+ </valuelist>
74
+ <value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">false</value>
75
+ <value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
76
+ <value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
77
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
78
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
79
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
80
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
81
+ </valuemap>
82
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
83
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
84
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
85
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
86
+ </valuemap>
87
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
88
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
89
+ <valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
90
+ <value type="QString">clean</value>
91
+ </valuelist>
92
+ <value type="bool" key="GenericProjectManager.GenericMakeStep.Clean">true</value>
93
+ <value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments"></value>
94
+ <value type="QString" key="GenericProjectManager.GenericMakeStep.MakeCommand"></value>
95
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
96
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
97
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
98
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
99
+ </valuemap>
100
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
101
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
102
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
103
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
104
+ </valuemap>
105
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
106
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
107
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
108
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Default</value>
109
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
110
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericBuildConfiguration</value>
111
+ </valuemap>
112
+ <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
113
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
114
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
115
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
116
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
117
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
118
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
119
+ </valuemap>
120
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
121
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
122
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
123
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
124
+ </valuemap>
125
+ <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
126
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
127
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
128
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
129
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
130
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
131
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
132
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
133
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
134
+ <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
135
+ <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
136
+ <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
137
+ <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
138
+ <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
139
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
140
+ <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
141
+ <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
142
+ <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
143
+ <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
144
+ <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
145
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
146
+ <value type="int">0</value>
147
+ <value type="int">1</value>
148
+ <value type="int">2</value>
149
+ <value type="int">3</value>
150
+ <value type="int">4</value>
151
+ <value type="int">5</value>
152
+ <value type="int">6</value>
153
+ <value type="int">7</value>
154
+ <value type="int">8</value>
155
+ <value type="int">9</value>
156
+ <value type="int">10</value>
157
+ <value type="int">11</value>
158
+ <value type="int">12</value>
159
+ <value type="int">13</value>
160
+ <value type="int">14</value>
161
+ </valuelist>
162
+ <value type="int" key="PE.EnvironmentAspect.Base">2</value>
163
+ <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
164
+ <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
165
+ <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
166
+ <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
167
+ <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
168
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
169
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
170
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
171
+ <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
172
+ <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
173
+ <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
174
+ <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
175
+ <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
176
+ <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
177
+ </valuemap>
178
+ <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
179
+ </valuemap>
180
+ </data>
181
+ <data>
182
+ <variable>ProjectExplorer.Project.TargetCount</variable>
183
+ <value type="int">1</value>
184
+ </data>
185
+ <data>
186
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
187
+ <value type="int">18</value>
188
+ </data>
189
+ <data>
190
+ <variable>Version</variable>
191
+ <value type="int">18</value>
192
+ </data>
193
+ </qtcreator>
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'aerospike_native/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aerospike_native"
8
+ spec.version = AerospikeNative::VERSION
9
+ spec.authors = ["Vladimir Ziablitskii"]
10
+ spec.email = ["zyablitskiy@gmail.com"]
11
+ spec.summary = %q{Aerospike native client}
12
+ spec.description = %q{Aerospike ruby client with c extension}
13
+ spec.homepage = "https://github.com/rainlabs/aerospike_native"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.extensions = %w[ext/aerospike_native/extconf.rb]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake-compiler"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,15 @@
1
+ //#include <iostream>
2
+ #include "aerospike_native.h"
3
+ #include "client.h"
4
+ #include "key.h"
5
+ #include "operation.h"
6
+
7
+ VALUE AerospikeNativeClass;
8
+
9
+ void Init_aerospike_native()
10
+ {
11
+ AerospikeNativeClass = rb_define_module("AerospikeNative");
12
+ define_client();
13
+ define_key();
14
+ define_operation();
15
+ }
@@ -0,0 +1,10 @@
1
+ #ifndef AEROSPIKE_NATIVE_H
2
+ #define AEROSPIKE_NATIVE_H
3
+
4
+ #include <ruby.h>
5
+ #include <aerospike/aerospike.h>
6
+
7
+ extern VALUE AerospikeNativeClass;
8
+
9
+ #endif // AEROSPIKE_NATIVE_H
10
+
@@ -0,0 +1,179 @@
1
+ #include "client.h"
2
+ #include "operation.h"
3
+ #include <aerospike/as_key.h>
4
+ #include <aerospike/as_operations.h>
5
+ #include <aerospike/aerospike_key.h>
6
+
7
+ VALUE ClientClass;
8
+
9
+ static void client_deallocate(void *p)
10
+ {
11
+ aerospike* ptr = p;
12
+ as_error err;
13
+
14
+ aerospike_close(ptr, &err);
15
+ aerospike_destroy(ptr);
16
+ }
17
+
18
+ static VALUE client_allocate(VALUE klass)
19
+ {
20
+ VALUE obj;
21
+ aerospike *ptr;
22
+
23
+ obj = Data_Make_Struct(klass, aerospike, NULL, client_deallocate, ptr);
24
+
25
+ return obj;
26
+ }
27
+
28
+ VALUE client_initialize(int argc, VALUE* argv, VALUE self)
29
+ {
30
+ VALUE ary = Qnil;
31
+ aerospike *ptr;
32
+ as_config config;
33
+ as_error err;
34
+ long idx = 0, n = 0;
35
+
36
+ if (argc > 1) { // there should only be 0 or 1 arguments
37
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
38
+ }
39
+
40
+ if (argc == 1) {
41
+ ary = argv[0];
42
+ }
43
+
44
+ switch (TYPE(ary)) {
45
+ case T_NIL:
46
+ case T_ARRAY:
47
+ break;
48
+ default:
49
+ /* raise exception */
50
+ Check_Type(ary, T_ARRAY);
51
+ break;
52
+ }
53
+ Data_Get_Struct(self, aerospike, ptr);
54
+
55
+ as_config_init(&config);
56
+
57
+ if (TYPE(ary) == T_ARRAY) {
58
+ idx = RARRAY_LEN(ary);
59
+ for(n = 0; n < idx; n++) {
60
+ VALUE hash = rb_ary_entry(ary, n);
61
+ VALUE host = rb_hash_aref(hash, rb_str_new2("host"));
62
+ VALUE port = rb_hash_aref(hash, rb_str_new2("port"));
63
+ printf("host: %s:%d\n", StringValueCStr(host), NUM2UINT(port));
64
+ as_config_add_host(&config, StringValueCStr(host), NUM2UINT(port));
65
+ }
66
+ }
67
+
68
+ if (idx == 0) {
69
+ as_config_add_host(&config, "127.0.0.1", 3000);
70
+ }
71
+
72
+ aerospike_init(ptr, &config);
73
+
74
+ if ( aerospike_connect(ptr, &err) != AEROSPIKE_OK ) {
75
+ printf( "Aerospike error (%d) %s at [%s:%d]\n", err.code, err.message, err.file, err.line );
76
+ rb_raise(rb_eRuntimeError, "Aerospike error (%d) %s at [%s:%d]\n", err.code, err.message, err.file, err.line);
77
+ }
78
+ return self;
79
+ }
80
+
81
+ VALUE client_operate(int argc, VALUE* argv, VALUE vSelf)
82
+ {
83
+ VALUE vKey;
84
+ VALUE vOperations;
85
+ VALUE vSettings = Qnil;
86
+ long idx = 0, n = 0;
87
+
88
+ aerospike *ptr;
89
+ as_operations ops;
90
+ as_key key;
91
+ as_error err;
92
+
93
+ VALUE vNamespace, vSet, vKeyValue;
94
+
95
+ if (argc > 3 || argc < 2) { // there should only be 2 or 3 arguments
96
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 3)", argc);
97
+ }
98
+
99
+ vKey = argv[0];
100
+ // char* name = rb_obj_classname(vKey);
101
+ printf("class name: %s\n", rb_obj_classname(vKey));
102
+
103
+ vOperations = argv[1];
104
+ Check_Type(vOperations, T_ARRAY);
105
+
106
+ if (argc == 3) {
107
+ vSettings = argv[2];
108
+
109
+ switch (TYPE(vSettings)) {
110
+ case T_NIL:
111
+ case T_HASH:
112
+ break;
113
+ default:
114
+ /* raise exception */
115
+ Check_Type(vSettings, T_HASH);
116
+ break;
117
+ }
118
+ }
119
+
120
+ idx = RARRAY_LEN(vOperations);
121
+ if (idx == 0) {
122
+ return Qfalse;
123
+ }
124
+
125
+ Data_Get_Struct(vSelf, aerospike, ptr);
126
+ as_operations_inita(&ops, idx);
127
+
128
+ printf("prepare operations\n");
129
+
130
+ for(n = 0; n < idx; n++) {
131
+ VALUE operation = rb_ary_entry(vOperations, n);
132
+ int op_type = NUM2INT( rb_iv_get(operation, "@op_type") );
133
+ VALUE bin_name = rb_iv_get(operation, "@bin_name");
134
+ VALUE bin_value = rb_iv_get(operation, "@bin_value");
135
+
136
+ switch( op_type ) {
137
+ case WRITE:
138
+ break;
139
+ case INCREMENT:
140
+ as_operations_add_incr(&ops, StringValueCStr( bin_name ), NUM2INT( bin_value ));
141
+ break;
142
+ }
143
+ }
144
+
145
+ printf("prepare key\n");
146
+
147
+ vNamespace = rb_iv_get(vKey, "@namespace");
148
+ vSet = rb_iv_get(vKey, "@set");
149
+ vKeyValue = rb_iv_get(vKey, "@value");
150
+ as_key_init_str(&key, StringValueCStr( vNamespace ), StringValueCStr( vSet ), StringValueCStr( vKeyValue ));
151
+
152
+ printf("execute\n");
153
+ if (aerospike_key_operate(ptr, &err, NULL, &key, &ops, NULL) != AEROSPIKE_OK) {
154
+ printf("error\n");
155
+ fprintf(stderr, "err(%d) %s at [%s:%d]\n", err.code, err.message, err.file, err.line);
156
+ }
157
+ printf("finish\n");
158
+
159
+ as_operations_destroy(&ops);
160
+
161
+ return Qtrue;
162
+ }
163
+
164
+ // GET
165
+ // PUT
166
+ // OPERATE
167
+
168
+ // Record
169
+ // Key
170
+ // Bin
171
+ // Policy
172
+
173
+ void define_client()
174
+ {
175
+ ClientClass = rb_define_class_under(AerospikeNativeClass, "Client", rb_cObject);
176
+ rb_define_alloc_func(ClientClass, client_allocate);
177
+ rb_define_method(ClientClass, "initialize", client_initialize, -1);
178
+ rb_define_method(ClientClass, "operate", client_operate, -1);
179
+ }
@@ -0,0 +1,9 @@
1
+ #ifndef CLIENT_H
2
+ #define CLIENT_H
3
+
4
+ #include "aerospike_native.h"
5
+
6
+ extern VALUE ClientClass;
7
+ void define_client();
8
+
9
+ #endif // CLIENT_H
@@ -0,0 +1,37 @@
1
+ require 'mkmf'
2
+
3
+ extension_name = 'aerospike_native'
4
+
5
+ find_executable('make')
6
+ find_executable('git')
7
+ have_library('crypto')
8
+ #have_library('libc')
9
+ #have_library('openssl')
10
+
11
+ headers_path = File.expand_path(File.join(File.dirname(__FILE__), "include"))
12
+ lib_path = File.expand_path(File.join(File.dirname(__FILE__), "lib"))
13
+ aerospike_client_c_dir = File.expand_path(File.join(File.dirname(__FILE__), "aerospike-client-c"))
14
+ `git clone https://github.com/aerospike/aerospike-client-c.git`
15
+ Dir.chdir(aerospike_client_c_dir) do
16
+ `git reset --hard f4aa41fc237fca3e25110d15e72b7735262e6653`
17
+ `git submodule update --init`
18
+ `make`
19
+ target_dir = Dir.glob("target/*").first
20
+ `cp -p #{target_dir}/lib/libaerospike.so #{lib_path}`
21
+ `cp -rp #{target_dir}/include/* #{headers_path}`
22
+ end
23
+
24
+ LIBDIR = RbConfig::CONFIG['libdir']
25
+ INCLUDEDIR = RbConfig::CONFIG['includedir']
26
+
27
+ HEADER_DIRS = [INCLUDEDIR, headers_path]
28
+ LIB_DIRS = [LIBDIR, lib_path]
29
+
30
+ libs = ['-laerospike', '-lcrypto']
31
+ dir_config(extension_name, HEADER_DIRS, LIB_DIRS)
32
+
33
+ libs.each do |lib|
34
+ $LOCAL_LIBS << "#{lib} "
35
+ end
36
+
37
+ create_makefile(extension_name)
@@ -0,0 +1,27 @@
1
+ #include "key.h"
2
+
3
+ VALUE KeyClass;
4
+
5
+ VALUE key_initialize(VALUE vSelf, VALUE vNamespace, VALUE vSet, VALUE vValue)
6
+ {
7
+ Check_Type(vNamespace, T_STRING);
8
+ Check_Type(vSet, T_STRING);
9
+ Check_Type(vValue, T_STRING);
10
+
11
+ rb_iv_set(vSelf, "@namespace", vNamespace);
12
+ rb_iv_set(vSelf, "@set", vSet);
13
+ rb_iv_set(vSelf, "@value", vValue);
14
+
15
+ return vSelf;
16
+ }
17
+
18
+ void define_key()
19
+ {
20
+ KeyClass = rb_define_class_under(AerospikeNativeClass, "Key", rb_cObject);
21
+ rb_define_method(KeyClass, "initialize", key_initialize, 3);
22
+ rb_define_attr(KeyClass, "namespace", 1, 0);
23
+ rb_define_attr(KeyClass, "set", 1, 0);
24
+ rb_define_attr(KeyClass, "value", 1, 0);
25
+ rb_define_attr(KeyClass, "digest", 1, 0);
26
+ }
27
+
@@ -0,0 +1,10 @@
1
+ #ifndef KEY_H
2
+ #define KEY_H
3
+
4
+ #include "aerospike_native.h"
5
+
6
+ extern VALUE KeyClass;
7
+ void define_key();
8
+
9
+ #endif // KEY_H
10
+
@@ -0,0 +1,46 @@
1
+ #include "operation.h"
2
+
3
+ VALUE OperationClass;
4
+
5
+ VALUE operation_initialize(VALUE vSelf, VALUE vOpType, VALUE vBinName, VALUE vBinValue)
6
+ {
7
+ Check_Type(vOpType, T_FIXNUM);
8
+ Check_Type(vBinName, T_STRING);
9
+
10
+ rb_iv_set(vSelf, "@op_type", vOpType);
11
+ rb_iv_set(vSelf, "@bin_name", vBinName);
12
+ rb_iv_set(vSelf, "@bin_value", vBinValue);
13
+
14
+ return vSelf;
15
+ }
16
+
17
+ VALUE operation_write(VALUE vSelf, VALUE vBinName, VALUE vBinValue)
18
+ {
19
+ VALUE vArgs[3];
20
+ vArgs[0] = INT2NUM(WRITE);
21
+ vArgs[1] = vBinName;
22
+ vArgs[2] = vBinValue;
23
+ return rb_class_new_instance(3, vArgs, vSelf);
24
+ }
25
+
26
+ VALUE operation_increment(VALUE vSelf, VALUE vBinName, VALUE vBinValue)
27
+ {
28
+ VALUE vArgs[3];
29
+ vArgs[0] = INT2NUM(INCREMENT);
30
+ vArgs[1] = vBinName;
31
+ vArgs[2] = vBinValue;
32
+ return rb_class_new_instance(3, vArgs, vSelf);
33
+ }
34
+
35
+ void define_operation()
36
+ {
37
+ OperationClass = rb_define_class_under(AerospikeNativeClass, "Operation", rb_cObject);
38
+ rb_define_method(OperationClass, "initialize", operation_initialize, 3);
39
+ rb_define_singleton_method(OperationClass, "write", operation_write, 2);
40
+ rb_define_singleton_method(OperationClass, "increment", operation_increment, 2);
41
+ rb_define_attr(OperationClass, "op_type", 1, 0);
42
+ rb_define_attr(OperationClass, "bin_name", 1, 0);
43
+ rb_define_attr(OperationClass, "bin_value", 1, 0);
44
+ }
45
+
46
+
@@ -0,0 +1,19 @@
1
+ #ifndef OPERATION_H
2
+ #define OPERATION_H
3
+
4
+ #include "aerospike_native.h"
5
+
6
+ extern VALUE OperationClass;
7
+ void define_operation();
8
+
9
+ enum OperationType {
10
+ READ,
11
+ WRITE,
12
+ INCREMENT,
13
+ APPEND,
14
+ PREPEND,
15
+ TOUCH
16
+ };
17
+
18
+ #endif // OPERATION_H
19
+
@@ -0,0 +1,7 @@
1
+ require "aerospike_native/version"
2
+
3
+ module AerospikeNative
4
+ # Your code goes here...
5
+ end
6
+
7
+ #require 'aerospike_native/aerospike_native'
@@ -0,0 +1,3 @@
1
+ module AerospikeNative
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aerospike_native
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vladimir Ziablitskii
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Aerospike ruby client with c extension
70
+ email:
71
+ - zyablitskiy@gmail.com
72
+ executables: []
73
+ extensions:
74
+ - ext/aerospike_native/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - aerospike_native.creator.user.93aa60d
84
+ - aerospike_native.gemspec
85
+ - ext/aerospike_native/aerospike_native.c
86
+ - ext/aerospike_native/aerospike_native.h
87
+ - ext/aerospike_native/client.c
88
+ - ext/aerospike_native/client.h
89
+ - ext/aerospike_native/extconf.rb
90
+ - ext/aerospike_native/include/.keep
91
+ - ext/aerospike_native/key.c
92
+ - ext/aerospike_native/key.h
93
+ - ext/aerospike_native/lib/.keep
94
+ - ext/aerospike_native/operation.c
95
+ - ext/aerospike_native/operation.h
96
+ - lib/aerospike_native.rb
97
+ - lib/aerospike_native/version.rb
98
+ homepage: https://github.com/rainlabs/aerospike_native
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.2
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Aerospike native client
122
+ test_files: []
123
+ has_rdoc: