Summary of the invention
In order to address the above problem, the present invention proposes the control method of data query in a kind of graphic data base online transaction, to realize inquiry to online transaction.
The technical scheme that the present invention adopts is following:
The control method of data query in a kind of graphic data base online transaction is characterized in that:
Transaction Processing is divided into three layers from top to bottom:
The superiors are the API that is exposed to the external call program;
The middle layer is an affairs logic control layer; Be divided into synchronization zone and asynchronous district by class of operation; The synchronization zone means can only have an operation to carry out at one time, and other operate in to get between the synchronization zone and all are in waiting status, and this mechanism utilizes the thread synchronization lockout feature of Java language to realize; The operation in asynchronous district is then unrestricted, all can carry out at any time;
Orlop in DataSet, is preserved the status information of online transaction self for the DataSet operation level of abstraction of storage data, and the transaction status attribute information of data;
The status data of online transaction in the graphic data base is stored in name is called among the data set DataSet of graphic_db_tx_def, the data structure of this DataSet is following:
The definition information of each node Node in the graphic data base is kept at name is called among the data set DataSet of graphic_db_node_def, the data structure of this DataSet is following:
The row title |
Data type |
Explanation |
?node_id |
Number |
The ID that the overall situation is unique |
?name |
String |
Be used to preserve the title of Node |
With Relation the relation between Node and the Node is described; Each Relation all has title, a source Node, a target Node that the overall situation is unique; By the direction of source Node to target Node, be referred to as forward, be referred to as oppositely to the direction of initial Node by target Node; The definition information of each Relation is kept at name is called among the DataSet of graphic_db_relation_def, the data structure of this DataSet is following:
The row title |
Data type |
Explanation |
relation_id |
Number |
The ID that the overall situation is unique |
name |
String |
Be used to preserve the title of Relation |
source_node |
Number |
The ID of source Node |
target_node |
Number |
The ID of target Node |
Data among two Node that connect through Relation can connect, and the link information of all data is kept at name is called among the DataSet of graphic_db_relation_record_def, and the data structure of this DataSet is following:
Carry out following steps:
1) CLIENT PROGRAM calls API, and supplemental characteristic is passed to graphic data base;
2) whether the inspection affairs are effective, if affairs are invalid, then this calls end, and returns error message, on the contrary the step below continuing;
3) whether the inspection destination node exists, and does not withdraw from if do not exist then, otherwise proceeds following step;
4) whether the path expression of inspection return node data result collection is correct, then withdraws from as if incorrect, otherwise proceeds following step;
5) whether the inspection filtercondition is legal, if not conforming to rule withdraws from, otherwise proceeds following step;
6) whether inspection comprises path expression in the filtercondition, if comprise then carry out the query steps 7 based on path expression), otherwise carry out the simple queries step 8);
7) execution is changeed step 9) based on the condition query of path expression;
8) carry out simple queries;
9) return to API Calls person, this poll-final of the result set after will inquiring about.
Further:
In said step 1), the parameter that API imports into comprises: node_name, specify the start node title of inquiring about; Fetch_path specifies the associated nodes data of returning with the form of path expression; Filter, filtercondition; Tx_no, the affairs numbering.
In said step 2) in; Whether effective method is the inspection affairs: Query Name is the DataSet of graphic_db_node_def; Tx_no affairs numbering to import among the API is retrieved as filtercondition, if there is following situation, then affairs are invalid: record does not find; The value of is_commit row is 1 in the record, explains that affairs submit to; The value of is_rollback row is 1 in the record, and affairs rollback is described; The value of is_timeout row is 1 in the record, explains that affairs are out of date.
In said step 3); The method whether the inspection destination node exists is: Query Name is the DataSet of graphic_db_node_def; Search the data recording that the node_name value imported among value and the API in the name row equates,, the destination node existence is described then if find respective record.
In said step 4), whether correct method is the path expression of inspection return node data result collection: the resolution path expression formula is a starting point with the node_name that imports among the API; Query Name is the DataSet of graphic_db_relation_def, and is different according to the direction of relational expression, searches the data recording that is complementary with the name row in source_node row or the target_node row; If record exists; Explain that expression formula is correct, otherwise, explain that expression formula is illegal.
In said step 5), whether legal method is the inspection filtercondition:
If a. comprise path expression in the filtercondition; Then at first carry out the inspection of path expression legitimacy, inspection logical and step 4) is identical, obtains the Column Properties title in the filtercondition then; The DataSet of inquiry graphic_db_node_def by name; Check whether last node in the path expression comprises these row,, explain that then filtercondition is legal if comprise;
If b. do not comprise path expression in the filtercondition; Then directly obtain the Column Properties title in the filtercondition; Inquiry is called the DataSet of graphic_db_node_def then; Whether the node of checking the node_name that imports into the sign among the API comprises these row, if comprise, explains that then filtercondition is legal.
In said step 7), following based on the detailed step of the condition query of path expression:
A. reversing paths expression formula is a starting point with the terminal point of path expression in the filtercondition, is terminal point with its starting point, simultaneously with the direction reversing of relation;
The start node of the path expression after b. inquiry is reversed; Obtain the data matching record by filtercondition; If have in the result set _ value of dirty row be 1 and _ value and the current affairs of tx_no row number unequal data; Explain that this is recorded as the dirty data in other affairs, removes it from result set;
The result set of c. above step inquiry is a starting point; According to the path expression after the counter-rotating, be the DataSet of graphic_db_relation_record_def through Query Name, recurrence is obtained the record of opening relationships with it; If record _ value of drity row is 1; And record _ value and the current affairs of tx_no row are numbered unequally, explain that then this is recorded as the dirty data in other affairs, ignores this record;
D. the associated record of reversing paths expression formula peripheral node is the Query Result of current filtercondition.
In said step 8); The detailed step of simple queries is following: the node of the node_name parameter appointment of importing among the inquiry API; By filtercondition wherein record is mated, obtains the record that is consistent with filtercondition, if in the record _ value of dirty row be 1 and _ value and the current affairs of tx_no row are numbered unequal; Explain that then this is recorded as the dirty data in other affairs, removes this record from result set.
The present invention has the following advantages: have the characteristic of transaction isolation, the inquiry in certain online transaction can not receive the influence of other online transaction or non-online transaction.
Embodiment
The present invention proposes the control method of data query in a kind of graphic data base online transaction, specify below in conjunction with accompanying drawing.
The graphic data base general introduction
The framework of graphic data base of the present invention can be divided into three layers from top to bottom.As shown in Figure 1, the superiors are the tissue and the realization of various conceptual objects in the graph data.The middle layer is abstract data physical store interface layer, is several data sets DataSet with the data abstraction of physical store.Bottom is that physical store realizes layer, realizes by existing storage engines by program, such as: traditional relational database, XML file or the like.
DataSet (data set)
DataSet is the logic storage unit of data in the graphic data base; The logical definition of data in the graphic data base and database self all is stored among the DataSet; DataSet is an abstract interface, and the realization procedure stores that real data can be through following the DataSet interface is in the file of relational database, XML or user-defined format.Each DataSet is made up of with several row (Column) a unique title of the overall situation.The following two kinds of data types of tabulation support among the DataSet:
Type |
Explanation |
String |
Be used to preserve the descriptor of Textuality |
Number |
Be used to preserve integer, floating number digital information, or be used for preserving Boolean information, represent true with 1, represent false. with-1 |
Table 1
Node (node)
Node is the logical block of storage data in the graphic data base; In graphic data base; Each record entity can abstractly be Node all, and such as when explaining an applications of computer network system, the manufacturer of the network interface card of the port in the switch, PC server, CPU, production accessory, we provide client, the user in the system, authority of service or the like for it; Each Node has a title that the overall situation is unique; Its distinctive attribute is used for recording configuration information with some, for example: with respect to the client of our service; We are with its called after Customer, and it has following attribute: contractedAmount (contract total value), industry (affiliated industry), name (customer name), description (description) etc.In the present invention, the attribute of Node can be the data of following type.
Table 2
The definition information of each Node all is kept at name and is called among the DataSet of graphic_db_node_def, and the data structure of this DataSet is following:
The row title |
Data type |
Explanation |
?node_id |
Number |
The ID that the overall situation is unique |
?name |
String |
Be used to preserve the title of Node |
Table 3
Among each Node defined attribute information be kept at the name be called among the DataSet of graphic_db_node_attr_def, the data structure of this DataSet is following:
Table 4
Be directed to the definition of Node, similar following two tables of the DataSet of physical store:
Table 5
Table 6
The data message of each Node is kept among the DataSet of the same name with it, supposes that we have a name to be called the Node of Customer, and this Node has following attribute:
Property Name |
Data type |
Explanation |
RID |
String |
Database is built-in |
name |
String |
Customer name |
contractedAmount |
Number |
Contract value |
industry |
Reference |
Affiliated industry |
description |
String |
Client's descriptor |
Table 7
The DataSet structure that then this Node is corresponding is:
Table 8
The similar following table of the DataSet of physical store:
Table 9
RID (Record ID, Record ID)
In graphic data base, each Node can have a name to be called the attribute of RID, and the RID value that is stored in each the bar data among the Node all is that the overall situation is unique, is recorded in the sign in the graphic data base as this.The data type of RID is the String type.Each Node all contains this attribute.The RID form is: Node title+underscore+increase progressively numeral, a typical R ID numerical value is similar to following form: Industry_109.
Relation (relation)
The entity of each category information all can be abstract is Node, in real world applications, usually need these Node be got up by certain logical organization, and Relation is used for describing the membership credentials between Node and the Node.Suppose the now existing Node:Customer that represent client, representative system user's Node:SysUser, in real world, our sales force can become a user in the system, and be responsible for some clients sale, reach communication work.Therefore, we Relation that can between SysUser and Customer, set up a SysUserServeCustomer by name explains relation between the two.We explain this relation with Fig. 2, and Relation is used to describe the special object that concerns between Node and the Node.Each Relation all has a title that the overall situation is unique, a source Node, a target Node.By the direction of source Node to target Node, we are referred to as forward, and we are referred to as oppositely to the direction of initial Node by target Node.
The definition information of each Relation all is kept at name and is called among the DataSet of graphic_db_relation_def, and the data structure of this DataSet is following:
The row title |
Data type |
Explanation |
relation_id |
Number |
The ID that the overall situation is unique |
name |
String |
Be used to preserve the title of Relation |
source_node |
Number |
The ID of source Node |
target_node |
Number |
The ID of target Node |
Table 10
Be directed to the definition of Relation, the similar following table of the DataSet of physical store:
Table 11
According to the definition of Relation, the data among two Node that connect through Relation can connect.The link information of all data is kept at name and is called among the DataSet of graphic_db_relation_record_def, and the data structure of this DataSet is following:
Table 12
In application scenarios, the similar following table of the DataSet of its physical store:
Table 13
Reference (quoting)
In graphic data base was abstract, some Node commonly used can have relation with other most of Node, and these Node data volumes commonly used are very limited and can not change basically, such as: country, province, city etc.If adopt the mode of Relation to explain, then need and other Node between the big magnitude relation set up, this maintenance to the later stage will cause certain difficulty.Under this kind situation, can consider to adopt the form of Reference to explain relation.A Node quotes another one Node through the attribute that it had, and realizes in form at it, and is largely similar with the Foreign Key (external key) of RDBMS (relational database).That preserve in the Dictionary attribute of a certain record is the RID of data recording among the another one Node.Node---the Customer that we discussed before considering has this attribute of (industry) industry, supposes that in our application scenarios, the quantity of industry is very limited, and can often not change.Then can quote certain the bar record among this Node of Industry with the mode of Reference attribute.The storage mode of data in DataSet is as shown in Figure 3.
We dot the Reference between the Node in the present invention, to be different from Relation, see Fig. 4.
Online transaction and non-online transaction
The operation of data can be divided in the graphic data base: " online transaction data manipulation " and " non-online transaction data manipulation ".Online transaction data manipulation steps in sequence is: create online transaction, carry out online transaction data manipulation (this operation can repeat repeatedly in an online transaction), submit to online transaction that operation is come into force or rollback online transaction abort operation.See shown in Figure 5.But not the online transaction data manipulation is not controlled by affairs, directly calls graphic data base API and gets final product, and sees shown in Figure 6.
As shown in Figure 7, Transaction Processing of the present invention is divided into three layers from top to bottom:
The superiors are the API that is exposed to the external call program.
The middle layer is an affairs logic control layer; Be divided into synchronization zone and asynchronous district by class of operation; The synchronization zone means can only have an operation to carry out at one time, and other operate in to get between the synchronization zone and all are in waiting status, and this mechanism utilizes the thread synchronization lockout feature of Java language to realize.The operation in asynchronous district is then unrestricted, all can carry out at any time.
Orlop in DataSet, is preserved the status information of online transaction self for the DataSet operation level of abstraction of storage data, and the transaction status attribute information of data.
In graphic data base, the status data of online transaction is stored in name and is called among the DataSet of graphic_db_tx_def, and the data structure of this DataSet is following:
Table 14
Each Node all has a corresponding DataSet of the same name in graphic data base, and the Relation information between the data is kept at name and is called among the DataSet of graphic_db_relation_record_def.All default built-in following two row among these DataSet:
Table 15
The control of data query in the online transaction
In online transaction, the processing logic of data query is as shown in Figure 7:
(1) CLIENT PROGRAM calls API, and supplemental characteristic is passed to graphic data base.API imports following parameter into:
A.node_name specifies the start node title of inquiring about.
B.fetch_path specifies the associated nodes data of returning with the form of path expression.
C.filter, filtercondition
D.tx_no, the affairs numbering
(2) whether the inspection affairs are effective.The mechanism of judging does, inquiry graphic_db_tx_def retrieves as filtercondition with the tx_no affairs numbering of importing among the API, if there is following situation, then affairs are invalid:
A. record does not find
B. the value of is_commit is 1 in the record, explains that affairs submit to
C. the value of is_rollback is 1 in the record, and affairs rollback is described
D. the value of is_timeout is 1 in the record, explains that affairs are out of date
If affairs are invalid, then this calls end, and returns error message.Otherwise continue to carry out.
(3) whether the inspection destination node exists.Query Name is the DataSet of graphic_db_node_def, searches the data recording that the node_name value imported among value and the API in the name row equates.If find respective record, explain that then destination node exists, the logic below continuing to carry out, otherwise withdraw from.
(4) whether the path expression of inspection return node data result collection is correct.The resolution path expression formula is a starting point with the node_name that imports among the API, and Query Name is the DataSet of graphic_db_relation_def; Different according to the direction of relational expression, search in source_node row or the target_node row and to be complementary with the value of node_name and data recording that the value of name row equates with the title of current path expression formula, if write down existence; Explain that expression formula is correct; Otherwise, explain that expression formula is illegal, directly withdraw from.
(5) whether the inspection filtercondition is legal.
If a. comprise path expression in the filtercondition, then first-selection is carried out the inspection of path expression legitimacy, and inspection logical and step (4) is identical; Obtain the Column Properties title in the filtercondition then; The DataSet of inquiry graphic_db_node_def by name checks whether last node in the path expression comprises these row, if comprise; Explain that then filtercondition is legal, otherwise directly withdraw from.
If b. do not comprise path expression in the filtercondition; Then directly obtain the Column Properties title in the filtercondition; The DataSet of inquiry graphic_db_node_def by name checks whether the node of the node_name that imports into the sign among the API comprises these row, if comprise then; Explain that then filtercondition is legal, otherwise directly withdraw from.
(6) whether comprise path expression in the inspection filtercondition,, otherwise carry out simple queries if comprise the inquiry of carrying out based on path expression.
(7) execution is based on the condition query of path expression.
A. reversing paths expression formula is a starting point with the terminal point of path expression in the filtercondition, is terminal point with its starting point, simultaneously with the direction reversing of relation.
The start node of the path expression after b. inquiry is reversed; Obtain the data matching record by filtercondition; If have in the result set _ value of dirty row be 1 and _ value and the current affairs of tx_no row number unequal data; Explain that this is recorded as the dirty data in other affairs, removes it from result set.
The result set of c. above step inquiry is a starting point; According to the path expression after the counter-rotating, be the DataSet of graphic_db_relation_record_def through Query Name, recurrence is obtained the record of opening relationships with it; If record _ value of drity row is 1; And record _ value and the current affairs of tx_no row are numbered unequally, explain that then this is recorded as the dirty data in other affairs, ignores this record.
D. the associated record of reversing paths expression formula peripheral node is the Query Result of current filtercondition.
(8) carry out simple queries.The node of the node_name parameter appointment of importing among the inquiry API; By filtercondition wherein record is mated; Obtain the record that is consistent with filtercondition; If in the record _ value of dirty row be 1 and _ value and the current affairs of tx_no row are numbered unequally, explain that then this is recorded as the dirty data in other affairs, removes this record from result set.
(9) return to API Calls person, this poll-final of the result set after will inquiring about.