Please also see my comments for the next patch. On Sat, Jan 16, 2016 at 12:16 AM, Liran Schour <lir...@il.ibm.com> wrote:
> Indexing is different between ovsdb_row to ovsdb_monitor_row. To be > able to evaluate conditions on ovsdb_monitor_row we need this mapping. > > signed-off-by: Liran Schour <lir...@il.ibm.com> > --- > ovsdb/monitor.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c > index 0dde54e..51f4e09 100644 > --- a/ovsdb/monitor.c > +++ b/ovsdb/monitor.c > @@ -116,6 +116,9 @@ struct ovsdb_monitor_table { > struct ovsdb_monitor_column *columns; > size_t n_columns; > > + /* map between column->index to columns */ > This comment seems too generic. It can be more helpful to be more precisely describe the map, and how what function it provides. > + unsigned int *columns_index_map; > + > /* Contains 'ovsdb_monitor_changes' indexed by 'transaction'. */ > struct hmap changes; > }; > @@ -347,6 +350,8 @@ ovsdb_monitor_add_table(struct ovsdb_monitor *m, > mt->table = table; > shash_add(&m->tables, table->schema->name, mt); > hmap_init(&mt->changes); > + mt->columns_index_map = > + xmalloc(sizeof(unsigned int) * > shash_count(&table->schema->columns)); > Should xzalloc() be used here instead? > } > > void > @@ -1065,6 +1070,7 @@ struct ovsdb_monitor * > ovsdb_monitor_add(struct ovsdb_monitor *new_dbmon) > { > struct ovsdb_monitor *dbmon; > + struct shash_node *node; > size_t hash; > > /* New_dbmon should be associated with only one jsonrpc > @@ -1078,6 +1084,16 @@ ovsdb_monitor_add(struct ovsdb_monitor *new_dbmon) > } > } > > + /* Prepare columns index map */ > + SHASH_FOR_EACH (node, &new_dbmon->tables) { > + struct ovsdb_monitor_table *mt = node->data; > + int i; > + > + for (i = 0; i < mt->n_columns; i++) { > + mt->columns_index_map[mt->columns[i].column->index] = i; > + } > + } > + > hmap_insert(&ovsdb_monitors, &new_dbmon->hmap_node, hash); > return new_dbmon; > } > @@ -1106,6 +1122,7 @@ ovsdb_monitor_destroy(struct ovsdb_monitor *dbmon) > } > hmap_destroy(&mt->changes); > free(mt->columns); > + free(mt->columns_index_map); > free(mt); > } > shash_destroy(&dbmon->tables); > -- > 2.1.4 > > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev