byzhang / terrastore

Automatically exported from code.google.com/p/terrastore
Other
0 stars 0 forks source link

Implement in-place merge #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Update functions are currently executed over a map-based representation of the 
stored value, which is expensive to compute in terms of cpu and memory.
While this is useful when the update is complex and/or cannot be easily 
determined upfront, it should be possible to execute simpler updates in-place, 
over the byte-based representation of the stored value.

Original issue reported on code.google.com by sergio.b...@gmail.com on 15 Jan 2011 at 5:10

GoogleCodeExporter commented 9 years ago
In-place updates will be expressed through an "update" document, describing 
document modifications with a simple syntax as follows:

- The * field contains an object with fields/values to replace.
Example: {"field":"value1"} -> {"*":{"field":"value2"}} -> {"field":"value2"}

- The + field contains an object with fields/values to add.
Example: {"field1":"value1"} -> {"+":{"field2":"value2"}} -> 
{"field1":"value1","field2":"value2"}

- The - field contains an array with field names to remove.
Example: {"field":"value"} -> {"-":["field"]} -> {}

- Fields whose name refers to an array will add contained items if the first 
item is a + sign.  
Example: {"field":["value1"]} -> {"field":["+","value2"]} ->  
{"field":["value1","value2"]}

- Fields whose name refers to an array will remove contained items if the first 
item is a - sign (only works with strings, meaning you can't remove other type 
of items from arrays).  
Example: {"field":["value"]} -> {"field":["-","value"]} ->  {"field":[]}

- Fields whose name refers to an object will evaluate this rules over the 
contained object.
Example: {"field":{"field1":"value1"}} -> {"field":{"+":{"field2":"value2"}}} 
-> {"field":{"field1":"value1","field2":"value2"}}

Original comment by sergio.b...@gmail.com on 19 Jan 2011 at 7:08

GoogleCodeExporter commented 9 years ago
Changed the issue summary to reflect the use of "merge" to denote the new 
operation.

Original comment by sergio.b...@gmail.com on 20 Jan 2011 at 5:18

GoogleCodeExporter commented 9 years ago
Implemented with "merge" syntax as described above.

Original comment by sergio.b...@gmail.com on 21 Jan 2011 at 6:19