riak-client-noenc 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +42 -0
  4. data/.rspec +1 -0
  5. data/Gemfile +17 -0
  6. data/Guardfile +20 -0
  7. data/LICENSE.md +16 -0
  8. data/README.markdown +640 -0
  9. data/RELEASE_NOTES.md +392 -0
  10. data/Rakefile +119 -0
  11. data/lib/riak.rb +22 -0
  12. data/lib/riak/bucket.rb +297 -0
  13. data/lib/riak/bucket_properties.rb +74 -0
  14. data/lib/riak/bucket_type.rb +77 -0
  15. data/lib/riak/bucket_typed/bucket.rb +121 -0
  16. data/lib/riak/client.rb +433 -0
  17. data/lib/riak/client/beefcake/bucket_properties_operator.rb +178 -0
  18. data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -0
  19. data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -0
  20. data/lib/riak/client/beefcake/crdt/set_loader.rb +18 -0
  21. data/lib/riak/client/beefcake/crdt_loader.rb +84 -0
  22. data/lib/riak/client/beefcake/crdt_operator.rb +223 -0
  23. data/lib/riak/client/beefcake/footer +4 -0
  24. data/lib/riak/client/beefcake/header +6 -0
  25. data/lib/riak/client/beefcake/message_codes.rb +89 -0
  26. data/lib/riak/client/beefcake/message_overlay.rb +87 -0
  27. data/lib/riak/client/beefcake/messages.rb +772 -0
  28. data/lib/riak/client/beefcake/object_methods.rb +112 -0
  29. data/lib/riak/client/beefcake/protocol.rb +105 -0
  30. data/lib/riak/client/beefcake/socket.rb +260 -0
  31. data/lib/riak/client/beefcake_protobuffs_backend.rb +538 -0
  32. data/lib/riak/client/decaying.rb +36 -0
  33. data/lib/riak/client/feature_detection.rb +120 -0
  34. data/lib/riak/client/instrumentation.rb +19 -0
  35. data/lib/riak/client/node.rb +49 -0
  36. data/lib/riak/client/protobuffs_backend.rb +143 -0
  37. data/lib/riak/client/search.rb +27 -0
  38. data/lib/riak/client/yokozuna.rb +52 -0
  39. data/lib/riak/conflict.rb +13 -0
  40. data/lib/riak/core_ext.rb +7 -0
  41. data/lib/riak/core_ext/blank.rb +53 -0
  42. data/lib/riak/core_ext/deep_dup.rb +13 -0
  43. data/lib/riak/core_ext/extract_options.rb +7 -0
  44. data/lib/riak/core_ext/json.rb +15 -0
  45. data/lib/riak/core_ext/slice.rb +18 -0
  46. data/lib/riak/core_ext/stringify_keys.rb +10 -0
  47. data/lib/riak/core_ext/symbolize_keys.rb +10 -0
  48. data/lib/riak/core_ext/to_param.rb +31 -0
  49. data/lib/riak/counter.rb +101 -0
  50. data/lib/riak/crdt.rb +21 -0
  51. data/lib/riak/crdt/base.rb +183 -0
  52. data/lib/riak/crdt/batch_counter.rb +19 -0
  53. data/lib/riak/crdt/batch_map.rb +41 -0
  54. data/lib/riak/crdt/counter.rb +82 -0
  55. data/lib/riak/crdt/inner_counter.rb +81 -0
  56. data/lib/riak/crdt/inner_flag.rb +42 -0
  57. data/lib/riak/crdt/inner_map.rb +75 -0
  58. data/lib/riak/crdt/inner_register.rb +26 -0
  59. data/lib/riak/crdt/inner_set.rb +102 -0
  60. data/lib/riak/crdt/map.rb +121 -0
  61. data/lib/riak/crdt/operation.rb +19 -0
  62. data/lib/riak/crdt/set.rb +166 -0
  63. data/lib/riak/crdt/typed_collection.rb +181 -0
  64. data/lib/riak/encoding.rb +6 -0
  65. data/lib/riak/errors/backend_creation.rb +9 -0
  66. data/lib/riak/errors/base.rb +9 -0
  67. data/lib/riak/errors/connection_error.rb +50 -0
  68. data/lib/riak/errors/crdt_error.rb +38 -0
  69. data/lib/riak/errors/failed_request.rb +58 -0
  70. data/lib/riak/errors/protobuffs_error.rb +11 -0
  71. data/lib/riak/errors/search_error.rb +35 -0
  72. data/lib/riak/i18n.rb +7 -0
  73. data/lib/riak/index_collection.rb +71 -0
  74. data/lib/riak/instrumentation.rb +6 -0
  75. data/lib/riak/json.rb +52 -0
  76. data/lib/riak/link.rb +96 -0
  77. data/lib/riak/list_buckets.rb +28 -0
  78. data/lib/riak/locale/en.yml +107 -0
  79. data/lib/riak/locale/fr.yml +51 -0
  80. data/lib/riak/map_reduce.rb +295 -0
  81. data/lib/riak/map_reduce/filter_builder.rb +103 -0
  82. data/lib/riak/map_reduce/phase.rb +98 -0
  83. data/lib/riak/map_reduce/results.rb +49 -0
  84. data/lib/riak/map_reduce_error.rb +7 -0
  85. data/lib/riak/multiget.rb +122 -0
  86. data/lib/riak/preflist_item.rb +7 -0
  87. data/lib/riak/rcontent.rb +173 -0
  88. data/lib/riak/robject.rb +222 -0
  89. data/lib/riak/search.rb +11 -0
  90. data/lib/riak/search/index.rb +87 -0
  91. data/lib/riak/search/query.rb +141 -0
  92. data/lib/riak/search/result_collection.rb +144 -0
  93. data/lib/riak/search/result_document.rb +129 -0
  94. data/lib/riak/search/schema.rb +65 -0
  95. data/lib/riak/secondary_index.rb +81 -0
  96. data/lib/riak/serializers.rb +73 -0
  97. data/lib/riak/stamp.rb +77 -0
  98. data/lib/riak/util/escape.rb +80 -0
  99. data/lib/riak/util/tcp_socket_extensions.rb +58 -0
  100. data/lib/riak/util/translation.rb +18 -0
  101. data/lib/riak/version.rb +3 -0
  102. data/lib/riak/walk_spec.rb +145 -0
  103. data/spec/failover/failover.rb +59 -0
  104. data/spec/fixtures/bitcask.txt +25 -0
  105. data/spec/fixtures/cat.jpg +0 -0
  106. data/spec/fixtures/multipart-basic-conflict.txt +15 -0
  107. data/spec/fixtures/multipart-blank.txt +7 -0
  108. data/spec/fixtures/multipart-mapreduce.txt +10 -0
  109. data/spec/fixtures/multipart-with-body.txt +16 -0
  110. data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -0
  111. data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -0
  112. data/spec/fixtures/server.cert.crt +15 -0
  113. data/spec/fixtures/server.cert.key +15 -0
  114. data/spec/fixtures/test.pem +1 -0
  115. data/spec/fixtures/yz_schema_template.xml +18 -0
  116. data/spec/integration/riak/bucket_types_spec.rb +270 -0
  117. data/spec/integration/riak/conflict_resolution_spec.rb +96 -0
  118. data/spec/integration/riak/counters_spec.rb +36 -0
  119. data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
  120. data/spec/integration/riak/crdt_search_spec.rb +176 -0
  121. data/spec/integration/riak/crdt_spec.rb +250 -0
  122. data/spec/integration/riak/crdt_validation/map_spec.rb +63 -0
  123. data/spec/integration/riak/crdt_validation/set_spec.rb +122 -0
  124. data/spec/integration/riak/preflist_spec.rb +31 -0
  125. data/spec/integration/riak/properties_spec.rb +69 -0
  126. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +33 -0
  127. data/spec/integration/riak/protobuffs_backends_spec.rb +40 -0
  128. data/spec/integration/riak/search_spec.rb +104 -0
  129. data/spec/integration/riak/secondary_index_spec.rb +72 -0
  130. data/spec/integration/riak/security_spec.rb +100 -0
  131. data/spec/integration/riak/threading_spec.rb +150 -0
  132. data/spec/integration/yokozuna/index_spec.rb +61 -0
  133. data/spec/integration/yokozuna/queries_spec.rb +115 -0
  134. data/spec/integration/yokozuna/schema_spec.rb +49 -0
  135. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +247 -0
  136. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +222 -0
  137. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +23 -0
  138. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +189 -0
  139. data/spec/riak/beefcake_protobuffs_backend_spec.rb +162 -0
  140. data/spec/riak/bucket_properties_spec.rb +135 -0
  141. data/spec/riak/bucket_spec.rb +275 -0
  142. data/spec/riak/bucket_type_spec.rb +50 -0
  143. data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
  144. data/spec/riak/client_spec.rb +246 -0
  145. data/spec/riak/core_ext/to_param_spec.rb +15 -0
  146. data/spec/riak/counter_spec.rb +122 -0
  147. data/spec/riak/crdt/counter_spec.rb +55 -0
  148. data/spec/riak/crdt/inner_counter_spec.rb +21 -0
  149. data/spec/riak/crdt/inner_flag_spec.rb +39 -0
  150. data/spec/riak/crdt/inner_map_spec.rb +47 -0
  151. data/spec/riak/crdt/inner_register_spec.rb +40 -0
  152. data/spec/riak/crdt/inner_set_spec.rb +33 -0
  153. data/spec/riak/crdt/map_spec.rb +78 -0
  154. data/spec/riak/crdt/set_spec.rb +61 -0
  155. data/spec/riak/crdt/shared_examples.rb +74 -0
  156. data/spec/riak/crdt/typed_collection_spec.rb +225 -0
  157. data/spec/riak/escape_spec.rb +72 -0
  158. data/spec/riak/feature_detection_spec.rb +77 -0
  159. data/spec/riak/index_collection_spec.rb +53 -0
  160. data/spec/riak/instrumentation_spec.rb +124 -0
  161. data/spec/riak/link_spec.rb +85 -0
  162. data/spec/riak/list_buckets_spec.rb +41 -0
  163. data/spec/riak/map_reduce/filter_builder_spec.rb +32 -0
  164. data/spec/riak/map_reduce/phase_spec.rb +142 -0
  165. data/spec/riak/map_reduce_spec.rb +434 -0
  166. data/spec/riak/multiget_spec.rb +81 -0
  167. data/spec/riak/node_spec.rb +26 -0
  168. data/spec/riak/robject_spec.rb +496 -0
  169. data/spec/riak/search/index_spec.rb +72 -0
  170. data/spec/riak/search/query_spec.rb +88 -0
  171. data/spec/riak/search/result_collection_spec.rb +89 -0
  172. data/spec/riak/search/result_document_spec.rb +106 -0
  173. data/spec/riak/search/schema_spec.rb +63 -0
  174. data/spec/riak/search_spec.rb +107 -0
  175. data/spec/riak/secondary_index_spec.rb +225 -0
  176. data/spec/riak/serializers_spec.rb +121 -0
  177. data/spec/riak/stamp_spec.rb +54 -0
  178. data/spec/riak/walk_spec_spec.rb +203 -0
  179. data/spec/spec_helper.rb +66 -0
  180. data/spec/support/certs/README.md +13 -0
  181. data/spec/support/certs/ca.crt +21 -0
  182. data/spec/support/certs/client.crl +13 -0
  183. data/spec/support/certs/client.crt +94 -0
  184. data/spec/support/certs/client.csr +18 -0
  185. data/spec/support/certs/client.key +27 -0
  186. data/spec/support/certs/empty_ca.crt +21 -0
  187. data/spec/support/certs/server.crl +13 -0
  188. data/spec/support/certs/server.crt +94 -0
  189. data/spec/support/certs/server.key +27 -0
  190. data/spec/support/crdt_search_config.rb +112 -0
  191. data/spec/support/crdt_search_fixtures.rb +42 -0
  192. data/spec/support/integration_setup.rb +10 -0
  193. data/spec/support/search_config.rb +83 -0
  194. data/spec/support/search_corpus_setup.rb +39 -0
  195. data/spec/support/test_client.rb +46 -0
  196. data/spec/support/test_client.yml.example +10 -0
  197. data/spec/support/unified_backend_examples.rb +380 -0
  198. data/spec/support/version_filter.rb +12 -0
  199. data/spec/support/wait_until.rb +20 -0
  200. metadata +511 -0
@@ -0,0 +1,25 @@
1
+ Bitcask is an Erlang application that provides an API for storing and retrieving key/value data into a log-structured hash table that provides very fast access. The design owes a lot to the principles found in log-structured file systems and draws inspiration from a number of designs that involve log file merging.
2
+
3
+ Strengths
4
+ Low latency per item read or written
5
+ This is due to the write-once, append-only nature of the Bitcask database files. High throughput, especially when writing an incoming stream of random items Because the data being written doesn't need to be ordered on disk and because the log structured design allows for minimal disk head movement during writes these operations generally saturate the I/O and disk bandwidth.
6
+
7
+ Ability to handle datasets larger than RAM w/o degradation
8
+ Because access to data in Bitcask is direct lookup from an in-memory hash table finding data on disk is very efficient, even when data sets are very large.
9
+
10
+ Single Seek to Retrieve Any Value
11
+ Bitcask's in-memory hash-table of keys point directly to locations on disk where the data lives. Bitcask never uses more than one disk seek to read a value and sometimes, due to file-system caching done by the operating system, even that isn't necessary.
12
+
13
+ Predictable Lookup and Insert Performance
14
+ As you might expect from the description above, read operations have a fixed, predictable behavior. What you might not expect is that this is also true for writes. Write operations are at most a seek to the end of the current file open writing and an append to that file.
15
+
16
+ Fast, bounded Crash Recovery
17
+ Due to the append-only write once nature of Bitcask files, recovery is easy and fast. The only items that might be lost are partially written records at the tail of the file last opened for writes. Recovery need only review the last record or two written and verify CRC data to ensure that the data is consistent.
18
+
19
+ Easy Backup
20
+ In most systems backup can be very complicated but here again Bitcask simplifies this process due to its append-only write once disk format. Any utility that archives or copies files in disk-block order will properly backup or copy a Bitcask database.
21
+
22
+ Weakness
23
+ Keys Must Fit In Memory
24
+ Bitcask keeps all keys in memory at all times, this means that your system must have enough memory to contain your entire keyspace with room for other operational components and operating system resident filesystem buffer space.
25
+
Binary file
@@ -0,0 +1,15 @@
1
+ --8XZD3w6ttFTHIz6LCmhVxn9Ex0K
2
+ Content-Type: text/plain
3
+ Link: </buckets/test>; rel="up"
4
+ Etag: 2baUwethOoLrVkwnMqzBRW
5
+ Last-Modified: Mon, 15 Oct 2012 19:36:06 GMT
6
+
7
+ bar
8
+ --8XZD3w6ttFTHIz6LCmhVxn9Ex0K
9
+ Content-Type: text/plain
10
+ Link: </buckets/test>; rel="up"
11
+ Etag: 6NtlHf8Lc3TEcCTKOVqEkl
12
+ Last-Modified: Mon, 15 Oct 2012 19:35:57 GMT
13
+
14
+ foo
15
+ --8XZD3w6ttFTHIz6LCmhVxn9Ex0K--
@@ -0,0 +1,7 @@
1
+
2
+ --73NmmA8dJxSB5nL2dVerpFIi8ze
3
+ Content-Type: multipart/mixed; boundary=8fPXq9XfV15txMoV1IbA3hovEij
4
+
5
+ --8fPXq9XfV15txMoV1IbA3hovEij--
6
+
7
+ --73NmmA8dJxSB5nL2dVerpFIi8ze--
@@ -0,0 +1,10 @@
1
+
2
+ --NT6cqYFYCfbYZsocVt15tNWCpG9
3
+ Content-Type: application/json
4
+
5
+ {"phase":0,"data":["source :gemcutter\n\ngem 'i18n'\ngem 'builder'\ngem 'rspec', \"~>2.0.0\"\ngem 'fakeweb', \">=1.2\"\ngem 'rack', '>=1.0'\ngem 'rake'\ngem 'bundler'\ngem 'excon', \"~>0.3.4\"\n\nif defined? JRUBY_VERSION\n gem 'json'\n gem 'jruby-openssl'\nelse\n gem 'curb', '>=0.6'\n gem 'yajl-ruby'\nend\n\ngroup :integration do\n gem 'activesupport', '~>3.0'\nend\n"]}
6
+ --NT6cqYFYCfbYZsocVt15tNWCpG9
7
+ Content-Type: application/json
8
+
9
+ {"phase":0,"data":["source \"http://rubygems.org\"\n\ngem 'rake'\ngem 'gollum-site'\ngem 'rdiscount'\ngem 'RedCloth'\ngem 'rspec'\n"]}
10
+ --NT6cqYFYCfbYZsocVt15tNWCpG9--
@@ -0,0 +1,16 @@
1
+
2
+ --5EiMOjuGavQ2IbXAqsJPLLfJNlA
3
+ Content-Type: multipart/mixed; boundary=7extjTzvYIKVMVHowUiTn0LfvSs
4
+
5
+ --7extjTzvYIKVMVHowUiTn0LfvSs
6
+ X-Riak-Vclock: a85hYGBgyWDKBVHMr9s3ZzAlMuaxMtyZcPAIH1RYyObHDqiwxIZjcOG1M98chAq3bUQIz7SSFQEKM4FUbwMKZwEA
7
+ Location: /riak/foo/baz
8
+ Content-Type: text/plain
9
+ Link: </riak/foo>; rel="up"
10
+ Etag: 6JdI51eFrvv5lDwY6un7a2
11
+ Last-Modified: Sat, 16 Jan 2010 22:13:44 GMT
12
+
13
+ SCP sloooow....
14
+ --7extjTzvYIKVMVHowUiTn0LfvSs--
15
+
16
+ --5EiMOjuGavQ2IbXAqsJPLLfJNlA--
@@ -0,0 +1,17 @@
1
+
2
+ --ADqgQtdmA5iQgyR5UGzX6V3HZtI
3
+ Content-Type: multipart/mixed; boundary=Ljz1mP3hZzqPu6DH1Y4L8k7hfxy
4
+
5
+ --Ljz1mP3hZzqPu6DH1Y4L8k7hfxy
6
+ X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvrNPcuWwZTIlMfKIOotdIIvCwA=
7
+ Location: /buckets/links/keys/target
8
+ Content-Type: application/octet-stream
9
+ Link: </buckets/links>; rel="up"
10
+ Etag: 5bUNdzHJhZDdCr7KlWxXq
11
+ Last-Modified: Tue, 18 Oct 2011 19:10:13 GMT
12
+ X-Riak-Deleted: true
13
+
14
+
15
+ --Ljz1mP3hZzqPu6DH1Y4L8k7hfxy--
16
+
17
+ --ADqgQtdmA5iQgyR5UGzX6V3HZtI--
@@ -0,0 +1,16 @@
1
+
2
+ --CvfrSTCWwIiwezy0Zt1B2zwKgS7
3
+ Content-Type: multipart/mixed; boundary=E9n2ZOKHIazIoPHzXj9XsWYWJjJ
4
+
5
+ --E9n2ZOKHIazIoPHzXj9XsWYWJjJ
6
+ X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fvpN53+WwZTIlMfKcNVJ6ARfFgA=
7
+ Location: /buckets/links/keys/target
8
+ Content-Type: application/octet-stream
9
+ Link: </buckets/links>; rel="up"
10
+ Etag: 50FOyLo7juvEVUO33MRJwP
11
+ Last-Modified: Tue, 18 Oct 2011 18:35:01 GMT
12
+
13
+
14
+ --E9n2ZOKHIazIoPHzXj9XsWYWJjJ--
15
+
16
+ --CvfrSTCWwIiwezy0Zt1B2zwKgS7--
@@ -0,0 +1,15 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICPzCCAagCCQDfZhEdJjSgTDANBgkqhkiG9w0BAQUFADBkMQswCQYDVQQGEwJV
3
+ UzELMAkGA1UECBMCTkMxEjAQBgNVBAcTCUNoYXJsb3R0ZTEOMAwGA1UEChMFQmFz
4
+ aG8xEDAOBgNVBAsTB1N1cHBvcnQxEjAQBgNVBAMTCTEyNy4wLjAuMTAeFw0xMTAz
5
+ MjYxNjMzMzNaFw0zODA4MTAxNjMzMzNaMGQxCzAJBgNVBAYTAlVTMQswCQYDVQQI
6
+ EwJOQzESMBAGA1UEBxMJQ2hhcmxvdHRlMQ4wDAYDVQQKEwVCYXNobzEQMA4GA1UE
7
+ CxMHU3VwcG9ydDESMBAGA1UEAxMJMTI3LjAuMC4xMIGfMA0GCSqGSIb3DQEBAQUA
8
+ A4GNADCBiQKBgQCtfHMCsR86HQEAsO52/WvtFWCEigXll0rxYjXvdqeszEPEMFIy
9
+ Qlg3GlRxH51YrBzp46ReF9Qv5sf0Nh6SR7HGzlWmMEVfPeuAKcz1fzVcjD+IXWHK
10
+ qklAQjpxz+18dvaGxQ7ZJMPsBlq1v64siTLXI0yhjxXOuQPJWrWsvuuXkQIDAQAB
11
+ MA0GCSqGSIb3DQEBBQUAA4GBAIqt1A5Ah7s2oUoYQ8YCKC83fKbXbbNCiLFLwIzy
12
+ TGYXd8j7JTfeY8ettbtitlYgP+ouf23LzonuMo47GRuMgVKRWm4l+ZVMP5Qbkx9t
13
+ uspx+6lHUWnMT9aRdP9/2I7dscyfuhtzs0UxddADLzL9Cif4Y06E1NhR/KK+zo46
14
+ Nep8
15
+ -----END CERTIFICATE-----
@@ -0,0 +1,15 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIICXQIBAAKBgQCtfHMCsR86HQEAsO52/WvtFWCEigXll0rxYjXvdqeszEPEMFIy
3
+ Qlg3GlRxH51YrBzp46ReF9Qv5sf0Nh6SR7HGzlWmMEVfPeuAKcz1fzVcjD+IXWHK
4
+ qklAQjpxz+18dvaGxQ7ZJMPsBlq1v64siTLXI0yhjxXOuQPJWrWsvuuXkQIDAQAB
5
+ AoGBAJIguzdPPgBTId8VKSes+lVupie9oo3qy8NaeBfGGCIixAnisbmHzIpNcUb/
6
+ 3CcuggQ4LODcrWvTtiTr2QBZx1FL7E4POBJl/N7zJMaQd+pGjmrJGfv5haSSQN+H
7
+ r74Ix3HCd0RPdSgt5pmlT4KfsqkfRmqsPd6Nw54zbyLFMlTpAkEA4ar3ZJi2+Y+u
8
+ FH3AycXuPdDtVW0tKFtxfvKlS48gshB6gmkd06Ugss5eZkdbSY0voAp88Tr2shOJ
9
+ +pXc++Zl6wJBAMTN9K9k728cVCf41pR6mDVxIaaqjJeY4DWppGQFSqw/fmYz/Quu
10
+ PlTvk6pGRYiGN6y9CZFNoL2I/SWcd4ukrXMCQCyfYOHsbKn2Zka5Awki8VQZ3wQ4
11
+ XWiQhGXE1ziUqbNsHL1yyaoTCd8xfWseCwgFOficek49CZD22h7JyXOqAFcCQCn2
12
+ mFPFu9//NFqJjod+VHIgu0IkX3H7oOMQVwMUtcVgjH0SXMRe1N+bbesCrNTdeYWV
13
+ kTKwULPZP9EDOeJGrM0CQQCsX+8VZ15yKTy6ADINrOt26PNpD4ib4552TE6T/1wG
14
+ LKdjn5l0qB5K7ILc22z3LCenNBa0Uxbg5/RSdoX57aHA
15
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ i-am-a-pem
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <schema name="SCHEMA_NAME" version="1.5">
3
+ <fields>
4
+ <field name="_yz_id" type="_yz_str" indexed="true" stored="true" multiValued="false" required="true" />
5
+ <field name="_yz_ed" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
6
+ <field name="_yz_pn" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
7
+ <field name="_yz_fpn" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
8
+ <field name="_yz_vtag" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
9
+ <field name="_yz_rk" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
10
+ <field name="_yz_rb" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
11
+ <field name="_yz_rt" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
12
+ <field name="_yz_err" type="_yz_str" indexed="true" stored="true" multiValued="false"/>
13
+ </fields>
14
+ <uniqueKey>_yz_id</uniqueKey>
15
+ <types>
16
+ <fieldType name="_yz_str" class="solr.StrField" sortMissingLast="true" />
17
+ </types>
18
+ </schema>
@@ -0,0 +1,270 @@
1
+ require 'spec_helper'
2
+ require 'riak'
3
+
4
+ describe 'Bucket Types', test_client: true, integration: true do
5
+
6
+ describe 'nested bucket types API' do
7
+ let(:bucket_type){ test_client.bucket_type 'yokozuna' }
8
+
9
+ it 'exposes bucket type properties' do
10
+ expect(props = bucket_type.properties).to be_a Hash
11
+ expect(props[:allow_mult]).to be
12
+ end
13
+
14
+ describe 'performing key-value operations' do
15
+ let(:bucket){ bucket_type.bucket(random_key) }
16
+ let(:untyped_bucket){ test_client.bucket bucket.name }
17
+
18
+ let(:object) do
19
+ object = bucket.new random_key
20
+ object.data = 'hello'
21
+ object.content_type = 'text/plain'
22
+ object.store
23
+ object
24
+ end
25
+
26
+ let(:untyped_object) do
27
+ untyped_object = untyped_bucket.new object.key
28
+ untyped_object.data = 'oooops'
29
+ untyped_object.content_type = 'text/plain'
30
+ untyped_object.store
31
+ untyped_object
32
+ end
33
+
34
+ it 'initializes with a bucket type' do
35
+ o = bucket.new 'lawnmower'
36
+ o.data = 'reel'
37
+ o.content_type = 'text/plain'
38
+ o.store
39
+
40
+ expect(bucket.get('lawnmower').data).to eq o.data
41
+ expect(bucket.exists?('lawnmower')).to be
42
+ end
43
+
44
+ describe 'loading and modifying a RObject' do
45
+ it "doesn't modify objects in other buckets" do
46
+ expect(o = bucket.get(object.key)).to be
47
+ o.data = 'updated'
48
+ o.store
49
+ o.reload
50
+
51
+ expect(o.data).to eq 'updated'
52
+
53
+ expect{ untyped_bucket.get(object.key)}.to raise_error(/not found/)
54
+
55
+ expect(o3 = bucket.get(object.key)).to be
56
+ expect(o3.data).to eq o.data
57
+ end
58
+
59
+ it "doesn't delete objects in other buckets'" do
60
+ expect{ untyped_object.reload }.to_not raise_error
61
+
62
+ expect(o = bucket.get(object.key)).to be
63
+ o.delete
64
+
65
+ expect{ untyped_object.reload }.to_not raise_error
66
+ end
67
+ end
68
+
69
+ it 'only retrieves with a bucket type' do
70
+ expect(bucket.get(object.key).data).to eq object.data
71
+ expect{ untyped_bucket.get object.key }.to raise_error /not_found/
72
+ end
73
+
74
+ it 'reloads with a bucket type' do
75
+ expect{ object.reload }.to_not raise_error
76
+ expect(object.data).to eq 'hello'
77
+ end
78
+
79
+ it 'lists keys only for the type' do
80
+ expect(untyped_bucket).to be # ensure existence
81
+ expect(object).to be
82
+
83
+ expect(untyped_bucket.keys).to be_empty
84
+ expect(bucket.keys).to include object.key
85
+ end
86
+
87
+ it 'keeps the bucket type attached to value objects' do
88
+ expect(bucket.get(object.key).bucket).to eq bucket
89
+ expect(bucket.get(object.key).bucket.type).to eq bucket_type
90
+ end
91
+
92
+ describe 'deletion' do
93
+ it 'self-deletes with a bucket type' do
94
+ expect(untyped_object).to be # ensure existence
95
+
96
+ expect(object.delete).to be
97
+ expect{ object.reload }.to raise_error /not_found/
98
+ expect(untyped_object).to be
99
+ expect{ untyped_object.reload }.to_not raise_error
100
+ end
101
+
102
+ it 'deletes from the typed bucket' do
103
+ expect(untyped_object).to be # ensure existence
104
+
105
+ expect(bucket.delete object.key).to be
106
+ expect{ object.reload }.to raise_error /not_found/
107
+ expect{ untyped_object.reload }.to_not raise_error
108
+ end
109
+ end
110
+
111
+ it 'multigets keys' do
112
+ results = bucket.get_many [object.key]
113
+ expect(results[object.key]).to be
114
+ expect(results[object.key].data).to eq object.data
115
+ end
116
+
117
+ describe 'secondary indexes' do
118
+ it 'finds the correct object with a SecondaryIndex instance' do
119
+ expect(untyped_object).to be
120
+ q = Riak::SecondaryIndex.new bucket, '$key', object.key
121
+
122
+ expect(q.keys).to include object.key
123
+ candidate = q.values.first
124
+ expect(candidate.data).to eq object.data
125
+ end
126
+ end
127
+
128
+ describe 'map-reduce' do
129
+ let(:mapred) do
130
+ Riak::MapReduce.new(test_client) do |mr|
131
+ mr.map 'function(obj){return [obj.values[0].data];}', keep: true
132
+ end
133
+ end
134
+
135
+ it 'map-reduces correctly with a typed bucket' do
136
+ expect(object).to be
137
+ expect(untyped_object).to be
138
+
139
+ mapred.add bucket
140
+ result = mapred.run
141
+
142
+ expect(result).to include object.data
143
+ expect(result).to_not include untyped_object.data
144
+ end
145
+
146
+ it 'map-reduces correctly with a robject in a typed bucket' do
147
+ expect(object).to be
148
+ expect(untyped_object).to be
149
+
150
+ mapred.add object
151
+ result = mapred.run
152
+
153
+ expect(result).to include object.data
154
+ expect(result).to_not include untyped_object.data
155
+ end
156
+ end
157
+ end
158
+
159
+ describe 'manipulating bucket properties' do
160
+ let(:bucket_type){ test_client.bucket_type 'yokozuna' }
161
+ let(:bucket){ bucket_type.bucket random_key }
162
+ let(:untyped_bucket){ test_client.bucket bucket.name }
163
+
164
+ it 'allows reading and writing bucket properties' do
165
+ expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['last_write_wins']).to_not be
166
+ expect(test_client.get_bucket_props(untyped_bucket)['last_write_wins']).to_not be
167
+
168
+ # test setting
169
+ expect{ bucket.props = {'last_write_wins' => true} }.to_not raise_error
170
+
171
+ # make sure setting doesn't leak to untyped bucket
172
+ expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['last_write_wins']).to be
173
+ expect(test_client.get_bucket_props(untyped_bucket)['last_write_wins']).to_not be
174
+
175
+ # add canary setting on untyped bucket
176
+ expect{ untyped_bucket.props = { 'n_val' => 1} }.to_not raise_error
177
+
178
+ # make sure canary setting doesn't leak to typed bucket
179
+ expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['n_val']).to_not eq 1
180
+ expect(test_client.get_bucket_props(untyped_bucket)['n_val']).to eq 1
181
+
182
+ # test clearing
183
+ expect{ bucket.clear_props }.to_not raise_error
184
+
185
+ # make sure clearing doesn't leak to canary setting on untyped bucket
186
+ expect(test_client.get_bucket_props(bucket, type: 'yokozuna')['last_write_wins']).to_not be
187
+ expect(test_client.get_bucket_props(untyped_bucket)['n_val']).to eq 1
188
+ end
189
+ end
190
+
191
+ describe 'performing CRDT operations' do
192
+ let(:bucket_type){ test_client.bucket_type 'other_counters' }
193
+ let(:bucket){ bucket_type.bucket random_key }
194
+ let(:counter){ Riak::Crdt::Counter.new bucket, random_key }
195
+
196
+ let(:untyped_bucket){ test_client.bucket bucket.name }
197
+ let(:untyped_counter){ Riak::Crdt::Counter.new untyped_bucket, random_key }
198
+
199
+ it 'overrides default bucket types for CRDTs' do
200
+ expect(untyped_counter.value).to eq 0
201
+ expect(untyped_counter.bucket_type).to eq Riak::Crdt::DEFAULT_BUCKET_TYPES[:counter]
202
+
203
+ untyped_counter.increment
204
+ counter.reload
205
+
206
+ expect(counter.value).to eq 0
207
+ expect(counter.bucket_type).to eq 'other_counters'
208
+ end
209
+ end
210
+ end
211
+
212
+ describe 'option-based bucket types API' do
213
+ let(:bucket){ random_bucket 'bucket_type_spec' }
214
+
215
+ describe 'performing key-value operations' do
216
+ # for the sake of having a non-default one, not search
217
+ let(:bucket_type){ 'yokozuna' }
218
+ let(:object) do
219
+ object = bucket.new random_key
220
+ object.data = 'hello'
221
+ object.content_type = 'text/plain'
222
+ object.store type: bucket_type
223
+ object
224
+ end
225
+
226
+ it 'only retrieves with a bucket type' do
227
+ expect{ bucket.get object.key, type: bucket_type }.to_not raise_error
228
+ expect{ bucket.get object.key }.to raise_error /not_found/
229
+ end
230
+
231
+ it 'deletes from the bucket only with a bucket type' do
232
+ expect(bucket.delete object.key).to eq true
233
+ expect{ bucket.get object.key, type: bucket_type }.to_not raise_error
234
+
235
+ expect{ bucket.delete object.key, type: bucket_type }.to_not raise_error
236
+ expect{ bucket.get object.key, type: bucket_type }.to raise_error /not_found/
237
+ end
238
+
239
+ it 'self-deletes only with a bucket type' do
240
+ expect(object.delete).to be
241
+ expect{ object.reload type: bucket_type }.to_not raise_error
242
+
243
+ expect(object.delete type: bucket_type).to be
244
+ expect{ object.reload type: bucket_type }.to raise_error /not_found/
245
+ end
246
+ end
247
+
248
+ describe 'performing CRDT set operations' do
249
+ let(:bucket_type){ Riak::Crdt::DEFAULT_BUCKET_TYPES[:set] }
250
+ let(:set) do
251
+ set = Riak::Crdt::Set.new bucket, random_key
252
+ set.add random_key
253
+ set
254
+ end
255
+
256
+ it 'retrieves the set blob via key-value using a bucket type' do
257
+ expect{ bucket.get set.key }.to raise_error /not_found/
258
+ expect(bucket.get set.key, type: bucket_type).to be
259
+ end
260
+
261
+ it 'deletes the set blob through the bucket type' do
262
+ expect(bucket.delete set.key).to be
263
+ expect{ bucket.get set.key, type: bucket_type }.to_not raise_error
264
+
265
+ expect(bucket.delete set.key, type: bucket_type).to be
266
+ expect{ bucket.get set.key, type: bucket_type }.to raise_error /not_found/
267
+ end
268
+ end
269
+ end
270
+ end