bigrecord 0.0.7 → 0.0.8

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.
Files changed (107) hide show
  1. data/LICENSE +0 -0
  2. data/README.rdoc +9 -1
  3. data/Rakefile +0 -0
  4. data/VERSION +1 -1
  5. data/examples/bigrecord.yml +2 -5
  6. data/generators/bigrecord/bigrecord_generator.rb +0 -0
  7. data/generators/bigrecord/templates/bigrecord.rake +0 -0
  8. data/generators/bigrecord_migration/bigrecord_migration_generator.rb +0 -0
  9. data/generators/bigrecord_migration/templates/migration.rb +0 -0
  10. data/generators/bigrecord_model/bigrecord_model_generator.rb +0 -0
  11. data/generators/bigrecord_model/templates/migration.rb +0 -0
  12. data/generators/bigrecord_model/templates/model.rb +0 -0
  13. data/generators/bigrecord_model/templates/model_spec.rb +0 -0
  14. data/{doc → guides}/bigrecord_specs.rdoc +0 -0
  15. data/guides/deployment.rdoc +21 -0
  16. data/{doc → guides}/getting_started.rdoc +30 -18
  17. data/init.rb +0 -0
  18. data/install.rb +0 -0
  19. data/lib/big_record/abstract_base.rb +50 -28
  20. data/lib/big_record/action_view_extensions.rb +1 -1
  21. data/lib/big_record/ar_associations/association_collection.rb +0 -0
  22. data/lib/big_record/ar_associations/association_proxy.rb +0 -0
  23. data/lib/big_record/ar_associations/belongs_to_association.rb +0 -0
  24. data/lib/big_record/ar_associations/belongs_to_many_association.rb +0 -0
  25. data/lib/big_record/ar_associations/has_and_belongs_to_many_association.rb +0 -0
  26. data/lib/big_record/ar_associations/has_many_association.rb +0 -0
  27. data/lib/big_record/ar_associations/has_one_association.rb +0 -0
  28. data/lib/big_record/ar_associations.rb +0 -0
  29. data/lib/big_record/ar_reflection.rb +0 -0
  30. data/lib/big_record/attribute_methods.rb +0 -0
  31. data/lib/big_record/base.rb +49 -24
  32. data/lib/big_record/br_associations/association_collection.rb +0 -0
  33. data/lib/big_record/br_associations/association_proxy.rb +0 -0
  34. data/lib/big_record/br_associations/belongs_to_association.rb +0 -0
  35. data/lib/big_record/br_associations/belongs_to_many_association.rb +0 -0
  36. data/lib/big_record/br_associations/cached_item_proxy.rb +0 -0
  37. data/lib/big_record/br_associations/cached_item_proxy_factory.rb +0 -0
  38. data/lib/big_record/br_associations/has_and_belongs_to_many_association.rb +0 -0
  39. data/lib/big_record/br_associations/has_one_association.rb +0 -0
  40. data/lib/big_record/br_associations.rb +0 -0
  41. data/lib/big_record/br_reflection.rb +0 -0
  42. data/lib/big_record/callbacks.rb +0 -0
  43. data/lib/big_record/connection_adapters/abstract/connection_specification.rb +0 -0
  44. data/lib/big_record/connection_adapters/abstract/database_statements.rb +0 -0
  45. data/lib/big_record/connection_adapters/abstract/quoting.rb +1 -1
  46. data/lib/big_record/connection_adapters/abstract_adapter.rb +0 -0
  47. data/lib/big_record/connection_adapters/column.rb +30 -0
  48. data/lib/big_record/connection_adapters/hbase_adapter.rb +0 -0
  49. data/lib/big_record/connection_adapters/hbase_rest_adapter.rb +424 -0
  50. data/lib/big_record/connection_adapters/view.rb +63 -0
  51. data/lib/big_record/connection_adapters.rb +1 -0
  52. data/lib/big_record/deletion.rb +0 -0
  53. data/lib/big_record/dynamic_schema.rb +0 -0
  54. data/lib/big_record/embedded.rb +128 -1
  55. data/lib/big_record/embedded_associations/association_proxy.rb +0 -0
  56. data/lib/big_record/family_span_columns.rb +0 -0
  57. data/lib/big_record/fixtures.rb +0 -0
  58. data/lib/big_record/migration.rb +30 -8
  59. data/lib/big_record/routing_ext.rb +6 -4
  60. data/lib/big_record/timestamp.rb +0 -0
  61. data/lib/big_record/validations.rb +0 -0
  62. data/lib/big_record.rb +5 -3
  63. data/lib/bigrecord.rb +0 -0
  64. data/rails/init.rb +3 -2
  65. data/spec/adapter_benchmark.rb +55 -0
  66. data/spec/connections/bigrecord.yml +4 -2
  67. data/spec/connections/cassandra/connection.rb +0 -0
  68. data/spec/connections/hbase/connection.rb +0 -0
  69. data/spec/debug.log +156 -40724
  70. data/spec/integration/br_associations_spec.rb +0 -0
  71. data/spec/lib/animal.rb +0 -0
  72. data/spec/lib/book.rb +0 -0
  73. data/spec/lib/broken_migrations/duplicate_name/20090706182535_add_animals_table.rb +0 -0
  74. data/spec/lib/broken_migrations/duplicate_name/20090706193019_add_animals_table.rb +0 -0
  75. data/spec/lib/broken_migrations/duplicate_version/20090706190623_add_books_table.rb +0 -0
  76. data/spec/lib/broken_migrations/duplicate_version/20090706190623_add_companies_table.rb +0 -0
  77. data/spec/lib/company.rb +0 -0
  78. data/spec/lib/embedded/web_link.rb +0 -0
  79. data/spec/lib/employee.rb +0 -0
  80. data/spec/lib/migrations/20090706182535_add_animals_table.rb +0 -0
  81. data/spec/lib/migrations/20090706190623_add_books_table.rb +0 -0
  82. data/spec/lib/migrations/20090706193019_add_companies_table.rb +0 -0
  83. data/spec/lib/migrations/20090706194512_add_employees_table.rb +0 -0
  84. data/spec/lib/migrations/20090706195741_add_zoos_table.rb +0 -0
  85. data/spec/lib/novel.rb +2 -0
  86. data/spec/lib/zoo.rb +0 -0
  87. data/spec/spec.opts +0 -0
  88. data/spec/spec_helper.rb +7 -1
  89. data/spec/unit/abstract_base_spec.rb +0 -0
  90. data/spec/unit/adapters/abstract_adapter_spec.rb +0 -0
  91. data/spec/unit/adapters/adapter_shared_spec.rb +0 -0
  92. data/spec/unit/adapters/hbase_adapter_spec.rb +0 -0
  93. data/spec/unit/ar_associations_spec.rb +0 -0
  94. data/spec/unit/base_spec.rb +0 -0
  95. data/spec/unit/br_associations_spec.rb +0 -0
  96. data/spec/unit/embedded_spec.rb +0 -0
  97. data/spec/unit/find_spec.rb +0 -0
  98. data/spec/unit/hash_helper_spec.rb +0 -0
  99. data/spec/unit/migration_spec.rb +0 -0
  100. data/spec/unit/model_spec.rb +0 -0
  101. data/spec/unit/validations_spec.rb +0 -0
  102. data/tasks/bigrecord_tasks.rake +0 -0
  103. data/tasks/data_store.rb +8 -1
  104. data/tasks/gem.rb +2 -2
  105. data/tasks/rdoc.rb +14 -8
  106. data/tasks/spec.rb +0 -0
  107. metadata +10 -6
