Summary of the invention
In order to address the above problem, the present invention proposes a kind of control method of inserting data into offline transaction of graphic database, it can be when graphic data base not be opened affairs data inserting.
The technical solution used in the present invention is as follows:
A kind of control method of inserting data into offline transaction of graphic database is characterized in that:
Non-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 the affair logic key-course, 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, other operate in to enter and all are in waiting status between the synchronization zone, 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 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 as follows:
The row title |
Data type |
Explanation |
node_id |
Number |
The ID that the overall situation is unique |
name |
String |
Be used for preserving the title of Node |
Defined attribute information among each node Node is kept at name is called among the data set DataSet of graphic_db_node_attr_def, the data structure of this DataSet is as follows:
Carry out following steps:
1) CLIENT PROGRAM is called API, and supplemental characteristic is passed to graphic data base;
2) check whether the destination node of wanting data inserting exists, if destination node exists, the step below then continuing to carry out, otherwise withdraw from;
3) check whether be inserted into data legal, if legal, the step below then continuing to carry out, otherwise withdraw from;
4) enter the synchronization zone;
5) generate the record identification RID that the overall situation is unique;
6) data inserting, the data data that imports into when calling API increases among the DataSet of the same name corresponding with the node of appointment;
7) withdraw from the synchronization zone.
Further:
In described step 1) in, the parameter that API imports into comprises: the title node_name and the new data data that will insert that will insert the node of new data.
In described step 2) in, check that the method whether 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 of this DataSet equates, if find respective record, illustrate that then destination node exists.
In described step 3) in, check to be inserted into data legal detailed step is as follows:
A. 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 of this DataSet equates, obtains the node_id of data;
B. Query Name is the DataSet of graphic_db_node_attr_def, searches the record that the value of the node_id row of this DataSet equates with the node_id value of just now obtaining in step a, the attribute column information of the in store present node of record set of coupling;
C. according to the attribute column information recording/collection that obtains among the step b, whether each attribute column among the data that inspection API imports into exists in record set, if there is no, illustrates that then the data of importing into are illegal;
D. by after the inspection of attribute column, according to the attribute column information recording/collection that obtains among the step b, whether the data type that again checks each property value among the data that API imports into conforms to definition in the record set, if do not conform to, then the data imported into of explanation are illegal;
E. after confirming as legal data by above-mentioned inspection, continue to carry out follow-up step, otherwise withdraw from.
The present invention has the following advantages:
1. insert with respect to the data in the online transaction, data inserting has been avoided a large amount of data interlocks in the non-online transaction, and it is higher to carry out efficient.
2. the indivisible atom type that is operating as of data inserting operates in the non-online transaction, is not subjected to the impact of online transaction locking, submission, rollback.
Embodiment
The present invention proposes a kind of control method of inserting data into offline transaction of graphic database, describe in detail 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 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, realized by existing storage engines by program, such as: traditional relational database, XML file etc.
DataSet (data set)
DataSet is the logic storage unit of data in the graphic data base, the logical definition of the 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 by following the DataSet interface is in the file of relational database, XML or user-defined format.Each DataSet is comprised of unique title and several row (Column) of the overall situation.Following two kinds of data types are supported in tabulation among the DataSet:
Type |
Explanation |
String |
Be used for preserving the descriptor of Textuality |
Number |
Be used for 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, such as when explaining an applications of computer network system, port in the switch, the network interface card of PC server, CPU, produce the manufacturer of accessory, we provide the client of service for it, user in the system, authority etc., each Node has a title that the overall situation is unique, its distinctive attributes with some, be used for recording configuration information, 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 such as Types Below.
Type |
Explanation |
String |
Be used for preserving the descriptor of Textuality |
Number |
Be used for preserving integer, floating number digital information |
Boolean |
Be used for preserving the data of Boolean type, only allow to preserve true or false |
Reference |
Quote type, when the data of preserving were the data of another one Node, we can come with the Reference type |
|
Quote the data of another one Node.During details vide infra to the detailed description of Reference. |
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 as follows:
The row title |
Data type |
Explanation |
node_id |
Number |
The ID that the overall situation is unique |
name |
String |
Be used for preserving 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 as follows:
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 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 RID 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 needs these Node 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 set up a SysUserServeCustomer by name between SysUser and Customer explains relation between the two.We explain this relation with Fig. 2, and Relation is exactly for the special object of describing Node and Node Relations Among.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 as follows:
The row title |
Data type |
Explanation |
relation_id |
Number |
The ID that the overall situation is unique |
name |
String |
Be used for preserving 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 by 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 as follows:
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 substantially can not change, such as: country, province, city etc.If adopt the mode of Relation to explain, then need and other Node between the large 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 by its attribute that has, 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 bar record among this Node of Industry with the mode of Reference attribute.The storage mode of data in DataSet 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 operation " and " non-online transaction data operation ".The online transaction data operation steps is followed successively by: create online transaction, carry out the online transaction data operation (in an online transaction this operation can repeatedly), submit to online transaction that operation is come into force or rollback online transaction abort operation.As shown in Figure 5.But not the online transaction data operation is not controlled by affairs, directly calls graphic data base API and gets final product, as shown in Figure 6.
As shown in Figure 7, non-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 the affair logic key-course, 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 enter and all are in waiting status between the synchronization zone, 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.Non-online transaction self stateless information is not so need preservation, only save data information.
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 as follows:
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.Equal default built-in following two row among these DataSet:
Table 15
The control of data inserting in the non-online transaction
As shown in Figure 8, in non-online transaction, the treatment scheme of data inserting is as follows:
(1) CLIENT PROGRAM is called API, and supplemental characteristic is passed to graphic data base.API imports following parameter into:
A.node_name, appointment will be inserted the title of the node of new data.
B.data, the new data that will insert.
(2) check whether the destination node of wanting data inserting 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 of this DataSet equates.If find respective record, illustrate that then destination node exists, the logic below continuing to carry out, otherwise withdraw from.
(3) check whether be inserted into data legal.The inspection step is as follows:
A. 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 of this DataSet equates.Obtain the node_id of data.
B. Query Name is the DataSet of graphic_db_node_attr_def, searches the record that the value of the node_id row of this DataSet equates with the node_id value of just now obtaining in step a.The attribute column information of the in store present node of record set of coupling.
C. according to the attribute column information recording/collection that obtains among the step b, whether each attribute column among the data that inspection API imports into exists in record set.If non-existent situation is arranged, illustrate that then the data of importing into are illegal.
D. by after the inspection of attribute column, according to the attribute column information recording/collection that obtains among the step b, whether the data type that again checks each property value among the data that API imports into conforms to definition in the record set.If situation about not conforming to is arranged, illustrate that then the data of importing into are illegal.
E. after confirming as legal data by above-mentioned inspection, the logic below continuing to carry out, otherwise withdraw from.
(4) enter the synchronization zone, the synchronization zone utilizes the synchronized thread synchronization locking of Java language to realize at synchronization, only having an operation can enter the synchronization zone.
(5) the overall unique RID by the newly-generated form up to specification of program.The RID form is: Node title+underscore+increase progressively numeral, a typical RID numerical value is similar to following form: Industry_109
(6) data inserting, the data that imports into when calling API is newly-increased to the of the same name DataSet corresponding with the node of appointment.Withdraw from the synchronization zone.Jump out the synchronized method of thread locked.Update is finished.