Commit e090101645a33917af050f1b1de58cff177a1bae

added notes on Views serialization

Commit diff

meta/philosophy/overview/views.txt

 
171171block and appropriate View#find options.
172172
1731733) You may want to decode key to use with View#find(:with_keys => true)
174Note: encode_key is not required to be a reversible operation, so
175decode_key should just return something reasonable for your application.
174176
175177 View.new do |view|
176178 view.decode_key do |key|
180180 end
181181 end
182182
1834) Also, when the large set of data is stored in a distributed environment,
1834) Also, when a large set of data is stored in a distributed environment,
184184view list can be splitted. To optimize locality (i.e. store related data
185185in the same storage), you may specify a split hinting:
186186
192192
193193This will act as an advice to split data by the key prefix.
194194Underlying storage system may either ignore it, or take it in account.
195In any case, it is guaranteed, that splitting does not affect view results.
196
197
198
199VIEW SERIALIZATION
200
201View is connected with a "view document" (viewdoc). This document is
202build up from the contents of the View.new() options (slots :name,
203:fixed_length_key etc.)
204When you change these slots, new version of viewdoc is created.
205Persistant index is named after the both viewdoc UUID and viewdoc version.
206
207Say, when you change :fixed_length_key, old index is completely discarded
208and new must be built.
209Sometimes we need to do a soft migration of the current index,
210or keep it as-is, or do a controlled migration to a completely new version.
211Migration issues are subject to discuss.
212
213You may specify descriptive data for view.*{ } blocks to make them
214"serializable". Like:
215
216 View.new do |v|
217 v.encode_key("downcase") do |key|
218 key.downcase
219 end
220 end
221
222When encode_key behavior changes, you should change its description:
223
224 View.new do |v|
225 v.encode_key("upcase") do |key|
226 key.upcase
227 end
228 end
229
230This will lead to using another index file.
231In a viewdoc, such info is accessed as a regular slot:
232
233 viewdoc["encode_key"] == "upcase"
234
235This is applied to "map", "encode_key", "decode_key" and "split_by".
236
237
238
195239
196240
197241FURTHER DISCUSSION
toggle raw diff