Optimized search performance for large lists by sorting and binary search
This commit is contained in:
parent
b743b0a080
commit
4b92dbdc10
28 changed files with 1405 additions and 701 deletions
|
|
@ -76,6 +76,7 @@
|
|||
#include <clixon/clixon_string.h>
|
||||
#include <clixon/clixon_file.h>
|
||||
#include <clixon/clixon_xml.h>
|
||||
#include <clixon/clixon_xml_sort.h>
|
||||
#include <clixon/clixon_proto.h>
|
||||
#include <clixon/clixon_proto_client.h>
|
||||
#include <clixon/clixon_plugin.h>
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ typedef int (xml_applyfn_t)(cxobj *yn, void *arg);
|
|||
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
|
||||
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
|
||||
|
||||
/* Hash for XML trees list entries
|
||||
/* Sort and binary search of XML children
|
||||
* Experimental
|
||||
*/
|
||||
extern int xml_child_hash;
|
||||
extern int xml_child_sort;
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
@ -160,14 +160,7 @@ int xml_body_int32(cxobj *xb, int32_t *val);
|
|||
int xml_body_uint32(cxobj *xb, uint32_t *val);
|
||||
int xml_operation(char *opstr, enum operation_type *op);
|
||||
char *xml_operation2str(enum operation_type op);
|
||||
int xml_child_spec(char *name, cxobj *xp, yang_spec *yspec, yang_stmt **yp);
|
||||
|
||||
clicon_hash_t *xml_hash(cxobj *x);
|
||||
int xml_hash_key(cxobj *x, yang_stmt *y, cbuf *key);
|
||||
int xml_hash_op(cxobj *x, void *arg);
|
||||
int xml_hash_add(cxobj *x);
|
||||
int xml_hash_rm_only(cxobj *x);
|
||||
int xml_hash_rm_entry(cxobj *x);
|
||||
int xml_sort(cxobj *x0, void *arg);
|
||||
|
||||
#ifdef XML_COMPAT /* See CHANGELOG */
|
||||
/* MANUAL CHANGE: xml_new(name, parent) --> xml_new(name, parent, NULL) */
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ int api_path2xpath_cvv(yang_spec *yspec, cvec *cvv, int offset, cbuf *xpath);
|
|||
int api_path2xpath(yang_spec *yspec, char *api_path, cbuf *xpath);
|
||||
int api_path2xml(char *api_path, yang_spec *yspec, cxobj *xtop,
|
||||
int schemanode, cxobj **xpathp, yang_node **ypathp);
|
||||
int match_base_child(cxobj *x0, cxobj *x1c, cxobj **x0cp, yang_stmt *yc);
|
||||
int xml_merge(cxobj *x0, cxobj *x1, yang_spec *yspec);
|
||||
int yang_enum_int_value(cxobj *node, int32_t *val);
|
||||
|
||||
|
|
|
|||
52
lib/clixon/clixon_xml_sort.h
Normal file
52
lib/clixon/clixon_xml_sort.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
*
|
||||
***** BEGIN LICENSE BLOCK *****
|
||||
|
||||
Copyright (C) 2009-2017 Olof Hagsand and Benny Holmgren
|
||||
|
||||
This file is part of CLIXON.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
the GNU General Public License Version 3 or later (the "GPL"),
|
||||
in which case the provisions of the GPL are applicable instead
|
||||
of those above. If you wish to allow use of your version of this file only
|
||||
under the terms of the GPL, and not to allow others to
|
||||
use your version of this file under the terms of Apache License version 2,
|
||||
indicate your decision by deleting the provisions above and replace them with
|
||||
the notice and other provisions required by the GPL. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file under
|
||||
the terms of any one of the Apache License version 2 or the GPL.
|
||||
|
||||
***** END LICENSE BLOCK *****
|
||||
|
||||
* XML sort and earch functions when used with YANG
|
||||
*/
|
||||
#ifndef _CLIXON_XML_SORT_H
|
||||
#define _CLIXON_XML_SORT_H
|
||||
|
||||
/* Sort and binary search of XML children
|
||||
* Experimental
|
||||
*/
|
||||
extern int xml_child_sort;
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
int xml_child_spec(char *name, cxobj *xp, yang_spec *yspec, yang_stmt **yp);
|
||||
cxobj *xml_search(cxobj *x, char *name, int yangi, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval);
|
||||
cxobj *xml_match(cxobj *x0, char *name, enum rfc_6020 keyword, int keynr, char **keyvec, char **keyval);
|
||||
int match_base_child(cxobj *x0, cxobj *x1c, cxobj **x0cp, yang_stmt *yc);
|
||||
|
||||
#endif /* _CLIXON_XML_SORT_H */
|
||||
|
|
@ -155,10 +155,17 @@ struct yang_stmt{
|
|||
|
||||
char *ys_argument; /* String / argument depending on keyword */
|
||||
int ys_flags; /* Flags according to YANG_FLAG_* above */
|
||||
cg_var *ys_cv; /* cligen variable. The following stmts have cvs::
|
||||
leaf, leaf-list, mandatory, fraction-digits */
|
||||
cg_var *ys_cv; /* cligen variable. See ys_populate()
|
||||
Following stmts have cv:s:
|
||||
leaf: for default value
|
||||
leaf-list,
|
||||
config: boolean true or false
|
||||
mandatory: boolean true or false
|
||||
fraction-digits for fraction-digits */
|
||||
cvec *ys_cvec; /* List of stmt-specific variables
|
||||
Y_RANGE: range_min, range_max */
|
||||
Y_RANGE: range_min, range_max
|
||||
Y_LIST: vector of keys
|
||||
*/
|
||||
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
|
||||
};
|
||||
|
||||
|
|
@ -208,7 +215,7 @@ yang_stmt *yang_find(yang_node *yn, int keyword, char *argument);
|
|||
yang_stmt *yang_find_datanode(yang_node *yn, char *argument);
|
||||
yang_stmt *yang_find_schemanode(yang_node *yn, char *argument);
|
||||
yang_stmt *yang_find_topnode(yang_spec *ysp, char *name, int schemanode);
|
||||
|
||||
int yang_order(yang_stmt *y);
|
||||
int yang_print(FILE *f, yang_node *yn);
|
||||
int yang_print_cbuf(cbuf *cb, yang_node *yn, int marginal);
|
||||
int yang_parse(clicon_handle h, const char *yang_dir,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue