Skip to content

Commit

Permalink
ovsdb-idl: idl compound indexes implementation
Browse files Browse the repository at this point in the history
This patch adds support for the creation of multicolumn indexes
in the C IDL to enable for efficient search and retrieval of database
rows by key.

Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Co-authored-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
hlrichardson authored and blp committed Aug 3, 2017
1 parent 6c2705c commit 93fe026
Show file tree
Hide file tree
Showing 3 changed files with 481 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/ovsdb-idl-provider.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2009, 2010, 2011, 2012, 2016 Nicira, Inc.
* Copyright (C) 2016 Hewlett Packard Enterprise Development LP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -111,6 +112,7 @@ struct ovsdb_idl_table {
struct hmap rows; /* Contains "struct ovsdb_idl_row"s. */
struct ovsdb_idl *idl; /* Containing idl. */
unsigned int change_seqno[OVSDB_IDL_CHANGE_MAX];
struct shash 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;
Expand All @@ -122,6 +124,33 @@ 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,
Expand Down

0 comments on commit 93fe026

Please sign in to comment.