Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (96 sloc) 3.586 kB
4ed26a8 @mwynholds Add a link for navigation on github.
mwynholds authored
1 **IMPORTANT**: If you are reading this on the main ActiveColumn page on github, please go to
f8700c2 @mwynholds Fix typo in link.
mwynholds authored
2 [the actual README page](./active_column/blob/master/README.md) so that links bring you to the right place.
4ed26a8 @mwynholds Add a link for navigation on github.
mwynholds authored
3
0f38720 @mwynholds Add some docs.
mwynholds authored
4 # ActiveColumn
5
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
6 ActiveColumn is a framework for working with data in Cassandra. It currently includes two features:
7
8 - Database migrations
9 - "Time line" model data management
10
390bb9d @mwynholds Rename some files.
mwynholds authored
11 Data migrations are very similar to those in ActiveRecord, and are documented in [Migrate](./docs/Migrate.md).
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
12
13 Time line data management is loosely based on concepts in ActiveRecord, but is adapted to saving data in which rows in
14 Cassandra grow indefinitely over time, such as in the oft-used Twitter example for Cassandra. This usage is documented
15 in:
16
390bb9d @mwynholds Rename some files.
mwynholds authored
17 - [Create](./docs/Create.md) - how to create data
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
18 - [Query](./docs/Query.md) - how to find data
0f38720 @mwynholds Add some docs.
mwynholds authored
19
20 ## Installation
21
22 Add ActiveColumn to your Gemfile:
23 <pre>
24 gem 'active_column'
25 </pre>
26
27 Install with bundler:
28 <pre>
29 bundle install
30 </pre>
31
32 ## Usage
33
34 ### Configuration
35
ffa050a @karlfreeman Change cassandra gem link
karlfreeman authored
36 ActiveColumn requires Cassandra 0.7 or above, as well as the [cassandra gem](https://github.com/twitter/cassandra),
70493a2 @mwynholds Update README
mwynholds authored
37 version 0.9 or above. You must also be sure to use the Cassandra 0.7 support in the gem, which can be done by
38 adding Cassandra to your Gemfile like this:
39 <pre>
40 gem 'cassandra', '>= 0.9', :require => 'cassandra/0.7'
41 </pre>
0f38720 @mwynholds Add some docs.
mwynholds authored
42
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
43 Data migrations in ActiveColumn are used within a Rails project, and are driven off of a configuration file,
44 config/cassandra.yml. It should look something like this:
0f38720 @mwynholds Add some docs.
mwynholds authored
45
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
46 _config/cassandra.yml_
0f38720 @mwynholds Add some docs.
mwynholds authored
47 <pre>
48 test:
49 servers: "127.0.0.1:9160"
50 keyspace: "myapp_test"
51 thrift:
52 timeout: 3
53 retries: 2
54
55 development:
56 servers: "127.0.0.1:9160"
57 keyspace: "myapp_development"
58 thrift:
59 timeout: 3
60 retries: 2
61 </pre>
62
d78af6c updated documentations
elzoiddy authored
63 You can use embedded ruby code in the YAML file to determine host/machine specific settings.
64
65 <pre>
66 production:
df62125 escape < and >
elzoiddy authored
67 servers: "&lt;%=get_from_file('abc.conf')%&gt;:9160"
68 keyspace: "&lt;%=get_from_file('abc.conf')%&gt;"
d78af6c updated documentations
elzoiddy authored
69 disable_node_auto_discovery: true
70 thrift:
71 timeout: 3
72 retries: 2
73 </pre>
74
75 Node Auto Discovery
76
77 You can set disable_node_auto_discovery to off by setting disable_node_auto_discovery flag in your cassandra.yml
78
e561145 @mwynholds Add yard gem, and update docs for time line support and migrations.
mwynholds authored
79 In order to get time line modeling support, you must provide ActiveColumn with an instance of a Cassandra object.
80 Since you have your cassandra.yml from above, you can do this very simply like this:
81
82
83 _config/initializers/cassandra.rb_
0f38720 @mwynholds Add some docs.
mwynholds authored
84 <pre>
85 config = YAML.load_file(Rails.root.join("config", "cassandra.yml"))[Rails.env]
86 $cassandra = Cassandra.new(config['keyspace'],
87 config['servers'],
88 config['thrift'])
89
90 ActiveColumn.connection = $cassandra
91 </pre>
92
93 As you can see, I create a global $cassandra variable, which I use in my tests to validate data directly in Cassandra.
94
f74e1ba documentation changes for example usuage
elzoiddy authored
95 ### Examples
c977273 added ability to update column family definitions as part of migration
elzoiddy authored
96
f74e1ba documentation changes for example usuage
elzoiddy authored
97 Add column family
c977273 added ability to update column family definitions as part of migration
elzoiddy authored
98 <pre>
99 create_column_family :impressions do |cf|
100 cf.comment = 'impressions for something'
37d0bba added back .rvmrc, small update to readme
elzoiddy authored
101 cf.comparator_type = :utf8
102 cf.key_validation_class = :utf8
c977273 added ability to update column family definitions as part of migration
elzoiddy authored
103 end
104 </pre>
105
106 Drop column family
107 <pre>
108 drop_column_family :impressions
109 </pre>
110
111 Rename column family
112 <pre>
113 rename_column_family :impressions, :showings
114 </pre>
115
8676727 changes to examples in readme
elzoiddy authored
116 Update column family
c977273 added ability to update column family definitions as part of migration
elzoiddy authored
117 <pre>
118 update_column_family :impressions do |cf|
119 cf.comment = "blah"
120 cf.gc_grace_seconds = 3600
121 end
122 </pre>
123
0f38720 @mwynholds Add some docs.
mwynholds authored
124 One other thing to note is that you obviously must have Cassandra installed and running! Please take a look at the
125 [mama_cass gem](https://github.com/carbonfive/mama_cass) for a quick way to get up and running with Cassandra for
70493a2 @mwynholds Update README
mwynholds authored
126 development and testing.
Something went wrong with that request. Please try again.