-
Notifications
You must be signed in to change notification settings - Fork 294
Database: document, re-add a test and use a value type rather than strings #2018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database: document, re-add a test and use a value type rather than strings #2018
Conversation
The types are: - String: most fields - Set: all Set(_) - Pairs: all Map(_,_) This allows a database implementation to avoid serialising sets and maps to strings all the time. This patch also adds 'with sexp' to the schema so it can be easily read and written. Eventually we will be able to separate the datamodel and the schema and have the database load the schema at runtime. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…ture Names like "MAP2" beg the question, "what happened to MAP1?" This patch also factorises the ROW, TABLE, TABLESET signatures into a shared common portion, with specific extensions on top. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
This means that - if you read the type, you realise this isn't just any old int64 - we are closer to making it fully abstract Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…ime.t Some of the functions omitted the third Time.t (the deleted time), because the object could not have been deleted yet. Elsewhere we have the convention that a live object has deleted = 0L. This patch makes all the Time.t -> Time.t (-> Time.t) functions consistent. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
The 3 Time.t's are like a file "stat": - a create time - a last-modified time - a deletion time (since the events are historical) Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…s fold Previously fold and fold_over_recent used a slightly different permutation of arguments in the function being folded over the data. The OCaml stdlib convention is to have a function (key -> value -> 'a -> 'a) so we follow this. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…_over_deleted This allows fold_over_recent to have the same signature as the other functions with the same name. Tracking of deleted references (without values) is specific to the Table. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…mon definition Now that all the common MAP instances have the same fold_over_recent signature, we can share the definition and avoid people playing "spot the difference" with a complicated type. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…as using it To define an error case from a fold you can either - turn the accumulator into a result type and return `Error - throw an exception (... and document this and guarantee to catch it) Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
This was confusing because we already had {Row,Table,TableSet}.find
which threw exceptions. The only difference was that Table.find_exn
would throw a DBCache exception rather than Not_found.
We revert all callers to Table.find, and expect them (in the DB_ACCESS
layer) to convert the Not_found into the DB_ACCESS-specific exception
themselves.
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
…ature The 'update_generation' function was defined as - always bump the generation count (in contract to 'update') - also transform one binding to another value In practice all users were using it only to bump the generation count like "touch"ing a file. Therefore we remove the transform ability and rename the function "touch". Signed-off-by: David Scott <dave.scott@eu.citrix.com>
This allows us to put the 'remove' function into the MAP signature for consistency. Now Row, Table, TableSet all have a remove which takes a Time.t which allows tracking of delete events. We only use these in the Table to track deleted Rows, but maybe in future we could track deleted Tables or fields later? Signed-off-by: David Scott <dave.scott@eu.citrix.com>
This was a trivial use of fold anyway. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Signed-off-by: David Scott <dave.scott@eu.citrix.com>
The schema can use this value for describing Column.ts, in particular - the 'empty' value - the optional 'default' value The Value.t is still being marshalled to a string for storage in the database. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
In particular this means that sets and maps are not automatically serialised to strings via the 'add_to' and 'remove_from' code. However the wire protocol still uses s-expressions so the more slaves, the more s-expressions you'll see.
The library test can be run easily from the build. The remainder of 'database_test' is really a 'database server test' which doesn't currently work. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
|
Niiiice |
|
Does the unit test exit 1 if it fails? I only ask because I keep getting bitten by this - you might have to do something like this: https://github.com/xenserver/gpumon/blob/master/test/test_main.ml#L9-10 |
|
Hm, I added a "failwith" in the test and got this: Grrr |
Thanks to @johnelse for pointing this out. Signed-off-by: David Scott <dave.scott@eu.citrix.com>
|
@jonludlam is happy to merge this now that the xen-4.5 changes have been built by the CI |
Database: document, re-add a test and use a value type rather than strings
|
Just for clarity, the Xen 4.5 changes mentioned above are only internal changes to be able to use Xen 4.5, not any actual changes to the source that may be required. |
We