File without changes
File without changes
@@ -28,15 +28,20 @@ module BigRecord
28
28
  end
29
29
  end
30
30
 
31
- # Although column-oriented databases are generally schema-less, certain ones (like Hbase)
32
- # require the creation of tables and column families ahead of time. The individual columns,
33
- # however, are defined in the model itself and can be modified dynamically without the need for migrations.
31
+ # = Migrations
34
32
  #
35
- # Unless you're familiar with column families, the majority of use cases work perfectly fine within one
36
- # column family. When you generate a bigrecord_model, it will default to creating the :attribute column family.
33
+ # Although column-oriented databases are generally schema-less, certain
34
+ # ones (like HBase) require the creation of tables and column families
35
+ # ahead of time. The individual columns, however, are defined in the model
36
+ # itself and can be modified dynamically without the need for migrations.
37
37
  #
38
- # The following is a standard migration file that creates a table called "Books" with the default
39
- # column family :attribute that has the following option of 100 versions and uses the 'lzo' compression scheme.
38
+ # Unless you're familiar with column families, the majority of use cases
39
+ # work perfectly fine within one column family. When you generate a
40
+ # bigrecord_model, it will default to creating the :attribute column family.
41
+ #
42
+ # The following is a standard migration file that creates a table
43
+ # called "Books" with the default column family :attribute that has the
44
+ # following option of 100 versions and uses the 'lzo' compression scheme.
40
45
  # Leave any options blank for the default value.
