diff options
author | Ryan Moats <rmoats@us.ibm.com> | 2016-08-06 17:46:29 -0500 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-08-14 16:31:15 -0700 |
commit | f1ab6e06061ab05f246f4c95c8653c89036c819f (patch) | |
tree | b2274ba453e83bedfb048bec53082fbb91fd90a5 /ovsdb | |
parent | 33ac3c83416334e8759ff21170e42aa9700be8e4 (diff) | |
download | openvswitch-f1ab6e06061ab05f246f4c95c8653c89036c819f.tar.gz |
ovsdb: Add/use partial set updates.
This patchset mimics the changes introduced in
f199df26 (ovsdb-idl: Add partial map updates functionality.)
010fe7ae (ovsdb-idlc.in: Autogenerate partial map updates functions.)
7251075c (tests: Add test for partial map updates.)
b1048e6a (ovsdb-idl: Fix issues detected in Partial Map Update feature)
but for columns that store sets of values rather than key-value
pairs. These columns will now be able to use the OVSDB mutate
operation to transmit deltas on the wire rather than use
verify/update and transmit wait/update operations on the wire.
Side effect of modifying the comments in the partial map update
tests.
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rwxr-xr-x | ovsdb/ovsdb-idlc.in | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 253344e0c..487876b41 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -233,7 +233,12 @@ bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id); print 'void %(s)s_update_%(c)s_setkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, print '%(coltype)s, %(valtype)s);' % {'coltype':column.type.key.toCType(prefix), 'valtype':column.type.value.toCType(prefix)} print 'void %(s)s_update_%(c)s_delkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, - print '%(coltype)s);' % {'coltype':column.type.key.toCType(prefix)}, + print '%(coltype)s);' % {'coltype':column.type.key.toCType(prefix)} + if column.type.is_set(): + print 'void %(s)s_update_%(c)s_addvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(valtype)s);' % {'valtype':column.type.key.toCType(prefix)} + print 'void %(s)s_update_%(c)s_delvalue(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(valtype)s);' % {'valtype':column.type.key.toCType(prefix)} print 'void %(s)s_add_clause_%(c)s(struct ovsdb_idl *idl, enum ovsdb_function function,' % {'s': structName, 'c': columnName}, if column.type.is_smap(): @@ -854,6 +859,64 @@ void 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), 'C': columnName.upper()} # End Update/Delete of partial maps + # Update/Delete of partial set column functions + if type.is_set(): + print ''' +/* Adds the value 'new_value' to the "%(c)s" set column from the "%(t)s" table + * in 'row'. + * + */ +void +%(s)s_update_%(c)s_addvalue(const struct %(s)s *row, %(valtype)snew_value) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->values); + datum->values = NULL; +''' % {'s': structName, 'c': columnName, + 'valtype':column.type.key.toCType(prefix), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_value") + print ''' + ovsdb_idl_txn_write_partial_set(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.key.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + print ''' +/* Deletes the value 'delete_value' from the "%(c)s" set column from the + * "%(t)s" table in 'row'. + * + */ +void +%(s)s_update_%(c)s_delvalue(const struct %(s)s *row, %(valtype)sdelete_value) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->values); + datum->values = NULL; +''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.key.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper(), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_value") + print ''' + ovsdb_idl_txn_delete_partial_set(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.key.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + # End Update/Delete of partial set # Add clause functions. for columnName, column in sorted(table.columns.iteritems()): |