massive_record 0.2.1 → 0.2.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +58 -2
- data/Gemfile.lock +17 -17
- data/README.md +98 -41
- data/lib/massive_record.rb +2 -1
- data/lib/massive_record/adapters/thrift/hbase/hbase.rb +2425 -2154
- data/lib/massive_record/adapters/thrift/hbase/hbase_constants.rb +3 -3
- data/lib/massive_record/adapters/thrift/hbase/hbase_types.rb +195 -195
- data/lib/massive_record/adapters/thrift/row.rb +35 -4
- data/lib/massive_record/adapters/thrift/table.rb +49 -12
- data/lib/massive_record/orm/attribute_methods.rb +77 -5
- data/lib/massive_record/orm/attribute_methods/cast_numbers_on_write.rb +24 -0
- data/lib/massive_record/orm/attribute_methods/dirty.rb +18 -0
- data/lib/massive_record/orm/attribute_methods/time_zone_conversion.rb +24 -3
- data/lib/massive_record/orm/attribute_methods/write.rb +8 -1
- data/lib/massive_record/orm/base.rb +62 -8
- data/lib/massive_record/orm/column.rb +7 -11
- data/lib/massive_record/orm/default_id.rb +1 -1
- data/lib/massive_record/orm/embedded.rb +66 -0
- data/lib/massive_record/orm/errors.rb +17 -0
- data/lib/massive_record/orm/finders.rb +124 -71
- data/lib/massive_record/orm/finders/rescue_missing_table_on_find.rb +1 -1
- data/lib/massive_record/orm/finders/scope.rb +58 -34
- data/lib/massive_record/orm/id_factory.rb +22 -105
- data/lib/massive_record/orm/id_factory/atomic_incrementation.rb +117 -0
- data/lib/massive_record/orm/id_factory/timestamp.rb +60 -0
- data/lib/massive_record/orm/identity_map.rb +256 -0
- data/lib/massive_record/orm/log_subscriber.rb +18 -0
- data/lib/massive_record/orm/observer.rb +69 -0
- data/lib/massive_record/orm/persistence.rb +47 -119
- data/lib/massive_record/orm/persistence/operations.rb +100 -0
- data/lib/massive_record/orm/persistence/operations/atomic_operation.rb +71 -0
- data/lib/massive_record/orm/persistence/operations/destroy.rb +17 -0
- data/lib/massive_record/orm/persistence/operations/embedded/destroy.rb +26 -0
- data/lib/massive_record/orm/persistence/operations/embedded/insert.rb +27 -0
- data/lib/massive_record/orm/persistence/operations/embedded/operation_helpers.rb +66 -0
- data/lib/massive_record/orm/persistence/operations/embedded/reload.rb +39 -0
- data/lib/massive_record/orm/persistence/operations/embedded/update.rb +29 -0
- data/lib/massive_record/orm/persistence/operations/insert.rb +19 -0
- data/lib/massive_record/orm/persistence/operations/reload.rb +26 -0
- data/lib/massive_record/orm/persistence/operations/suppress.rb +15 -0
- data/lib/massive_record/orm/persistence/operations/table_operation_helpers.rb +106 -0
- data/lib/massive_record/orm/persistence/operations/update.rb +25 -0
- data/lib/massive_record/orm/query_instrumentation.rb +26 -49
- data/lib/massive_record/orm/raw_data.rb +47 -0
- data/lib/massive_record/orm/relations.rb +4 -0
- data/lib/massive_record/orm/relations/interface.rb +134 -0
- data/lib/massive_record/orm/relations/metadata.rb +58 -12
- data/lib/massive_record/orm/relations/proxy.rb +17 -12
- data/lib/massive_record/orm/relations/proxy/embedded_in.rb +54 -0
- data/lib/massive_record/orm/relations/proxy/embedded_in_polymorphic.rb +15 -0
- data/lib/massive_record/orm/relations/proxy/embeds_many.rb +215 -0
- data/lib/massive_record/orm/relations/proxy/references_many.rb +112 -88
- data/lib/massive_record/orm/relations/proxy/references_one.rb +1 -1
- data/lib/massive_record/orm/relations/proxy/references_one_polymorphic.rb +1 -1
- data/lib/massive_record/orm/relations/proxy_collection.rb +84 -0
- data/lib/massive_record/orm/schema/column_family.rb +3 -2
- data/lib/massive_record/orm/schema/{column_interface.rb → embedded_interface.rb} +38 -4
- data/lib/massive_record/orm/schema/field.rb +2 -0
- data/lib/massive_record/orm/schema/table_interface.rb +19 -2
- data/lib/massive_record/orm/single_table_inheritance.rb +37 -2
- data/lib/massive_record/orm/timestamps.rb +17 -7
- data/lib/massive_record/orm/validations.rb +4 -0
- data/lib/massive_record/orm/validations/associated.rb +50 -0
- data/lib/massive_record/rails/railtie.rb +31 -0
- data/lib/massive_record/version.rb +1 -1
- data/lib/massive_record/wrapper/cell.rb +8 -1
- data/massive_record.gemspec +4 -4
- data/spec/adapter/thrift/atomic_increment_spec.rb +16 -0
- data/spec/adapter/thrift/table_find_spec.rb +14 -2
- data/spec/adapter/thrift/table_spec.rb +6 -6
- data/spec/adapter/thrift/utf8_encoding_of_id_spec.rb +71 -0
- data/spec/orm/cases/attribute_methods_spec.rb +215 -22
- data/spec/orm/cases/auto_generate_id_spec.rb +1 -1
- data/spec/orm/cases/change_id_spec.rb +62 -0
- data/spec/orm/cases/default_id_spec.rb +25 -6
- data/spec/orm/cases/default_values_spec.rb +6 -3
- data/spec/orm/cases/dirty_spec.rb +150 -102
- data/spec/orm/cases/embedded_spec.rb +250 -0
- data/spec/orm/cases/{finder_default_scope.rb → finder_default_scope_spec.rb} +4 -0
- data/spec/orm/cases/finder_scope_spec.rb +96 -29
- data/spec/orm/cases/finders_spec.rb +57 -10
- data/spec/orm/cases/id_factory/atomic_incrementation_spec.rb +72 -0
- data/spec/orm/cases/id_factory/timestamp_spec.rb +61 -0
- data/spec/orm/cases/identity_map/identity_map_spec.rb +357 -0
- data/spec/orm/cases/identity_map/middleware_spec.rb +74 -0
- data/spec/orm/cases/log_subscriber_spec.rb +15 -2
- data/spec/orm/cases/observing_spec.rb +61 -0
- data/spec/orm/cases/persistence_spec.rb +151 -60
- data/spec/orm/cases/raw_data_spec.rb +58 -0
- data/spec/orm/cases/single_table_inheritance_spec.rb +58 -2
- data/spec/orm/cases/table_spec.rb +3 -3
- data/spec/orm/cases/time_zone_awareness_spec.rb +27 -0
- data/spec/orm/cases/timestamps_spec.rb +23 -109
- data/spec/orm/cases/validation_spec.rb +9 -0
- data/spec/orm/models/address.rb +5 -1
- data/spec/orm/models/address_with_timestamp.rb +12 -0
- data/spec/orm/models/car.rb +5 -0
- data/spec/orm/models/person.rb +13 -1
- data/spec/orm/models/person_with_timestamp.rb +4 -2
- data/spec/orm/models/test_class.rb +1 -0
- data/spec/orm/persistence/operations/atomic_operation_spec.rb +58 -0
- data/spec/orm/persistence/operations/destroy_spec.rb +22 -0
- data/spec/orm/persistence/operations/embedded/destroy_spec.rb +71 -0
- data/spec/orm/persistence/operations/embedded/insert_spec.rb +59 -0
- data/spec/orm/persistence/operations/embedded/operation_helpers_spec.rb +92 -0
- data/spec/orm/persistence/operations/embedded/reload_spec.rb +67 -0
- data/spec/orm/persistence/operations/embedded/update_spec.rb +60 -0
- data/spec/orm/persistence/operations/insert_spec.rb +31 -0
- data/spec/orm/persistence/operations/reload_spec.rb +48 -0
- data/spec/orm/persistence/operations/suppress_spec.rb +17 -0
- data/spec/orm/persistence/operations/table_operation_helpers_spec.rb +98 -0
- data/spec/orm/persistence/operations/update_spec.rb +25 -0
- data/spec/orm/persistence/operations_spec.rb +58 -0
- data/spec/orm/relations/interface_spec.rb +188 -0
- data/spec/orm/relations/metadata_spec.rb +92 -15
- data/spec/orm/relations/proxy/embedded_in_polymorphic_spec.rb +37 -0
- data/spec/orm/relations/proxy/embedded_in_spec.rb +66 -0
- data/spec/orm/relations/proxy/embeds_many_spec.rb +651 -0
- data/spec/orm/relations/proxy/references_many_spec.rb +466 -2
- data/spec/orm/schema/column_family_spec.rb +21 -0
- data/spec/orm/schema/embedded_interface_spec.rb +181 -0
- data/spec/orm/schema/field_spec.rb +7 -0
- data/spec/orm/schema/table_interface_spec.rb +31 -1
- data/spec/shared/orm/id_factories.rb +44 -0
- data/spec/shared/orm/model_with_timestamps.rb +132 -0
- data/spec/shared/orm/persistence/a_persistence_embedded_operation_class.rb +3 -0
- data/spec/shared/orm/persistence/a_persistence_operation_class.rb +11 -0
- data/spec/shared/orm/persistence/a_persistence_table_operation_class.rb +11 -0
- data/spec/shared/orm/relations/proxy.rb +9 -2
- data/spec/spec_helper.rb +9 -0
- data/spec/support/mock_massive_record_connection.rb +2 -1
- metadata +106 -21
- data/spec/orm/cases/column_spec.rb +0 -49
- data/spec/orm/cases/id_factory_spec.rb +0 -92
- data/spec/orm/schema/column_interface_spec.rb +0 -136
@@ -8,218 +8,218 @@ module Apache
|
|
8
8
|
module Hadoop
|
9
9
|
module Hbase
|
10
10
|
module Thrift
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
11
|
+
# TCell - Used to transport a cell value (byte[]) and the timestamp it was
|
12
|
+
# stored with together as a result for get and getRow methods. This promotes
|
13
|
+
# the timestamp of a cell to a first-class value, making it easy to take
|
14
|
+
# note of temporal data. Cell is used all the way from HStore up to HTable.
|
15
|
+
class TCell
|
16
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
17
|
+
VALUE = 1
|
18
|
+
TIMESTAMP = 2
|
19
|
+
|
20
|
+
FIELDS = {
|
21
|
+
VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary => true},
|
22
|
+
TIMESTAMP => {:type => ::Thrift::Types::I64, :name => 'timestamp'}
|
23
|
+
}
|
24
|
+
|
25
|
+
def struct_fields; FIELDS; end
|
26
|
+
|
27
|
+
def validate
|
28
|
+
end
|
29
|
+
|
30
|
+
::Thrift::Struct.generate_accessors self
|
31
|
+
end
|
32
|
+
|
33
|
+
# An HColumnDescriptor contains information about a column family
|
34
|
+
# such as the number of versions, compression settings, etc. It is
|
35
|
+
# used as input when creating a table or adding a column.
|
36
|
+
class ColumnDescriptor
|
37
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
38
|
+
NAME = 1
|
39
|
+
MAXVERSIONS = 2
|
40
|
+
COMPRESSION = 3
|
41
|
+
INMEMORY = 4
|
42
|
+
BLOOMFILTERTYPE = 5
|
43
|
+
BLOOMFILTERVECTORSIZE = 6
|
44
|
+
BLOOMFILTERNBHASHES = 7
|
45
|
+
BLOCKCACHEENABLED = 8
|
46
|
+
TIMETOLIVE = 9
|
47
|
+
|
48
|
+
FIELDS = {
|
49
|
+
NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary => true},
|
50
|
+
MAXVERSIONS => {:type => ::Thrift::Types::I32, :name => 'maxVersions', :default => 3},
|
51
|
+
COMPRESSION => {:type => ::Thrift::Types::STRING, :name => 'compression', :default => %q"NONE"},
|
52
|
+
INMEMORY => {:type => ::Thrift::Types::BOOL, :name => 'inMemory', :default => false},
|
53
|
+
BLOOMFILTERTYPE => {:type => ::Thrift::Types::STRING, :name => 'bloomFilterType', :default => %q"NONE"},
|
54
|
+
BLOOMFILTERVECTORSIZE => {:type => ::Thrift::Types::I32, :name => 'bloomFilterVectorSize', :default => 0},
|
55
|
+
BLOOMFILTERNBHASHES => {:type => ::Thrift::Types::I32, :name => 'bloomFilterNbHashes', :default => 0},
|
56
|
+
BLOCKCACHEENABLED => {:type => ::Thrift::Types::BOOL, :name => 'blockCacheEnabled', :default => false},
|
57
|
+
TIMETOLIVE => {:type => ::Thrift::Types::I32, :name => 'timeToLive', :default => -1}
|
58
|
+
}
|
59
|
+
|
60
|
+
def struct_fields; FIELDS; end
|
61
|
+
|
62
|
+
def validate
|
63
|
+
end
|
64
|
+
|
65
|
+
::Thrift::Struct.generate_accessors self
|
66
|
+
end
|
67
|
+
|
68
|
+
# A TRegionInfo contains information about an HTable region.
|
69
|
+
class TRegionInfo
|
70
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
71
|
+
STARTKEY = 1
|
72
|
+
ENDKEY = 2
|
73
|
+
ID = 3
|
74
|
+
NAME = 4
|
75
|
+
VERSION = 5
|
76
|
+
|
77
|
+
FIELDS = {
|
78
|
+
STARTKEY => {:type => ::Thrift::Types::STRING, :name => 'startKey', :binary => true},
|
79
|
+
ENDKEY => {:type => ::Thrift::Types::STRING, :name => 'endKey', :binary => true},
|
80
|
+
ID => {:type => ::Thrift::Types::I64, :name => 'id'},
|
81
|
+
NAME => {:type => ::Thrift::Types::STRING, :name => 'name', :binary => true},
|
82
|
+
VERSION => {:type => ::Thrift::Types::BYTE, :name => 'version'}
|
83
|
+
}
|
84
|
+
|
85
|
+
def struct_fields; FIELDS; end
|
86
|
+
|
87
|
+
def validate
|
88
|
+
end
|
89
|
+
|
90
|
+
::Thrift::Struct.generate_accessors self
|
91
|
+
end
|
92
|
+
|
93
|
+
# A Mutation object is used to either update or delete a column-value.
|
94
|
+
class Mutation
|
95
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
96
|
+
ISDELETE = 1
|
97
|
+
COLUMN = 2
|
98
|
+
VALUE = 3
|
99
|
+
|
100
|
+
FIELDS = {
|
101
|
+
ISDELETE => {:type => ::Thrift::Types::BOOL, :name => 'isDelete', :default => false},
|
102
|
+
COLUMN => {:type => ::Thrift::Types::STRING, :name => 'column', :binary => true},
|
103
|
+
VALUE => {:type => ::Thrift::Types::STRING, :name => 'value', :binary => true}
|
104
|
+
}
|
105
|
+
|
106
|
+
def struct_fields; FIELDS; end
|
107
|
+
|
108
|
+
def validate
|
109
|
+
end
|
110
|
+
|
111
|
+
::Thrift::Struct.generate_accessors self
|
112
|
+
end
|
113
|
+
|
114
|
+
# A BatchMutation object is used to apply a number of Mutations to a single row.
|
115
|
+
class BatchMutation
|
116
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
117
|
+
ROW = 1
|
118
|
+
MUTATIONS = 2
|
119
|
+
|
120
|
+
FIELDS = {
|
121
|
+
ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
|
122
|
+
MUTATIONS => {:type => ::Thrift::Types::LIST, :name => 'mutations', :element => {:type => ::Thrift::Types::STRUCT, :class => Apache::Hadoop::Hbase::Thrift::Mutation}}
|
123
|
+
}
|
124
|
+
|
125
|
+
def struct_fields; FIELDS; end
|
126
|
+
|
127
|
+
def validate
|
128
|
+
end
|
129
|
+
|
130
|
+
::Thrift::Struct.generate_accessors self
|
131
|
+
end
|
132
|
+
|
133
|
+
# Holds row name and then a map of columns to cells.
|
134
|
+
class TRowResult
|
135
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
136
|
+
ROW = 1
|
137
|
+
COLUMNS = 2
|
138
|
+
|
139
|
+
FIELDS = {
|
140
|
+
ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
|
141
|
+
COLUMNS => {:type => ::Thrift::Types::MAP, :name => 'columns', :key => {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type => ::Thrift::Types::STRUCT, :class => Apache::Hadoop::Hbase::Thrift::TCell}}
|
142
|
+
}
|
143
|
+
|
144
|
+
def struct_fields; FIELDS; end
|
145
|
+
|
146
|
+
def validate
|
147
|
+
end
|
148
|
+
|
149
|
+
::Thrift::Struct.generate_accessors self
|
150
|
+
end
|
151
|
+
|
152
|
+
# An IOError exception signals that an error occurred communicating
|
153
|
+
# to the Hbase master or an Hbase region server. Also used to return
|
154
|
+
# more general Hbase error conditions.
|
155
|
+
class IOError < ::Thrift::Exception
|
156
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
157
|
+
def initialize(message=nil)
|
158
|
+
super()
|
159
|
+
self.message = message
|
160
|
+
end
|
124
161
|
|
125
|
-
|
162
|
+
MESSAGE = 1
|
126
163
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
::Thrift::Struct.generate_accessors self
|
131
|
-
end
|
132
|
-
|
133
|
-
# Holds row name and then a map of columns to cells.
|
134
|
-
class TRowResult
|
135
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
136
|
-
ROW = 1
|
137
|
-
COLUMNS = 2
|
138
|
-
|
139
|
-
FIELDS = {
|
140
|
-
ROW => {:type => ::Thrift::Types::STRING, :name => 'row', :binary => true},
|
141
|
-
COLUMNS => {:type => ::Thrift::Types::MAP, :name => 'columns', :key => {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type => ::Thrift::Types::STRUCT, :class => Apache::Hadoop::Hbase::Thrift::TCell}}
|
142
|
-
}
|
143
|
-
|
144
|
-
def struct_fields; FIELDS; end
|
145
|
-
|
146
|
-
def validate
|
147
|
-
end
|
148
|
-
|
149
|
-
::Thrift::Struct.generate_accessors self
|
150
|
-
end
|
164
|
+
FIELDS = {
|
165
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
166
|
+
}
|
151
167
|
|
152
|
-
|
153
|
-
# to the Hbase master or an Hbase region server. Also used to return
|
154
|
-
# more general Hbase error conditions.
|
155
|
-
class IOError < ::Thrift::Exception
|
156
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
157
|
-
def initialize(message=nil)
|
158
|
-
super()
|
159
|
-
self.message = message
|
160
|
-
end
|
168
|
+
def struct_fields; FIELDS; end
|
161
169
|
|
162
|
-
|
170
|
+
def validate
|
171
|
+
end
|
163
172
|
|
164
|
-
|
165
|
-
|
166
|
-
}
|
173
|
+
::Thrift::Struct.generate_accessors self
|
174
|
+
end
|
167
175
|
|
168
|
-
|
176
|
+
# An IllegalArgument exception indicates an illegal or invalid
|
177
|
+
# argument was passed into a procedure.
|
178
|
+
class IllegalArgument < ::Thrift::Exception
|
179
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
180
|
+
def initialize(message=nil)
|
181
|
+
super()
|
182
|
+
self.message = message
|
183
|
+
end
|
169
184
|
|
170
|
-
|
171
|
-
end
|
185
|
+
MESSAGE = 1
|
172
186
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
# An IllegalArgument exception indicates an illegal or invalid
|
177
|
-
# argument was passed into a procedure.
|
178
|
-
class IllegalArgument < ::Thrift::Exception
|
179
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
180
|
-
def initialize(message=nil)
|
181
|
-
super()
|
182
|
-
self.message = message
|
183
|
-
end
|
187
|
+
FIELDS = {
|
188
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
189
|
+
}
|
184
190
|
|
185
|
-
|
191
|
+
def struct_fields; FIELDS; end
|
186
192
|
|
187
|
-
|
188
|
-
|
189
|
-
}
|
193
|
+
def validate
|
194
|
+
end
|
190
195
|
|
191
|
-
|
196
|
+
::Thrift::Struct.generate_accessors self
|
197
|
+
end
|
192
198
|
|
193
|
-
|
194
|
-
|
199
|
+
# An AlreadyExists exceptions signals that a table with the specified
|
200
|
+
# name already exists
|
201
|
+
class AlreadyExists < ::Thrift::Exception
|
202
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
203
|
+
def initialize(message=nil)
|
204
|
+
super()
|
205
|
+
self.message = message
|
206
|
+
end
|
195
207
|
|
196
|
-
|
197
|
-
end
|
208
|
+
MESSAGE = 1
|
198
209
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
203
|
-
def initialize(message=nil)
|
204
|
-
super()
|
205
|
-
self.message = message
|
206
|
-
end
|
210
|
+
FIELDS = {
|
211
|
+
MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
|
212
|
+
}
|
207
213
|
|
208
|
-
|
214
|
+
def struct_fields; FIELDS; end
|
209
215
|
|
210
|
-
|
211
|
-
|
212
|
-
}
|
216
|
+
def validate
|
217
|
+
end
|
213
218
|
|
214
|
-
|
219
|
+
::Thrift::Struct.generate_accessors self
|
220
|
+
end
|
215
221
|
|
216
|
-
|
222
|
+
end
|
223
|
+
end
|
217
224
|
end
|
218
|
-
|
219
|
-
::Thrift::Struct.generate_accessors self
|
220
225
|
end
|
221
|
-
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
@@ -41,6 +41,36 @@ module MassiveRecord
|
|
41
41
|
@columns.inject({"id" => id}) {|h, (column_name, cell)| h[column_name] = cell.value; h}
|
42
42
|
end
|
43
43
|
|
44
|
+
# Returns values as a nested hash.
|
45
|
+
#
|
46
|
+
# {
|
47
|
+
# 'family' => {
|
48
|
+
# 'attr1' => 'value'
|
49
|
+
# 'attr2' => 'value'
|
50
|
+
# },
|
51
|
+
# ...
|
52
|
+
# }
|
53
|
+
#
|
54
|
+
# I think maybe that values should return this instead, as it is what the
|
55
|
+
# values= expects to receive.
|
56
|
+
def values_hash
|
57
|
+
Hash.new { |hash, key| hash[key] = {} }.tap do |hash|
|
58
|
+
@columns.each do |key, column|
|
59
|
+
column_family, name = key.split(':')
|
60
|
+
hash[column_family][name] = column.value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def values_raw_data_hash
|
66
|
+
Hash.new { |hash, key| hash[key] = {} }.tap do |hash|
|
67
|
+
@columns.each do |key, column|
|
68
|
+
column_family, name = key.split(':')
|
69
|
+
hash[column_family][name] = MassiveRecord::ORM::RawData.new_with_data_from column
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
44
74
|
def values=(data)
|
45
75
|
@values = {}
|
46
76
|
update_columns(data)
|
@@ -86,6 +116,10 @@ module MassiveRecord
|
|
86
116
|
def atomic_increment(column_name, by = 1)
|
87
117
|
@table.client.atomicIncrement(@table.name, id.to_s, column_name, by)
|
88
118
|
end
|
119
|
+
|
120
|
+
def atomic_decrement(column_name, by = 1)
|
121
|
+
atomic_increment(column_name, -by)
|
122
|
+
end
|
89
123
|
|
90
124
|
def read_atomic_integer_value(column_name)
|
91
125
|
atomic_increment(column_name, 0)
|
@@ -99,10 +133,7 @@ module MassiveRecord
|
|
99
133
|
row.column_families = column_families
|
100
134
|
|
101
135
|
result.columns.each do |name, value|
|
102
|
-
row.columns[name] = MassiveRecord::Wrapper::Cell.
|
103
|
-
:value => value.value,
|
104
|
-
:created_at => Time.at(value.timestamp / 1000, (value.timestamp % 1000) * 1000)
|
105
|
-
})
|
136
|
+
row.columns[name] = MassiveRecord::Wrapper::Cell.populate_from_tcell(value)
|
106
137
|
end
|
107
138
|
|
108
139
|
row
|