41
46
  #
42
47
  # class CreateBooks < BigRecord::Migration
@@ -51,6 +56,23 @@ module BigRecord
51
56
  # end
52
57
  # end
53
58
  #
59
+ # == HBase column family options (HBase specific)
60
+ #
61
+ # * versions: integer. By default, Hbase will store 3 versions of changes for
62
+ # any column family. Changing this value on the creation will change this
63
+ # behavior.
64
+ #
65
+ # * compression: 'none', 'gz', 'lzo'. Defaults to 'none'. Since Hbase 0.20,
66
+ # column families can be stored using compression. The compression scheme
67
+ # you define here must be installed on the Hbase servers!
68
+ #
69
+ # == Migrating
70
+ #
71
+ # Run the following rake task to migrate your tables and column families up
72
+ # to the latest version:
73
+ #
74
+ # rake bigrecord:migrate
75
+ #
54
76
  class Migration
55
77
  @@verbose = true
56
78
  cattr_accessor :verbose
@@ -170,7 +192,7 @@ module BigRecord
170
192
 
171
193
  end
172
194
 
173
- class Migrator#:nodoc:
195
+ class Migrator #:nodoc:
174
196
  class << self
175
197
  def migrate(migrations_path, target_version = nil)
176
198
  case
@@ -1,7 +1,9 @@
1
- # The following overrides are required because we use strings as ids and it's
2
- # possible that these strings are not clean. The default implementation
3
- # escapes them with URI.escape() but its' not good. e.g. '&' becomes &amp; instead of %26
4
- module ActionController
1
+ module ActionController #:nodoc
2
+
3
+ # The following overrides are required because we use strings as ids and it's
4
+ # possible that these strings are not clean. The default implementation
5
+ # escapes them with URI.escape() but its' not good. e.g. '&' becomes
6
+ # &amp; instead of %26.
5
7
  module Routing
6
8
  class PathSegment
7
9
  def interpolation_chunk(value_code = "#{local_name}")
File without changes
File without changes
data/lib/big_record.rb CHANGED
@@ -40,7 +40,7 @@ require dir + '/abstract_base'
40
40
  require dir + '/base'
41
41
  require dir + '/embedded'
42
42
  require dir + '/validations'
43
- require dir + '/callbacks'
43
+ #require dir + '/callbacks'
44
44
  require dir + '/ar_reflection'
45
45
  require dir + '/br_reflection'
46
46
  require dir + '/ar_associations'
@@ -60,7 +60,8 @@ require dir + '/action_view_extensions'
60
60
 
61
61
  BigRecord::Base.class_eval do
62
62
  include BigRecord::Validations
