CN103902554B - Data access method and device - Google Patents
Data access method and device Download PDFInfo
- Publication number
- CN103902554B CN103902554B CN201210573013.9A CN201210573013A CN103902554B CN 103902554 B CN103902554 B CN 103902554B CN 201210573013 A CN201210573013 A CN 201210573013A CN 103902554 B CN103902554 B CN 103902554B
- Authority
- CN
- China
- Prior art keywords
- keyword
- user data
- data
- configuration file
- sub
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 238000004458 analytical method Methods 0.000 claims description 2
- 238000007726 management method Methods 0.000 description 14
- 230000006870 function Effects 0.000 description 4
- 238000012423 maintenance Methods 0.000 description 4
- 230000008859 change Effects 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 241001269238 Data Species 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000010354 integration Effects 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000002155 anti-virotic effect Effects 0.000 description 1
- 238000012550 audit Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 235000013399 edible fruits Nutrition 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 230000004215 skin function Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention provides a kind of data access method and device, wherein, data access method includes:The keyword of user data is obtained according to data definition, wherein, the data definition defines the corresponding keyword of user data of certain business and the corresponding keyword of configuration file of the business, wherein, the corresponding keyword of the user data of same business keyword corresponding with the configuration file of the business is identical;User data is obtained according to the keyword of the user data, generates user data tree;According to the keyword, access to the user data tree and/or the configuration file.By the present invention, realize user data and configuration data carries out unified access and management.
Description
Technical field
The present invention relates to client application technical field, more particularly to a kind of data access method and device.
Background technology
Client application is the software for the realization specific function for being deployed in client, such as Ali Wang Wang, QQ, antivirus software
Deng.Client application is generally formed by the combinations of services of each complexity, and the flow for such as replacing software interface appearance business includes:It visits
It asks associated server, various appearances is provided, push associated appearance data, record user's selection etc. are selected according to user.
Each business of client application has the dependence of configuration data and the generation of user data, at present to configuration data
Mainly have with the treating method of user data:Method one, configuration data are stored in the configuration file of each business, each business
All oneself accesses and parsing data, user data and each Self management of configuration data;Method two, user data and configuration data are all borrowed
Third party database is helped to store.In the above method, the configuration data edit operation simple and flexible of method a pair of client application, but
It is numerous and at random to will appear configuration file so that configuration data is difficult to maintenance and management;Each business must go to operate simultaneously
Disk file and parsing data so that the code of parsing configuration data software write is mixed and disorderly, is performed simultaneously inefficiency;Method
Although two configuration data has been managed concentratedly, there is unified data parsing, since user data and configuration data store
In a database file, therefore it is complicated for operation to edit configuration data, and when there is change in the configuration data later stage, can not be timely
It updates on the machine of client.
Therefore, existing data processing method is when each business goes to parse and accesses the data of itself, data meeting zero
It is random, and inefficiency, rapidly clear data and efficient management can not be got up, so as to cause software development can not be improved
Efficiency in the process.
Invention content
The present invention provides a kind of data access method and device, to solve existing data processing scheme inefficiency,
The problem of rapidly clear data and efficient management can not being got up.
To solve the above-mentioned problems, the invention discloses a kind of data access method, including:It is obtained and used according to data definition
The keyword of user data, wherein, the data definition defines the corresponding keyword of user data of certain business and the business
The corresponding keyword of configuration file, wherein, the corresponding keyword of user data of same business and the configuration file of the business
Corresponding keyword is identical;User data is obtained according to the keyword of the user data, generates user data tree;According to described
Keyword accesses to the user data tree and/or the configuration file.
Preferably, described the step of user data is obtained according to the keyword of the user data, generates user data tree
Including:The keyword of the user data is parsed, the separator in the keyword is successively by the keyword
Resolve to one to multiple grade keyword;Wherein, if the keyword resolves to level-one keyword, the level-one keyword is closed for father
Key word;If the keyword resolves to multistage keyword, the multistage keyword includes father's keyword and one of highest level
A or multiple sub- keywords according to rank height sequence, wherein, the corresponding user data of keyword of a rank includes this
The user data of rank and user data corresponding less than the keyword of this rank;Determine the corresponding number of users of keywords at different levels
According to according to the user data tree of the rank generation user data of the keywords at different levels.
Preferably, it is described according to the keyword, it accesses to the user data tree and/or the configuration file
Step includes:When being read out access to the user data tree and/or the configuration file, judged according to the keyword
With the presence or absence of corresponding user data tree;If in the presence of judging to whether there is under father's keyword node of the user data tree
Sub- keyword node;If there is no the sub- keyword nodes, the corresponding user data of father's keyword node is returned;If
There are the sub- keyword nodes, it is determined that sub- keyword node to be visited returns to the sub- keyword node to be visited
Corresponding user data;If there is no corresponding user data tree, according to configuration file described in the crucial word access, return
Configuration data in the configuration file.
Preferably, the corresponding keyword of the configuration file is divided into one to multiple grade according to the separator in the keyword and closes
Key word, wherein, if the keyword is divided into level-one keyword, the level-one keyword is father's keyword;If the keyword
It is divided into multistage keyword, then father keyword and one or more of the multistage keyword including highest level are according to rank height
The sub- keyword of sequence;Configuration data in the configuration file corresponds to storage according to the one to multiple grade keyword, wherein, one
The configuration data that the corresponding configuration data of keyword of a rank includes this rank is matched with corresponding less than the keyword of this rank
Put data;The configuration file according to the crucial word access, the step of returning to the configuration data in the configuration file
Including:Judge to whether there is the sub- keyword under father's keyword;If there is no the sub- keywords, the father is returned
The corresponding configuration data of keyword;If there are the sub- keywords, it is determined that sub- keyword to be visited returns described to be visited
The corresponding configuration data of sub- keyword.
Preferably, it is if described there is no corresponding user data tree, according to configuration file described in the key word access,
The step of returning to the configuration data in the configuration file includes:If there is no corresponding user data trees, judge in caching
With the presence or absence of the corresponding configuration data of the keyword;If in the presence of the configuration data is returned;If being not present, according to institute
Configuration file described in stating crucial word access returns to the configuration data in the configuration file, and the configuration data is added in institute
It states in caching.
Preferably, it is described according to the keyword, it accesses to the user data tree and/or the configuration file
Step includes:When carrying out write-access to the user data tree, corresponding use is judged whether according to the keyword
User data tree;If in the presence of judging to whether there is sub- keyword node under father's keyword node of the user data tree;If no
There are the sub- keyword nodes, then data are written in father's keyword node;If there are the sub- keyword node, really
Data are written in the sub- keyword node to be written in fixed sub- keyword node to be written;If there is no corresponding users
Data tree then generates corresponding user data tree according to the keyword and the corresponding user data of the keyword, determines to treat
Simultaneously data are written in the keyword node of write-in.
Preferably, the data definition also defines database and the number that the user data of each business uses
According to library path and, the storage path of the configuration file of each business and form;It is described according to the user data
The step of keyword acquisition user data, generation user data tree, includes:According to determining the keyword of the user data
The database and the path of the database that user data uses;According to the path of the database, access the database and obtain
The user data is taken, generates the user data tree;It is described according to the keyword, access to the configuration file
Step includes:According to the keyword, storage path and the form of the configuration file are determined;According to the storage path, adjust
Configuration file described in the File Open to be matched with the form with the configuration file, accesses to the configuration file.
To solve the above-mentioned problems, the invention also discloses a kind of data access device, including:Acquisition module, for root
The keyword of user data is obtained according to data definition, wherein, the user data that the data definition defines certain business is corresponding
Keyword and the corresponding keyword of the configuration file of the business, wherein, the corresponding keyword of user data of same business with
The corresponding keyword of configuration file of the business is identical;Generation module is used for being obtained according to the keyword of the user data
User data generates user data tree;Access modules for according to the keyword, to the user data tree and/or described are matched
File is put to access.
Preferably, the generation module parses for the keyword to the user data, according to the keyword
In separator the keyword is resolved into one to multiple grade keyword successively;Wherein, if the keyword resolves to level-one pass
Key word, then the level-one keyword is father's keyword;If the keyword resolves to multistage keyword, the multistage keyword
Father's keyword including highest level and one or more sub- keywords according to rank height sequence, wherein, rank
The corresponding user data of keyword includes the user data of this rank and user data corresponding less than the keyword of this rank;Really
Determine the corresponding user data of keywords at different levels, the user data of the user data is generated according to the rank of the keywords at different levels
Tree.
Preferably, the access modules are read out visit for working as to the user data tree and/or the configuration file
When asking, corresponding user data tree is judged whether according to the keyword;If in the presence of the user data tree is judged
It whether there is sub- keyword node under father's keyword node;If there is no the sub- keyword node, it is crucial to return to the father
The corresponding user data of word node;If there are the sub- keyword nodes, it is determined that sub- keyword node to be visited returns to institute
State the corresponding user data of sub- keyword node to be visited;If there is no corresponding user data tree, according to the key
Configuration file described in word access returns to the configuration data in the configuration file.
Preferably, the corresponding keyword of the configuration file is divided into one to multiple grade according to the separator in the keyword and closes
Key word, wherein, if the keyword is divided into level-one keyword, the level-one keyword is father's keyword;If the keyword
It is divided into multistage keyword, then father keyword and one or more of the multistage keyword including highest level are according to rank height
The sub- keyword of sequence;Configuration data in the configuration file corresponds to storage according to the one to multiple grade keyword, wherein, one
The configuration data that the corresponding configuration data of keyword of a rank includes this rank is matched with corresponding less than the keyword of this rank
Put data;The access modules return to the configuration in the configuration file in the configuration file according to the crucial word access
During data, judge to whether there is the sub- keyword under father's keyword;If there is no the sub- keyword, described in return
The corresponding configuration data of father's keyword;If there are the sub- keywords, it is determined that sub- keyword to be visited is waited to visit described in return
The corresponding configuration data of sub- keyword asked.
Preferably, if corresponding user data tree is being not present in the access modules, according to the crucial word access institute
Configuration file is stated, when returning to the configuration data in the configuration file, if there is no corresponding user data trees, judges to cache
In whether there is the corresponding configuration data of the keyword;If in the presence of the configuration data is returned;If being not present, basis
Configuration file described in the key word access, returns to the configuration data in the configuration file, and the configuration data is added in
In the caching.
Preferably, the access modules, for when to the user data tree carry out write-access when, according to the key
Word judges whether corresponding user data tree;If in the presence of, judge be under father's keyword node of the user data tree
It is no that there are sub- keyword nodes;If there is no the sub- keyword node, data are written in father's keyword node;If it deposits
In the sub- keyword node, it is determined that sub- keyword node to be written, in the sub- keyword node write-in to be written
Data;If there is no corresponding user data tree, generated according to the keyword and the corresponding user data of the keyword
Corresponding user data tree determines keyword node to be written and data is written.
Preferably, the data definition also defines database and the number that the user data of each business uses
According to library path and, the storage path of the configuration file of each business and form;
The generation module, for determining database that the user data uses according to the keyword of the user data
With the path of the database;According to the path of the database, access the database and obtain the user data, generate institute
State user data tree;The access modules are according to the keyword, when accessing to the configuration file, according to the pass
Key word determines storage path and the form of the configuration file;According to the storage path, the lattice with the configuration file are called
Configuration file described in the File Open that formula matches accesses to the configuration file.
Compared with prior art, the present invention has the following advantages:
The present invention provides a kind of user data and configuration data unified management and the scheme accessed, the program to pass through data
Definition presets the keyword of each user data and each configuration file, wherein, the user data and configuration file of same business
Keyword it is identical and unique, and then, the program obtains corresponding user data using the keyword that sets, generates number of users
According to tree;Then, keyword unified access user data and configuration data are utilized.Using keyword to user data and configuration data
Carry out unified access and management so that data access and management are simple and clear;It, can be rapidly by the present invention's by data definition
Data access scheme is integrated into various client applications, and can realize configuration file edit operation simple and flexible, in time more
New client application.
Description of the drawings
Fig. 1 is a kind of System data structure according to embodiments of the present invention;
Fig. 2 is a kind of step flow chart of according to embodiments of the present invention one data access method;
Fig. 3 is a kind of step flow chart of according to embodiments of the present invention two data access method;
Fig. 4 is a kind of step flow chart of according to embodiments of the present invention three method for reading data;
Fig. 5 is a kind of step flow chart of according to embodiments of the present invention four method for writing data;
Fig. 6 is a kind of structure diagram of according to embodiments of the present invention five data access device.
Specific embodiment
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, it is below in conjunction with the accompanying drawings and specific real
Applying mode, the present invention is described in further detail.
Data access scheme of the invention for ease of understanding is first explained the system data structure of the present invention.Such as
Shown in Fig. 1, system of the invention includes data definition, configuration file such as three software configuration data packet, user data structures.Its
In, data definition at least define each business the corresponding keyword of user data and each business configuration file it is corresponding
Keyword, also, the corresponding keyword of the user data keyword corresponding with the configuration file of the business of same business is identical.
Such as, for changing appearance business, then the corresponding user data of the business and configuration file use identical keyword.Client should
With can access according to keyword that the data definition is defined is unified to user data and/or configuration file.
The data access scheme of the present invention is illustrated with embodiment below.
Embodiment one
With reference to Fig. 2, a kind of step flow chart of according to embodiments of the present invention one data access method is shown.
The data access method of the present embodiment includes the following steps:
Step S102:The keyword of user data is obtained according to data definition.
Wherein, data definition definition (it can be appreciated that setting) the corresponding keyword of user data of some business and
The corresponding keyword of configuration file of the business, wherein, the corresponding keyword of user data and the business of same business
The corresponding keyword of configuration file is identical.
Business typically refers to each specific function of software, such as:Function, peace are automatically replied in instant message applications
The audit function of universe name changes interface skin function;What the user data of one business can be edited including client automatically replies
The data such as content, some skin of client's selection;It is safe domain name to include which domain name in configuration file, and interface skin has
The data such as several.
Step S104:User data is obtained according to the keyword of user data, generates user data tree.
Step S106:According to the keyword, access to user data tree and/or configuration file.
For example, when the user data that access change appearance business, first obtain outside the change defined in data definition
The corresponding keyword of user data of sight business;Then, user data is obtained according in the keyword to corresponding database, into
And generate user data tree;Because user data tree is according to keyword generation, therefore, can be determined further according to the keyword to be visited
User data tree in node, access;Fail if accessing user data tree, can match further according to the key word access
File is put, and then obtains corresponding data.It certainly, can also be according to the keyword, only to configuration when only needing to configure data
File accesses.
Through this embodiment, a kind of user data and configuration data unified management and the scheme accessed, the program are provided
The keyword of each user data and each configuration file is preset by data definition, wherein, the user data of same business and
The keyword of configuration file is identical and unique, and then, the program obtains corresponding user data using the keyword set, raw
Into user data tree;Then, keyword unified access user data and configuration data are utilized.Using keyword to user data and
Configuration data carries out unified access and management so that data access and management are simple and clear;By data definition, can rapidly by
The data access scheme of the present invention is integrated into various client applications, and can realize that configuration file edit operation is simply clever
Living, timely update client application.
Embodiment two
With reference to Fig. 3, a kind of step flow chart of according to embodiments of the present invention two data access method is shown.
The data access method of the present embodiment includes the following steps:
Step S202:Carry out data definition.
In this step, data definition defines the corresponding keyword of user data of each business and the configuration of each business
The corresponding keyword of file, wherein, the corresponding keyword of user data of same business is corresponding with the configuration file of the business
Keyword is identical.The corresponding keyword of user data for certain business that data definition defines is corresponding with the configuration file of the business
Keyword it is as follows:
Wherein DefinedConfigSources defines position and the form of data, and DefinedConfigFileKeys is fixed
Adopted configuration file for KEY.
It, can be according to certain rule automatically to the user data and configuration file of each business when carrying out data definition
Carry out keyword definition.The user data and configuration file of different business have different keywords.
Preferably, data definition can also define the road of database that the user data of each business uses and database
Diameter and, the storage path of the configuration file of each business and form.
Step S204:Access request input by user is received, determines user data to be visited.
Such as, the operation maintenance personnel of certain client application inputs access request, and request accesses the use of a certain client application
The client application appearance of family setting, then according to the access request, it may be determined that user data to be visited is a certain account
The appearance setting data of client application.At this point, user data is not specific data, the only mark of user data, such as
User data name is other.
Step S206:The keyword of user data is obtained according to data definition.
According to the correspondence of data definition in step S202, the keyword of user data to be visited is determined.
Step S208:The keyword of user data is parsed, the separator in keyword is successively by keyword
Resolve to one to multiple grade keyword.
Wherein, if keyword resolves to level-one keyword, level-one keyword is father's keyword;If keyword resolves to more
Grade keyword, then multistage keyword includes father's keyword of highest level and one or more sons according to rank height sequence close
Key word, wherein, the corresponding user data of keyword of any one rank includes the user data of this rank and less than this rank
The corresponding user data of keyword.That is, user data has also carried out corresponding classification, user data tree according to keyword-level
In the corresponding user data of a node in addition to the particular user data including this node, further include be subordinated to the node son knot
The corresponding particular user data of point.
Step S210:It determines the corresponding user data of keywords at different levels, number of users is generated according to the rank of keywords at different levels
According to user data tree.
Preferably, when data definition defines the path of the database that the user data of each business uses and database
When, the path of database that user data uses and database can be determined according to the keyword of user data;According to database
Path, database is accessed using the database access mode being adapted with database, and then obtain user data, ultimately generated
User data tree.
Step S212:According to the keyword, access to user data tree and/or configuration file.
Wherein, the keyword of user data obtained in the keyword, that is, step S206.
According to the keyword, access to user data tree and/or configuration file including:
(1) when being read out access to user data tree and/or configuration file
Corresponding user data tree is judged whether according to the keyword;
If there are corresponding user data tree, judge crucial with the presence or absence of son under father's keyword node of user data tree
Word node;If there is no sub- keyword nodes, the corresponding user data of father's keyword node is returned;If there are sub- keyword knots
Point, it is determined that sub- keyword node to be visited (can it is common tree data is searched by way of search it is determining
Sub- keyword node to be visited, when final sub- keyword node can not be found, it may be determined that finally find that
A node is sub- keyword node to be visited, because the data packet of the node contains its all subordinate's node that may be present
Data), return to the corresponding user data of sub- keyword node to be visited;
If there is no corresponding user data tree, according to the crucial word access configuration file, return in configuration file
Configuration data.
Preferably, the corresponding keyword of configuration file is divided into one to multiple grade key according to the separator in the keyword
Word, wherein, if keyword is divided into level-one keyword, level-one keyword is father's keyword;If keyword is divided into multistage keyword,
Then multistage keyword includes father's keyword of highest level and one or more sub- keywords according to rank height sequence;Configuration
Configuration data in file is corresponded to according to one to multiple grade keyword to be stored, wherein, the corresponding configuration number of keyword of a rank
According to the configuration data including this rank and configuration data corresponding less than the keyword of this rank;Then according to the crucial word access
Configuration file when returning to the configuration data in configuration file, first judges to whether there is sub- keyword under father's keyword;If it is not present
Sub- keyword then returns to the corresponding configuration data of father's keyword;If there are sub- keywords, it is determined that sub- keyword to be visited
(determining determining method of the method with above-mentioned user data tree), returns to the corresponding configuration data of sub- keyword to be visited.
Preferably, if there is no during corresponding user data tree, can also judge in caching with the presence or absence of the keyword
Corresponding configuration data;If exist in caching, corresponding configuration data in direct return cache;If being not present in caching,
Further according to the crucial word access configuration file, the configuration data in configuration file is returned to, and configuration data is added in caching.
By the caching mechanism of data, reduce operation of the client application to disk file, improve the performance of client application.
Preferably, when data definition defines storage path and the form of the configuration file of each business, then according to institute
Keyword is stated, accesses and may be used to configuration file:According to the keyword, storage path and the lattice of configuration file are determined
Formula;According to storage path, the File Open configuration file that the form with configuration file is called to match visits configuration file
It asks.Form such as configuration file is ZIP forms, then WINRAR can be called to open the configuration file, and then to the configuration file
It accesses.
(2) when carrying out write-access to user data tree
Corresponding user data tree is judged whether according to keyword;
If there are corresponding user data tree, judge crucial with the presence or absence of son under father's keyword node of user data tree
Word node;If there is no sub- keyword node, data are written in father's keyword node;If there are sub- keyword node, really
Data are written in sub- keyword node to be written in fixed sub- keyword node to be written;
It is if corresponding according to keyword and the corresponding user data generation of keyword there is no corresponding user data tree
User data tree determines keyword node to be written and data is written.
Wherein, it generates user data tree and determines that the mode of keyword node to be written can refer to described in (1), herein
It repeats no more.
Through this embodiment, it realizes in the management, maintenance and development process of client application, it can be by uniformly matching
The method for putting management, rapidly clear data and efficiently, management is got up, so as to improve the management of client application, safeguard
With the efficiency of exploitation, while the file read-write performance of client application is improved.On the one hand, the present embodiment is to configuration file and use
User data is uniformly managed and has been parsed, and convenient for the maintenance to data, while can be reduced by the caching mechanism of data
Operation of the client application to disk file improves the performance of client application;On the other hand, the present embodiment is to client
The configuration file and user data of application are stored separately, wherein, configuration file is stored with document form, and user data is with database
Form stores, but unified data access form is defined by data definition so that the access of data has unified interface, together
When maintain configuration file edit operation simple and flexible to client application, there is the configuration data of client application in the later stage more
It can also be updated on client machine in time when new.
Embodiment three
With reference to Fig. 4, a kind of step flow chart of according to embodiments of the present invention three method for reading data is shown.
The present embodiment is explained the data access scheme of the present invention in terms of digital independent, and the data of the present embodiment are read
Method is taken to include the following steps:
Step S302:According to data definition, obtain user data to be visited and the corresponding KEY of configuration file is (crucial
Word).
Step S304:Whole user data is obtained according to the KEY of user data.
Step S306:The KEY of user data is resolved to father KEY and multiple sub- KEY according to separator such as " | ".
The present embodiment it should be understood by those skilled in the art that in some cases, may only have by taking multistage KEY as an example
Father KEY.
Step S308:According to the father KEY and multiple sub- KEY parsed, user data is generated into a user data tree.
Step S310:Father KEY is searched in user data tree, judges whether to find, if so, performing step S312;
If it is not, then perform step S320.
Step S312:Judge whether father KEY has sub- KEY, if so, then performing step S316;If no, perform step
S314。
Step S314:Father KEY does not have sub- KEY, returns to the corresponding user data of father KEY, terminates flow.
If father KEY does not have sub- KEY, the corresponding user data of father KEY is read, and parses data and finds son to be visited
The corresponding user data of KEY returns.
Step S316:Father KEY has sub- KEY, then continues to search for, and judges whether the also sub- KEY of subordinate, if so, then returning to step
Rapid S312;If no, perform step S318.
Step S318:The corresponding user data of sub- KEY is read, to be visited sub- KEY pairs is parsed from the user data
The user data answered simultaneously returns to the user data, terminates flow.
Step S320:If father KEY is not found, judge whether to have during configuration file is data cached opposite with father KEY
The configuration data answered, if so, then returning to the configuration data;If it is not, perform step S322.
Step S322:If father is not searched according to data definition with father KEY corresponding configuration datas in caching
The corresponding configuration files of KEY.
Step S324:Judge whether configuration file corresponding with father KEY finds, if it is not, then returning to failed message, terminate
Flow;If so, perform step S326.
Step S326:Read the configuration data in configuration file.
Step S328:Judge in configuration data, whether father KEY has sub- KEY, if not having, performs step S330;If so,
Then perform step S332.
Step S330:If without sub- KEY, entire file data is returned to, and according to access frequency and time, data
It replaces in caching.
Step S332:If there is sub- KEY, then file data is parsed the corresponding configuration datas of sub- KEY, returned data,
And according to access frequency and time, in data displacement to caching.
Through this embodiment, a kind of uniform data reading side of the configuration data of user data and configuration file is provided
Case utilizes KEY unified access users data and profile data so that data access is simple and clear;Provide data definition,
It can rapidly will be in the solution integration of the present embodiment to various client applications;The access of the configuration data of configuration file is done
Caching process, can reduce access of the client application to disk file, improve the performance of client application.
Example IV
With reference to Fig. 5, a kind of step flow chart of according to embodiments of the present invention four method for writing data is shown.
The present embodiment is explained the data access scheme of the present invention in terms of data write-in, and the data of the present embodiment are write
Enter method to include the following steps:
Step S402:According to data definition, get user data to be visited and the corresponding KEY of configuration file is (crucial
Word).
Step S404:Whole user data is obtained according to the KEY of user data.
Step S406:The KEY of user data is resolved to father KEY and multiple sub- KEY according to separator such as " | ".
The present embodiment it should be understood by those skilled in the art that in some cases, may only have by taking multistage KEY as an example
Father KEY.
Step S408:According to the father KEY and multiple sub- KEY parsed, user data is generated into a user data tree.
Step S410:Judge father KEY whether is found in user data tree, if finding, perform step S412;If not yet
It finds, performs step S420.
Step S412:Judge whether father KEY has sub- KEY, if not having, perform step S414;If so, then perform step
S416。
Step S414:Father KEY does not have sub- KEY, then sets data in present node (i.e. father KEY), and present node
All son node numbers are according to deletion.
That is, write the data to the father KEY.
Step S416:Father KEY has sub- KEY then to continue to search for sub- KEY, judges whether the sub- KEY also has subordinate's
KEY, if so, then return to step S412;If no, perform step S418.
Step S418:If fruit KEY is not found, then the corresponding nodes of sub- KEY are created in data tree, and in the section of establishment
Point setting data.
Step S420:If father KEY is not found, the corresponding nodes of father KEY are created in data tree.
Step S422:Judge whether father KEY has sub- KEY, if so, then performing step S424;If no, perform step
S426。
Step S424:If father KEY has sub- KEY, the corresponding nodes of sub- KEY are created in data tree, until all sons
After the completion of KEY nodes are established, on the node of data setting to the end, terminate flow.
Step S426:If father KEY does not have sub- KEY, in data setting to the corresponding nodes of father KEY.
For example, to set KEY is KA | KA1 | the data of KA11, and to KEY analyses it is found that the KEY includes father KEY KA,
Sub- KEY KA1 and sub- KEY KA11, if not finding these KEY in data tree, it is corresponding that creates these KEY in tree
Node, data are finally set on KA11, the secondary setting KEY KA if any under | it is corresponding then to find KA1 for the data of KA1
Node, then KA11 knot removals, data are set on KA1, this is because here assert the corresponding data packet of KA1 nodes
Contained the data of KA11 respective nodes, and the corresponding number of KA1 nodes is newest data, thus here using newest data as
Standard deletes old data.
Through this embodiment, a kind of uniform data write-in side of the configuration data of user data and configuration file is provided
Case utilizes KEY unified access users data and profile data so that data access is simple and clear;Provide data definition,
It can rapidly will be in the solution integration of the present embodiment to various client applications;When data are written, father KEY data and son have been done
The merging of KEY data ensure that the uniqueness of latest data.
Embodiment five
With reference to Fig. 6, a kind of structure diagram of according to embodiments of the present invention five data access device is shown.
The data access device of the present embodiment includes:Acquisition module 502, for obtaining user data according to data definition
Keyword, wherein, data definition defines the corresponding keyword of user data of some business and the configuration file of the business
Corresponding keyword, wherein, the corresponding keyword of the user data key corresponding with the configuration file of the business of same business
Word is identical;Generation module 504 for obtaining user data according to the keyword of user data, generates user data tree;Access mould
Block 506, for according to the keyword, accessing to user data tree and/or configuration file.
Preferably, generation module 504 parse for the keyword to user data, the separation in keyword
Keyword is resolved to one to multiple grade keyword by symbol successively;Wherein, if keyword resolves to level-one keyword, level-one keyword
For father's keyword;If keyword resolves to multistage keyword, father keyword and one of the multistage keyword including highest level
Or multiple sub- keywords according to rank height sequence, wherein, the corresponding user data of keyword of a rank includes this grade
Other user data and user data corresponding less than the keyword of this rank;Determine the corresponding user data of keywords at different levels,
According to the user data tree of the rank generation user data of keywords at different levels.
Preferably, access modules 506, for when being read out access to user data tree and/or configuration file, according to
Keyword judges whether corresponding user data tree;If in the presence of, judge be under father's keyword node of user data tree
It is no that there are sub- keyword nodes;If there is no sub- keyword nodes, the corresponding user data of father's keyword node is returned;If it deposits
In sub- keyword node, it is determined that sub- keyword node to be visited returns to the corresponding user of sub- keyword node to be visited
Data;If there is no corresponding user data tree, according to crucial word access configuration file, the configuration number in configuration file is returned to
According to.
Preferably, the corresponding keyword of configuration file is divided into one to multiple grade keyword according to the separator in keyword,
In, if keyword is divided into level-one keyword, level-one keyword is father's keyword;If keyword is divided into multistage keyword, more
Grade keyword includes father's keyword of highest level and one or more sub- keywords according to rank height sequence;Configuration file
In configuration data according to one to multiple grade keyword correspond to store, wherein, the corresponding configuration data packet of keyword of a rank
Include the configuration data of this rank and configuration data corresponding less than the keyword of this rank;Access modules 506 are according to keyword
Configuration file is accessed, when returning to the configuration data in configuration file, judges to whether there is sub- keyword under father's keyword;If it does not deposit
In sub- keyword, then the corresponding configuration data of father's keyword is returned;If there are sub- keywords, it is determined that son to be visited is crucial
Word returns to the corresponding configuration data of sub- keyword to be visited.
Preferably, if corresponding user data tree is being not present in access modules 506, text is configured according to crucial word access
Part when returning to the configuration data in configuration file, if there is no corresponding user data tree, is judged in caching with the presence or absence of pass
The corresponding configuration data of key word;If in the presence of configuration data is returned;If being not present, according to crucial word access configuration file, return
The configuration data in configuration file is returned, and configuration data is added in caching.
Preferably, access modules 506, for when carrying out write-access to user data tree, being according to keyword judgement
It is no that there are corresponding user data trees;If in the presence of judging crucial with the presence or absence of son under father's keyword node of user data tree
Word node;If there is no sub- keyword node, data are written in father's keyword node;If there are sub- keyword node, really
Data are written in sub- keyword node to be written in fixed sub- keyword node to be written;If there is no corresponding user data
Tree then generates corresponding user data tree according to keyword and the corresponding user data of keyword, determines keyword to be written
Simultaneously data are written in node.
Preferably, data definition also defines the path of database that the user data of each business uses and database,
And storage path and the form of the configuration file of each business;Generation module 504, for the keyword according to user data
Determine the path of database that user data uses and database;According to the path of database, access database and obtain number of users
According to generation user data tree;Access modules 506 are according to keyword, when accessing to configuration file, according to keyword, really
Determine storage path and the form of configuration file;According to storage path, the File Open that the form with configuration file is called to match
Configuration file accesses to configuration file.
The data access device of the present embodiment is used to implement corresponding data access method in aforesaid plurality of embodiment of the method,
And the advantageous effect with corresponding embodiment of the method, details are not described herein.
Each embodiment in this specification is described by the way of progressive, the highlights of each of the examples are with
The difference of other embodiment, just to refer each other for identical similar part between each embodiment.For device embodiment
For, since it is basicly similar to embodiment of the method, so description is fairly simple, referring to the portion of embodiment of the method in place of correlation
It defends oneself bright.
A kind of data access method provided by the present invention and device are described in detail above, it is used herein
Specific case is expounded the principle of the present invention and embodiment, and the explanation of above example is only intended to help to understand this
The method and its core concept of invention;Meanwhile for those of ordinary skill in the art, thought according to the present invention, specific
There will be changes in embodiment and application range, in conclusion the content of the present specification should not be construed as to the present invention's
Limitation.
Claims (14)
1. a kind of data access method, which is characterized in that including:
The keyword of user data is obtained according to data definition, wherein, the data definition defines the user data of certain business
Corresponding keyword and the corresponding keyword of the configuration file of the business, wherein, the corresponding pass of user data of same business
Key word keyword corresponding with the configuration file of the business is identical;
The keyword of the user data is parsed, the separator in the keyword is successively by the keyword solution
It analyses as one to multiple grade keyword;
It determines the corresponding user data of keywords at different levels, the use of the user data is generated according to the rank of the keywords at different levels
User data tree;
According to the keyword, access to the user data tree and/or the configuration file.
2. according to the method described in claim 1, it is characterized in that,
If the keyword resolves to level-one keyword, the level-one keyword is father's keyword;
If the keyword resolves to multistage keyword, father keyword and one of the multistage keyword including highest level
Or multiple sub- keywords according to rank height sequence, wherein, the corresponding user data of keyword of a rank includes this grade
Other user data and user data corresponding less than the keyword of this rank.
3. according to the method described in claim 2, it is characterized in that, described according to the keyword, to the user data tree
And/or configuration file the step of accessing, includes:
When being read out access to the user data tree and/or the configuration file, judged whether according to the keyword
There are corresponding user data trees;
If in the presence of judging to whether there is sub- keyword node under father's keyword node of the user data tree;If it is not present
The sub- keyword node then returns to the corresponding user data of father's keyword node;If there are the sub- keyword node,
It then determines sub- keyword node to be visited, returns to the corresponding user data of sub- keyword node to be visited;
If there is no corresponding user data tree, according to configuration file described in the crucial word access, the configuration text is returned to
Configuration data in part.
4. according to the method described in claim 3, it is characterized in that, the corresponding keyword of the configuration file is according to the key
Separator in word is divided into one to multiple grade keyword, wherein, if the keyword is divided into level-one keyword, the level-one is crucial
Word is father's keyword;If the keyword is divided into multistage keyword, the father that the multistage keyword includes highest level is crucial
Word and one or more sub- keywords according to rank height sequence;Configuration data in the configuration file according to described one to
Multistage keyword corresponds to storage, wherein, the corresponding configuration data of keyword of a rank include this rank configuration data and
Configuration data corresponding less than the keyword of this rank;
The configuration file according to the crucial word access, the step of returning to the configuration data in the configuration file, wrap
It includes:Judge to whether there is the sub- keyword under father's keyword;If there is no the sub- keyword, return to the father and close
The corresponding configuration data of key word;If there are the sub- keywords, it is determined that sub- keyword to be visited returns described to be visited
The corresponding configuration data of sub- keyword.
5. according to the method described in claim 4, it is characterized in that, if described be not present corresponding user data tree, basis
Configuration file described in the key word access, the step of returning to the configuration data in the configuration file, include:
If there is no corresponding user data tree, judge in caching with the presence or absence of the corresponding configuration data of the keyword;
If in the presence of the configuration data is returned;
If being not present, according to configuration file described in the crucial word access, the configuration data in the configuration file is returned, and
The configuration data is added in the caching.
6. according to the method described in claim 2, it is characterized in that, described according to the keyword, to the user data tree
And/or configuration file the step of accessing, includes:
When carrying out write-access to the user data tree, corresponding user data is judged whether according to the keyword
Tree;
If in the presence of judging to whether there is sub- keyword node under father's keyword node of the user data tree;If it is not present
Then data are written in father's keyword node in the sub- keyword node;If there are the sub- keyword nodes, it is determined that treats
Data are written in the sub- keyword node to be written in the sub- keyword node of write-in;
If there is no corresponding user data tree, according to the keyword and the corresponding user data generation pair of the keyword
The user data tree answered determines keyword node to be written and data is written.
7. according to the method described in claim 1, it is characterized in that, the data definition also defines the use of each business
Database that user data uses and the path of the database and, the storage path of the configuration file of each business and
Form;
It is described according to the keyword of the user data obtain user data, generate user data tree the step of include:According to institute
The keyword for stating user data determines the path of database that the user data uses and the database;According to the data
The path in library accesses the database and obtains the user data, generates the user data tree;
It is described according to the keyword, the step of accessing to the configuration file, includes:According to the keyword, institute is determined
State storage path and the form of configuration file;According to the storage path, call what the form with the configuration file matched
Configuration file described in File Open accesses to the configuration file.
8. a kind of data access device, which is characterized in that including:
Acquisition module, for obtaining the keyword of user data according to data definition, wherein, the data definition defines certain industry
The corresponding keyword of user data of business and the corresponding keyword of configuration file of the business, wherein, the user of same business
The corresponding keyword of data keyword corresponding with the configuration file of the business is identical;
Generation module parses for the keyword to the user data, and the separator in the keyword is successively
The keyword is resolved into one to multiple grade keyword;The corresponding user data of keywords at different levels is determined, according to the passes at different levels
The rank of key word generates the user data tree of the user data;
Access modules, for according to the keyword, accessing to the user data tree and/or the configuration file.
9. device according to claim 8, which is characterized in that
If the keyword resolves to level-one keyword, the level-one keyword is father's keyword;If the keyword parsing
For multistage keyword, then the multistage keyword includes father's keyword of highest level and one or more is arranged according to rank height
The sub- keyword of sequence, wherein, the corresponding user data of keyword of a rank includes the user data of this rank and less than this
The corresponding user data of keyword of rank.
10. device according to claim 9, which is characterized in that the access modules, for when to the user data tree
And/or the configuration file judges whether corresponding user data tree when being read out access according to the keyword;If
In the presence of, then judge under father's keyword node of the user data tree whether there is sub- keyword node;If there is no the sons
Keyword node then returns to the corresponding user data of father's keyword node;If there are the sub- keyword nodes, it is determined that
Sub- keyword node to be visited returns to the corresponding user data of sub- keyword node to be visited;If there is no correspond to
User data tree, then the configuration file according to the crucial word access, returns to the configuration data in the configuration file.
11. device according to claim 10, which is characterized in that the corresponding keyword of the configuration file is according to the pass
Separator in key word is divided into one to multiple grade keyword, wherein, if the keyword is divided into level-one keyword, the level-one is closed
Key word is father's keyword;If the keyword is divided into multistage keyword, the father that the multistage keyword includes highest level is closed
Key word and one or more sub- keywords according to rank height sequence;Configuration data in the configuration file is according to described one
It corresponds to and stores to multistage keyword, wherein, the corresponding configuration data of keyword of a rank includes the configuration data of this rank
With configuration data corresponding less than the keyword of this rank;
The access modules return to the configuration data in the configuration file in the configuration file according to the crucial word access
When, judge to whether there is the sub- keyword under father's keyword;If there is no the sub- keyword, return to the father and close
The corresponding configuration data of key word;If there are the sub- keywords, it is determined that sub- keyword to be visited returns described to be visited
The corresponding configuration data of sub- keyword.
12. according to the devices described in claim 11, which is characterized in that if corresponding number of users is being not present in the access modules
According to tree, then the configuration file according to the crucial word access, when returning to the configuration data in the configuration file, if being not present
Corresponding user data tree is then judged in caching with the presence or absence of the corresponding configuration data of the keyword;If in the presence of institute is returned
State configuration data;If being not present, according to configuration file described in the crucial word access, the configuration in the configuration file is returned to
Data, and the configuration data is added in the caching.
13. device according to claim 9, which is characterized in that the access modules, for when to the user data tree
When carrying out write-access, corresponding user data tree is judged whether according to the keyword;If in the presence of the use is judged
It whether there is sub- keyword node under father's keyword node of user data tree;If there is no the sub- keyword node, in institute
State father's keyword node write-in data;If there are the sub- keyword nodes, it is determined that sub- keyword node to be written, in institute
State sub- keyword node write-in data to be written;If there is no corresponding user data tree, according to the keyword and institute
It states the corresponding user data of keyword and generates corresponding user data tree, determine keyword node to be written and data are written.
14. device according to claim 8, which is characterized in that the data definition also defines each business
Database that user data uses and the path of the database and, the storage path of the configuration file of each business
And form;
The generation module, for determining database and institute that the user data uses according to the keyword of the user data
State the path of database;According to the path of the database, access the database and obtain the user data, generate the use
User data tree;
The access modules when accessing to the configuration file, according to the keyword, are determined according to the keyword
The storage path of the configuration file and form;According to the storage path, the form with the configuration file is called to match
File Open described in configuration file, access to the configuration file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210573013.9A CN103902554B (en) | 2012-12-25 | 2012-12-25 | Data access method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210573013.9A CN103902554B (en) | 2012-12-25 | 2012-12-25 | Data access method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103902554A CN103902554A (en) | 2014-07-02 |
CN103902554B true CN103902554B (en) | 2018-06-29 |
Family
ID=50993883
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210573013.9A Active CN103902554B (en) | 2012-12-25 | 2012-12-25 | Data access method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103902554B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105956140B (en) * | 2016-05-12 | 2019-03-22 | 无锡威泰迅电力科技有限公司 | The method that data are locally stored based on mixed mode mobile application |
CN108304186B (en) * | 2016-08-16 | 2021-07-06 | 阿里巴巴集团控股有限公司 | Method and equipment for executing multiple operations based on synthetic configuration file |
CN108073635B (en) * | 2016-11-18 | 2021-08-27 | 中国电力科学研究院有限公司 | System for loading data scene of electric power information system and loading method thereof |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1650295A (en) * | 2001-09-28 | 2005-08-03 | 克莱特动力有限公司 | Method and system for database queries and information delivery |
CN1652534A (en) * | 2004-02-03 | 2005-08-10 | 华为技术有限公司 | Method for storing character string matching rule and character string matching by storing rule |
CN102006281A (en) * | 2010-10-19 | 2011-04-06 | 中国联合网络通信集团有限公司 | Soft terminal data processing method and system and devices |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7822793B2 (en) * | 2005-04-01 | 2010-10-26 | Microsoft Corporation | User data profile namespace |
CN105447166A (en) * | 2015-12-03 | 2016-03-30 | 沈文策 | Keyword based information search method and system |
-
2012
- 2012-12-25 CN CN201210573013.9A patent/CN103902554B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1650295A (en) * | 2001-09-28 | 2005-08-03 | 克莱特动力有限公司 | Method and system for database queries and information delivery |
CN1652534A (en) * | 2004-02-03 | 2005-08-10 | 华为技术有限公司 | Method for storing character string matching rule and character string matching by storing rule |
CN102006281A (en) * | 2010-10-19 | 2011-04-06 | 中国联合网络通信集团有限公司 | Soft terminal data processing method and system and devices |
Also Published As
Publication number | Publication date |
---|---|
CN103902554A (en) | 2014-07-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Demertzis et al. | Dynamic searchable encryption with small client storage | |
Shi et al. | Oblivious RAM with O ((log N) 3) worst-case cost | |
CN103348344B (en) | Composite term index for graph data | |
US7895176B2 (en) | Entry group tags | |
US10073876B2 (en) | Bloom filter index for device discovery | |
US8738657B2 (en) | Distribution of key values | |
EP2064637B1 (en) | Method for dynamic secure management of an authenticated relational table in a database | |
WO2007041290A1 (en) | Method and system for creating an index arrangement for a directory | |
US20130282741A1 (en) | High-throughput message generation | |
CN105447166A (en) | Keyword based information search method and system | |
CN110263104A (en) | JSON character string processing method and device | |
CN103902554B (en) | Data access method and device | |
CN104239337B (en) | Processing method and processing device of tabling look-up based on TCAM | |
CN102724301B (en) | Cloud database system and method and equipment for reading and writing cloud data | |
US11055266B2 (en) | Efficient key data store entry traversal and result generation | |
Moataz et al. | Oblivious substring search with updates | |
CN107239568B (en) | Distributed index implementation method and device | |
CN101374307B (en) | Method and apparatus for updating digital content information of mobile equipment | |
CN102214214B (en) | Method and device for processing data relationship and mobile communication terminal | |
KR101743731B1 (en) | Method and apparatus for processing quary based on ontology generated by collaborating distributed data | |
US20080126309A1 (en) | Hybrid groups | |
US11836130B2 (en) | Relational database blockchain accountability | |
CN105871726A (en) | Mode matching method for dynamically adding tree node and unit based on common prefix | |
CN111898157A (en) | Inadvertent storage access methods for machine learning multi-source training sets | |
CN102682068A (en) | Method and system for searching user name |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |