summaryrefslogtreecommitdiff
path: root/lib/ovsdb-idl-provider.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-06-07 21:07:34 -0700
committerBen Pfaff <blp@ovn.org>2018-06-12 08:24:08 -0700
commitd14e007c1f7314fec9ac0df6c2d39e24753cb11e (patch)
tree85bada039ed865221a1e8aa0eeefa775380ea54c /lib/ovsdb-idl-provider.h
parent7717d233cfdf0b3c59f62cd6bf86e3b4261dcbf8 (diff)
downloadopenvswitch-d14e007c1f7314fec9ac0df6c2d39e24753cb11e.tar.gz
ovsdb-idl: Redesign use of indexes.
The design of the compound index feature in the C OVSDB IDL was unusual. Indexes were generally referenced only by name rather than by pointer, and could be obtained only from the top-level ovsdb_idl object. To iterate or otherwise search an index required explicitly creating a special ovsdb_idl_cursor object, which at least seemed somewhat heavy-weight given that it required a string lookup in a table of indexes. This commit redesigns the compound index interface. It discards the use of names for indexes, instead having clients pass in a pointer to the index object itself. It simplifies how indexes are created, gets rid of the need for explicit cursor objects, and updates all of the users to the new interface. The underlying reason for this commit is to make it easier in ovn-controller to keep track of the dependencies for a given function, by making the indexes explicit arguments to any function that needs to use them. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Han Zhou <hzhou8@ebay.com>
Diffstat (limited to 'lib/ovsdb-idl-provider.h')
-rw-r--r--lib/ovsdb-idl-provider.h57
1 files changed, 29 insertions, 28 deletions
diff --git a/lib/ovsdb-idl-provider.h b/lib/ovsdb-idl-provider.h
index 70bfde11e..2eee4fd01 100644
--- a/lib/ovsdb-idl-provider.h
+++ b/lib/ovsdb-idl-provider.h
@@ -118,7 +118,7 @@ struct ovsdb_idl_table {
struct hmap rows; /* Contains "struct ovsdb_idl_row"s. */
struct ovsdb_idl_db *db; /* Containing db. */
unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
- struct shash indexes; /* Contains "struct ovsdb_idl_index"s */
+ struct ovs_list indexes; /* Contains "struct ovsdb_idl_index"s */
struct ovs_list track_list; /* Tracked rows (ovsdb_idl_row.track_node). */
struct ovsdb_idl_condition condition;
bool cond_changed;
@@ -130,33 +130,6 @@ struct ovsdb_idl_class {
size_t n_tables;
};
-/*
- * Structure containing the per-column configuration of the index.
- */
-struct ovsdb_idl_index_column {
- const struct ovsdb_idl_column *column; /* Column used for index key. */
- column_comparator *comparer; /* Column comparison function. */
- int sorting_order; /* Sorting order (ascending or descending). */
-};
-
-/*
- * Defines a IDL compound index
- */
-struct ovsdb_idl_index {
- struct skiplist *skiplist; /* Skiplist with pointers to rows. */
- struct ovsdb_idl_index_column *columns; /* Columns configuration */
- size_t n_columns; /* Number of columns in index. */
- size_t alloc_columns; /* Size allocated memory for columns,
- comparers and sorting order. */
- bool ins_del; /* True if a row in the index is being
- inserted or deleted; if true, the
- search key is augmented with the
- UUID and address in order to discriminate
- between entries with identical keys. */
- const struct ovsdb_idl_table *table; /* Table that owns this index */
- const char *index_name; /* The name of this index. */
-};
-
struct ovsdb_idl_row *ovsdb_idl_get_row_arc(
struct ovsdb_idl_row *src,
const struct ovsdb_idl_table_class *dst_table,
@@ -166,6 +139,34 @@ void ovsdb_idl_txn_verify(const struct ovsdb_idl_row *,
const struct ovsdb_idl_column *);
struct ovsdb_idl_txn *ovsdb_idl_txn_get(const struct ovsdb_idl_row *);
+
+/* Index internals. */
+
+struct ovsdb_idl_index {
+ struct ovs_list node; /* In ->table->indexes. */
+ struct ovsdb_idl_table *table; /* The indexed table. */
+ struct ovsdb_idl_index_column *columns; /* The indexed columns. */
+ size_t n_columns;
+
+ /* Skiplist with pointers to rows. */
+ struct skiplist *skiplist;
+
+ /* True if a row in the index is being inserted or deleted. If true, the
+ search key is augmented with the UUID and address to discriminate
+ between entries with identical keys. */
+ bool ins_del;
+};
+
+int ovsdb_idl_index_compare(struct ovsdb_idl_index *,
+ const struct ovsdb_idl_row *a,
+ const struct ovsdb_idl_row *b);
+
+void ovsdb_idl_index_write(struct ovsdb_idl_row *,
+ const struct ovsdb_idl_column *,
+ struct ovsdb_datum *,
+ const struct ovsdb_idl_table_class *);
+struct ovsdb_idl_row *ovsdb_idl_index_init_row(struct ovsdb_idl_index *);
+void ovsdb_idl_index_destroy_row(const struct ovsdb_idl_row *);
#ifdef __cplusplus
}