63
- include BigRecord::Callbacks
63
+ # include BigRecord::Callbacks
64
+ include ActiveRecord::Callbacks
64
65
  include BigRecord::Timestamp
65
66
  include BigRecord::ArAssociations
66
67
  include BigRecord::BrAssociations
@@ -74,7 +75,8 @@ end
74
75
 
75
76
  BigRecord::Embedded.class_eval do
76
77
  include BigRecord::Validations
77
- include BigRecord::Callbacks
78
+ # include BigRecord::Callbacks
79
+ include ActiveRecord::Callbacks
78
80
  include BigRecord::Timestamp
79
81
  include BigRecord::ArAssociations
80
82
  include BigRecord::BrAssociations
data/lib/bigrecord.rb CHANGED
File without changes
data/rails/init.rb CHANGED
@@ -10,6 +10,7 @@ begin
10
10
 
11
11
  # Try establishing the connection
12
12
  BigRecord::Base.establish_connection
13
- rescue
14
- puts "[Bigrecord] Couldn't load the config/bigrecord.yml config file. Please bootstrap it into your application with: script/generate bigrecord"
13
+ rescue Exception => e
14
+ puts "[Bigrecord] Error encountered while loading the config file and establishing a connection. Please bootstrap Bigrecord into your application if you haven't done so already with: script/generate bigrecord\n" +
15
+ e.message
15
16
  end
@@ -0,0 +1,55 @@
1
+ # This benchmark was created to give a relative measure of performance
2
+ # between different adapters, e.g. Bigrecord Driver vs Stargate.
3
+ #
4
+ # This is not meant to be a benchmark of real world performance.
5
+ #
6
+ # To use it, run the command:
7
+ # > ruby adapter_benchmark.rb [hbase|hbase_brd]
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'benchmark'
12
+ require 'pathname'
13
+ require 'ruby-debug'
14
+
15
+ SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
16
+ require SPEC_ROOT.parent + 'lib/big_record'
17
+
18
+ BigRecord::Base.configurations = YAML::load(File.open(File.join(File.dirname(__FILE__), "connections", "bigrecord.yml")))
19
+ BigRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "benchmark.log"))
20
+
21
+ environment = (ARGV.pop || "hbase")
22
+ BigRecord::Base.establish_connection(environment)
23
+ BigRecord::Base.logger.info "Connecting to #{environment} data store (#{BigRecord::Base.configurations.inspect})"
24
+
25
+ require 'lib/book'
26
+
27
+ Book.delete_all
28
+ record_ids = []
29
+
30
+ # Benchmark the creation process
31
+ Benchmark.bm do |x|
32
+ x.report("Creating 1000 records") do
33
+ record_ids = 1000.times.collect do |i|
34
+ Book.create(:title => "Book_#{i}", :description => "Book description", :author => "Some Author").id
35
+ end
36
+ end
37
+ end
38
+
39
+ # Reading in those records created previously
40
+ Benchmark.bm do |x|
41
+ x.report("Reading 1000 records") do
42
+ record_ids.each do |id|
43
+ Book.find(id)
44
+ end
45
+ end
46
+ end
47
+
48
+ # Benchmark the scanner functionality
49
+ Benchmark.bm do |x|
50
+ x.report('find(:all)x10') do
51
+ 10.times do |x|
52
+ Book.find(:all)
53
+ end
54
+ end
55
+ end
@@ -1,10 +1,12 @@
1
1
  hbase:
2
+ adapter: hbase_rest
3
+ api_address: http://localhost:8080
4
+ hbase_brd:
2
5
  adapter: hbase
3
6
  zookeeper_quorum: localhost
4
- zookeeper_client_port: 21811
7
+ zookeeper_client_port: 2181
5
8
  drb_host: localhost
6
9
  drb_port: 50001
7
-
8
10
  cassandra:
9
11
  adapter: cassandra
10
12
  address: localhost
File without changes
File without changes