Background technology
Along with the fast development of the present computing machine and the network information technology, more and more be unable to do without use in existing office and the life for computing machine and network.Various a large amount of information and data have realized data sharing and remote transmission by network or unit operation.When the data in the database are managed, at the effective classified access of data and implement the method for advanced search and software also correspondingly produces and is applied.
The data managing method that obtains more application at present includes modes such as level, netted and relational database, though can solve the problem of data access and retrieval to a certain extent, sets up and uses this class commercial data base and still exist certain defective.Such as, database foundation and use cost are higher, just seem too expensive for small-sized data management unit; In addition, existing all being based at hard disk or tape as databases such as MS SQL, DBII and Oracle operated, and can't satisfy the requirement of real-time response, quick access and retrieval when data volume is big.Now also there is the memory database of employing to set up the pattern of data access and retrieval,, also taken bigger external memory and memory source space, particularly serious waste of resources for embedded system simultaneously though retrieval rate is very fast.
As mentioned above, existing various database accesss and search method all exist significant disadvantages and deficiency for small-sized data application units, in the public technology corresponding solution is not arranged now.
Summary of the invention
The method of realization class internal storage data library access of the present invention and retrieval is intended to address the above problem and not enough and design has data access and the search method that is applied to embedded system data base.
The method of described realization class internal storage data library access and retrieval according to data content and type and for the needs of data retrieval, is at first set up the storage list of corresponding data node.Described storage list is based on the data list structure of Hash table type, can be according to major key direct access target data.
Secondly, set up corresponding concordance list according to above-mentioned storage list, concordance list is based on the data list structure balanced binary tree modelling, that dynamically can sort.The advantage of described concordance list be can be quickly and easily as required the data in the his-and-hers watches sort.
At last, set up a preferential storage list of concordance list sort field according to above-mentioned concordance list, scan and analyze, the priority of attribute query is sorted specifying several times inquiry formerly, determine the ordering rule of index, thereby make the inquiry of data more efficient.And, inquiry times for the preferential storage list of sort field, can carry out repeatedly access and search operaqtion to the data in the database by using the method for described realization class internal storage data library access and retrieval, dynamically adjust according to the hit rate of each practical operation.
As mentioned above, the method for realization class internal storage data library access of the present invention and retrieval, the storage of data is that the third normal form according to relational database carries out, and can effectively prevent redundant and unusual.And compare with existing memory database search method, can immediate updating statistical query hit rate, have quite high data base administration and security performance, therefore can raise the efficiency and reduce the memory, external memory resource occupation.
Embodiment
As Fig. 1-shown in Figure 8, the method for realization class internal storage data library access of the present invention and retrieval is set up the storage list of corresponding data node at data content and type, to realize according to major key direct access target data.Set up corresponding concordance list according to storage list based on the balanced binary tree-model.Set up a preferential storage list of concordance list sort field according to above-mentioned concordance list, scan and analyze, the priority of attribute query is sorted, determine the ordering rule of index specifying several times inquiry formerly.
As shown in Figure 1, described storage list is based on that Hash table type structure sets up, by major key (boldface type) can the one-time positioning data the memory location, thereby use major key just can realize the fast data access.
According to data content in the described storage list and type, for effectively avoiding the whole redundancy and unusual that occurs of database, normally press the third normal form pattern in the relational database, set up the question blank that is used for fast query and data locking accordingly.
As shown in Figure 2, set up the balanced binary tree-model of concordance list, realize that the major key of each node manipulative indexing table is stored, and carried out optimum field ordering in advance according to above-mentioned storage list.Thereby the inquiry complexity minimum can guarantee that index hits the time.
As shown in Figure 3, comprise the priority data of storage list all properties in the preferential storage list of concordance list sort field, last column data in table be its above column the m line data and.
As shown in Figure 4, behind the m bar query note in analyzing the preferential storage list of above-mentioned concordance list sort field, hitting in the counting rate meter shown in up-to-date hit rate deposited in.
As shown in Figure 5, the initialization flow process of described class memory database is:
Read the up-to-date m of configuration and hit counting rate meter (as Fig. 4);
Set up described concordance list and balance Two Binomial Tree Model (as Fig. 2) and the preferential storage list of concordance list sort field (as Fig. 3);
Call the storage function in described class internal storage data library inquiry and the access flow process (as Fig. 8), set up all forms (as Fig. 1) in the database, further improve described concordance list (as Fig. 2) simultaneously.
As shown in Figure 6, be described class memory database ending phase synoptic diagram.
As shown in Figure 7, be described configuration file format table.
As shown in Figure 8, described class internal storage data library inquiry and access flow process are:
Need to analyze m bar query note, from above-mentioned Fig. 4, select hit rate the highest be m value, all identical as if hit rate, then selection at random;
After receiving query statement, at first total inquiry times is added 1, determining to relate to Field Count then is the NO. value, then respectively this weight (NO...1) is assigned to this memory range from big to small according to existing priority data at every turn; In i<=m, simply priority data and the summation of this weight with last time can obtain this priority data; Emptying this table data and put I when i>m is 0.
Carry out the concordance list ordering according to optimum field, then skip this step identical with the last time, and the value place in the preferential storage list of sort field as shown in Figure 3 adds 1; Screen first according to optimum field (if any) then, thereby the final back end key word that needs of obtaining finally carries out unirecord one by one and reads (do not have Keyword List can only traversal list all data).When carrying out the unirecord access, need only the storage list of directly looking into as shown in Figure 1, can guarantee after the function conversion of limited number of time, can obtain accurate location, and not need to check one by one;
Carrying out hit rate when total inquiry times is more than or equal to m calculates, inserting the relevant position then and putting total inquiry times is 0, therefrom select the highest the carrying out of hit rate m value (being maximum, then conduct of random choose m value next time simultaneously) next time then if hit to have in the counting rate meter more than individual position;
Rebulid storage list concordance list as shown in Figure 2;
Empty the preferential storage list of concordance list sort field as shown in Figure 3;
When stopping to serve, will hit counting rate meter and store external memory into, as the initial value of service operation next time as configuration file (as Fig. 4).