1. Technical Field
Embodiments of the present disclosure relates to data search methods, and more particularly, to a computing device and method for searching for parameters in a data model.
2. Description of Related Art
The broadband forum (DSL forum) has released TR-098 as a data model for network devices. TR-098 defines varieties of data objects that contain all necessary parameters for a network device. All parameters are named according to a hierarchical form similar to a tree (e.g., “x.y.z”). At present, to search for a parameter for obtaining its access function in a TR-098 like data model, what is often done is to compare characters in an input data string with characters in predefined parameter name strings from the head to the tail of the input data string. The aforementioned linear searching method may be time-consuming if the number of the characters in the input data string is large.
The disclosure, including the accompanying drawings in which like references indicate similar elements, is illustrated by way of examples and not by way of limitation. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
In general, the word “module,” as used hereinafter, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, for example, Java, C, or Assembly. One or more software instructions in the modules may be embedded in firmware. It will be appreciated that modules may comprised connected logic units, such as gates and flip-flops, and may comprise programmable units, such as programmable gate arrays or processors. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of computer-readable medium or other computer storage device.
In block S101, the creating module 11 creates a first hash table for storing index values of parameter names in a data model, where each parameter name corresponds to a leaf node in a hierarchical tree of the data model (please refer to
It is further understood that, in the data model, all parameters are leaf nodes of the tree.
In block S103, the creating module 11 creates a second hash table for storing index values of data paths of duplicate parameter names in the data model. In this embodiment, the index values of data paths of the duplicate parameter names in the data model are also computed using the hash function, and the second hash table is also stored in the storage device 20 of the computing device 100.
As shown in
In block S105, the reading module 12 reads a last character of an input data string. For example, if the input data string is “A. D. F. J”, then the character “J” is read, and if the input data string is “A. C. G”, then the character “G” is read.
In block S107, the searching module 13 computes an index value of the last character using the hash function, and searches for the index value in the first hash table. For example, the index value of the character “J” is 4, and the index value of the character “G” is 2.
In block S109, the searching module 13 determines if the index value of the last character exists in the first hash table. If the index value of the last character does not exist in the first hash table, which means there is no parameter name in the data model matching the last character, the procedure goes to block S123, the prompt module 14 causes a dialog box to be displayed on a display (not shown) of the computing device 100 to announce the input error. Otherwise, if the index value of the last character exists in the first hash table, which means there is at least one parameter name in the data model matching the last character, the procedure goes to block S111.
In block S111, the searching module 13 determines if the last character has duplicate index values in the first hash table. If the last character has duplicate index values in the first hash table, which means there is duplicate parameter names in the data model matching the last character, the procedure goes to block S119. For example, as shown in
In block S113, the searching module 13 compares the remaining characters one at a time in the data string in a reverse order with a corresponding parent node of a leaf node represented by the last character in the hierarchical tree of the data model. For example, excluding the last character “J” in the input data string “A. D. F. J”, the remaining characters are “A,” “D,” and “F,” then the reverse sequence of the remaining characters is “F,” “D,” and “A.” As shown in
In block S115, the searching module 13 determines if each remaining character matches a corresponding parent node of the leaf node. If any remaining character does not match a corresponding parent node of the leaf node, the procedure goes to block S123. Otherwise, if each remaining character matches a corresponding parent node of the leaf node, the procedure goes to block S117. For example, as mentioned above, excluding the last character “J” in the input data string “A. D. F. J”, the reverse sequence of the remaining characters is the same as the reverse sequence of the parent nodes of the leaf node “J” in the example data model, so the procedure goes to block S117.
In block S117, the searching module 13 determines a data path of a parameter matching the last character of the input data string in the data model, and obtains an access function of the parameter from the storage device 20 according to the data path. For example, a data path of the parameter “J” is “A. D. F. J”, and the access function of the parameter “J” may be obtained according to the record “Mo_A_D_F_J_Ptr” from the storage device 20 (please refer to
In block S119, the searching module 13 computes a total index value of all characters in the input data string using the hash function, and searches for the total index value in the second hash table. As mentioned above, if the input data string is “A. C. G”, because the character “G” has duplicate index values 2 in the first hash table, a record of the character “G” cannot be found according to the first hash table (please refer to
In block S121, the searching module 13 determines if the total index value exists in the second hash table. If the total index value does not exist in the second hash table, the procedure goes to block S123. Otherwise, if the total index value exists in the second hash table, the procedure goes to block S117. For example, the total index value of all characters in the input data string “A. C. G” is 1 that exists in the second hash table, so the procedure goes to block S117. Then, in block S117, the searching module 13 determines a data path of a parameter matching the last character of the input data string in the data model, and obtains an access function of the parameter from the storage device 20 according to the data path. For example, a data path of the parameter “G” is “A. C. G”, and the access function of the parameter “G” may be obtained according to the record “Mo_A_C_G_Ptr” from the storage device 20 (please refer to
The above embodiments use the first hash table to store index values of all parameter names in a data model, and use the second hash table to store index values of data paths of duplicate parameters names in the data model, and change the comparison sequence when searching for parameters in the data model. That is, comparing starting from the last character in the input data string, if a leaf node in the data model matches the last character, then comparing parent nodes of the leaf node with the remaining characters of the input data string. Therefore, a data path of a parameter having a unique name can be quickly located according to the first hash table. Furthermore, data paths of parameters having duplicate names can be located according to the second hash table. Due to that all parameter names in TR-098 like data model are known and fixed, the search method can reduce unnecessary comparison effort and improve search speed.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
| Number | Date | Country | Kind |
|---|---|---|---|
| 201010245054.6 | Aug 2010 | CN | national |