CN107688612A - Data manipulation method, device and computer equipment - Google Patents
Data manipulation method, device and computer equipment Download PDFInfo
- Publication number
- CN107688612A CN107688612A CN201710657501.0A CN201710657501A CN107688612A CN 107688612 A CN107688612 A CN 107688612A CN 201710657501 A CN201710657501 A CN 201710657501A CN 107688612 A CN107688612 A CN 107688612A
- Authority
- CN
- China
- Prior art keywords
- lock
- relation
- application
- read
- operated
- 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.)
- Granted
Links
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/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/176—Support for shared access to files; File sharing support
- G06F16/1767—Concurrency control, e.g. optimistic or pessimistic approaches
- G06F16/1774—Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (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 application proposes a kind of data manipulation method, device and computer equipment, wherein, above-mentioned data manipulation method includes:Receive data operation request;After the parent object addition relation lock of operation object is treated in application, apply to the object addition Structural lock to be operated;Data manipulation is carried out to the object to be operated according to the data operation request.The application can be realized by relation lock and Structural lock neatly control data concurrent operations, and being controlled with thinner Control granularity to concurrent operations, improve the concurrent efficiency of data manipulation.
Description
Technical field
The application is related to Computer Applied Technology field, more particularly to a kind of data manipulation method, device and computer are set
It is standby.
Background technology
In software systems, the application of tree-like dependence object is extremely wide.Such as mechanism level, organizational hierarchy and text
Part systemic hierarchial etc., it can be described as tree-like dependence object.Such as:The first group, the first headquarters and the first thing
Industry portion, the first division department depends on the first group and the first headquarters, if the first group is not present, then also just do not deposit
In the first division department.
In software systems, concurrent operations are very common.If be not controlled by concurrent operations, can to obtain
Data there is the situation of entanglement.Such as:One operation is employee's sum of the statistics first group, and an operation is the first cause
Portion increases new employee, and employee's sum of the first group is counted while new employee is increased, can make it that the employee that statistics obtains is total
Number is incorrect.
In existing correlation technique, a kind of scheme is by after all operation used in system and the object binding to be operated
Classified, and configuration concurrency rule, this solution lacks flexibility, when system needs increase and decrease business, it is necessary to change
System realizes that cost is higher, is unfavorable for safeguarding.
Another scheme is will to operate the lock for adding coarseness, such as a branch is pinned in branch's lock, every time operation, this
Sample, just can be concurrent only when operation is belonging respectively to Liang Ge branches, therefore the concurrent Control granularity of this scheme is thicker, though
So solve concurrent problem, but it is concurrent less efficient.
The content of the invention
The application is intended to one of technical problem at least solving in correlation technique to a certain extent.
Therefore, first purpose of the application is to propose a kind of data manipulation method, is locked and tied by relation to realize
Structure locks neatly control data concurrent operations, and being controlled with thinner Control granularity to concurrent operations, improves
The concurrent efficiency of data manipulation.
Second purpose of the application is to propose a kind of data operation device.
The 3rd purpose of the application is to propose a kind of computer equipment.
The 4th purpose of the application is to propose a kind of non-transitorycomputer readable storage medium.
The 5th purpose of the application is to propose a kind of computer program product.
For the above-mentioned purpose, the application first aspect embodiment proposes a kind of data manipulation method, including:Receive data behaviour
Ask;After the parent object addition relation lock of operation object is treated in application, apply to the object addition Structural lock to be operated;
Data manipulation is carried out to the object to be operated according to the data operation request.
In the data manipulation method of the embodiment of the present application, data operation request is received, the father of operation object is treated in application
After object addition relation lock, apply to above-mentioned object addition Structural lock to be operated, then according to above-mentioned data operation request pair
Above-mentioned object to be operated carries out data manipulation, so as to realize that neatly control data is concurrently grasped with Structural lock by relation lock
Make, and concurrent operations can be controlled with thinner Control granularity, improve the concurrent efficiency of data manipulation.
For the above-mentioned purpose, the application second aspect embodiment proposes a kind of data operation device, including:Receive mould
Block, for receiving data operation request;Apply for module, after the parent object addition relation lock for applying for treating operation object,
Application adds Structural lock to the object to be operated;Data operation modules, for the data behaviour received according to the receiving module
Ask to carry out data manipulation to the object to be operated.
In the data operation device of the embodiment of the present application, receiving module receives data operation request, in application module application
After the parent object addition relation lock for treating operation object, apply adding Structural lock to above-mentioned object to be operated, then data are grasped
Make module and data manipulation is carried out to above-mentioned object to be operated according to above-mentioned data operation request, locked so as to realize by relation
With Structural lock neatly control data concurrent operations, and being controlled with thinner Control granularity to concurrent operations, carry
The concurrent efficiency of data manipulation is risen.
For the above-mentioned purpose, the application third aspect embodiment proposes a kind of computer equipment, including memory, processing
Device and the computer program that can be run on the memory and on the processor is stored in, meter described in the computing device
During calculation machine program, method as described above is realized.
To achieve these goals, the application fourth aspect embodiment proposes a kind of computer-readable storage of non-transitory
Medium, is stored thereon with computer program, and the computer program realizes method as described above when being executed by processor.
To achieve these goals, the aspect embodiment of the application the 5th proposes a kind of computer program product, when described
When instruction processing unit in computer program product performs, method as described above is realized.
The aspect and advantage that the application adds will be set forth in part in the description, and will partly become from the following description
Obtain substantially, or recognized by the practice of the application.
Brief description of the drawings
The above-mentioned and/or additional aspect of the application and advantage will become from the following description of the accompanying drawings of embodiments
Substantially and it is readily appreciated that, wherein:
Fig. 1 is the flow chart of the application data manipulation method one embodiment;
Fig. 2 is the schematic diagram that relation locks one embodiment in the application data manipulation method;
Fig. 3 is the schematic diagram of Structural lock one embodiment in the application data manipulation method;
Fig. 4 is the schematic diagram of relation one embodiment of relation lock and Structural lock in the application data manipulation method;
Fig. 5 is the schematic diagram for being related to another embodiment of relation lock and Structural lock in the application data manipulation method;
Fig. 6 is the schematic diagram of the relation further embodiment of relation lock and Structural lock in the application data manipulation method;
Fig. 7 is the schematic diagram of the relation further embodiment of relation lock and Structural lock in the application data manipulation method;
Fig. 8 (a)~Fig. 8 (b) operates the schematic diagram of one embodiment for the Data Concurrent in the application data manipulation method;
Fig. 9 is the flow chart of another embodiment of the application data manipulation method;
Figure 10 is the schematic diagram that addition relation locks one embodiment in the application data manipulation method;
Figure 11 is to read to count the schematic diagram of one embodiment in the application data manipulation method;
Figure 12 is the schematic diagram that application structure read lock one embodiment is waited in the application data manipulation method;
Figure 13 is the flow chart of the application data manipulation method further embodiment;
Figure 14 is that the schematic diagram for counting one embodiment is write in the application data manipulation method;
Figure 15 is the schematic diagram for waiting application relation to lock one embodiment in the application data manipulation method;
Figure 16 is the schematic diagram that synchrolock fairness scheme one embodiment is counted in the application data manipulation method;
Figure 17 is the schematic diagram that the non-fairness scheme one embodiment of synchrolock is counted in the application data manipulation method;
Figure 18 is the structural representation of the application data operation device one embodiment;
Figure 19 is the structural representation of another embodiment of the application data operation device;
Figure 20 is the structural representation of the application computer equipment one embodiment.
Embodiment
Embodiments herein is described below in detail, the example of the embodiment is shown in the drawings, wherein from beginning to end
Same or similar label represents same or similar element or the element with same or like function.Below with reference to attached
The embodiment of figure description is exemplary, it is intended to for explaining the application, and it is not intended that limitation to the application.
Fig. 1 is the flow chart of the application data manipulation method one embodiment, as shown in figure 1, above-mentioned data manipulation method
It can include:
Step 101, data operation request is received.
Step 102, after the parent object addition relation lock of operation object is treated in application, apply adding above-mentioned object to be operated
Add Structural lock.
Wherein, above-mentioned relation lock is keeps the lock of dependent objects relation, after adding relation to lock to an object, from root pair
As that can not change to the dependence for locking object, Fig. 2 is that relation locks showing for one embodiment in the application data manipulation method
It is intended to, as shown in Fig. 2 when being locked to the first headquarters plus relation, from the first group to the interdependent pass of the first headquarters
System can not change, i.e. the first group and the two objects of the first headquarters can not change, it is impossible to delete, but can be with newly-built point
Branch.In fig. 2, represent to lock the relation of the first group and the addition of the first headquarters with dashed rectangle.
Said structure lock is keeping object and its dependence of branch and the lock of content.Said structure lock can include knot
Structure writes lock and structure read lock, and when adding structure to write lock one object, adding structure to write the content of the object of lock can be changed, but
Adding structure to write the dependence of all objects on the object and its branch of lock can not be changed and be read, and add structure to write the object of lock
The content of all objects can not be changed and read in the branch of place.When adding structure read lock to an object, add structure read lock
Object cannot be changed with object relationship and content all in its branch in itself, but can be read.
Fig. 3 is the schematic diagram of Structural lock one embodiment in the application data manipulation method, as shown in figure 3, when to first
When headquarters add Structural lock, it is meant that the dependence of the first headquarters, the first division department and the second division department and interior
Rong Jun is lockable.In Fig. 3, chain-dotted line square frame represents that structure writes lock.
Step 103, data manipulation is carried out to above-mentioned object to be operated according to above-mentioned data operation request.
In a kind of implementation of the present embodiment, above-mentioned data operation request can be read operation request, and said structure is locked
Including structure read lock;So step 102 can be:After the parent object addition relation lock of operation object is treated in application, application pair
Above-mentioned object addition structure read lock to be operated;Step 103 can be:The object to be operated is entered according to above-mentioned read operation request
Row data read operation.
In another implementation of the present embodiment, above-mentioned data operation request can be write operation requests, said structure
Lock includes structure and writes lock;So, step 102 can be:After the parent object addition relation lock of operation object is treated in application, application
Lock is write to above-mentioned object addition structure to be operated;Step 103 can be:According to above-mentioned write operation requests to above-mentioned object to be operated
Carry out data write operation.
In the present embodiment, above-mentioned relation lock between, relation lock structure read lock between and structure read lock between be to weigh
Enter;It is above-mentioned to reentry including carrying out repeating locking to identical object;And/or include in the range of reentrant lock identical
Object.
Fig. 4 is relation lock and the schematic diagram of relation one embodiment of Structural lock, such as Fig. 4 in the application data manipulation method
Shown, the first headquarters can apply for that addition relation is locked, and such first group and the first headquarters add relation lock, so
Afterwards if necessary to carry out reading data manipulation to the first headquarters, then need to first group's addition relation lock, to the first cause
Our department adds structure read lock, and the first division department and the second division department where such first headquarters in branch are added structure
Read lock.Figure 4, it is seen that added two relations to lock in the first group, added one relation lock in the first headquarters and
One structure read lock, this just illustrates, reentrant lock, can be to identical object locking.In Fig. 4, dashed rectangle represents relation
Lock, chain-dotted line square frame represent that structure writes lock, and double dot dash line square frame represents structure read lock, similarly hereinafter, repeated no more.
Fig. 5 is the schematic diagram for being related to another embodiment of relation lock and Structural lock in the application data manipulation method, such as
Shown in Fig. 5, it is necessary to which first to file is added to the first group and the first headquarters when carrying out data read operation to the first division department
Relation is locked, and then applies adding structure read lock to the first division department;Next, if necessary to carry out data to the first headquarters
Read operation is, it is necessary to then first to file adds structure read lock, the first thing to first group's addition relation lock to the first headquarters
After industry our department adds structure read lock, the first division department of branch and the second division department also add structure where the first headquarters
Read lock.Locked from fig. 5, it can be seen that with the addition of two relations on this object of the first group, on this object of the first headquarters
Relation lock and one be with the addition of structure read lock, with the addition of two structure read locks on this object of the first division department, this just says
It is bright, reentrant lock, identical object can be contained in the range of lock.
In the present embodiment, structure write lock and relation lock between, structure write lock and structure read lock and structure write lock between be
Mutual exclusion;Wherein, the lock of mutual exclusion can not lock same object;And/or identical pair can not be included in the range of the lock of mutual exclusion
As.
Fig. 6 is the schematic diagram of the relation further embodiment of relation lock and Structural lock in the application data manipulation method, such as
Shown in Fig. 6, the first headquarters can apply for that addition relation is locked, and such first group and the first headquarters add relation
Lock, then if necessary to carry out data writing operation to the first headquarters, then need to first group's addition relation lock, to first
Headquarters' addition structure writes lock, but because the first headquarters have been added relation lock, and structure is write lock and locked with relation
Mutual exclusion, the lock of mutual exclusion can not lock same object simultaneously, therefore the first headquarters addition structure writes lock failure.
Fig. 7 is the schematic diagram of the relation further embodiment of relation lock and Structural lock in the application data manipulation method, such as
Shown in Fig. 7, it is necessary to which first to file is added to the first group and the first headquarters when carrying out data write operation to the first division department
Relation is locked, and then applies writing lock to the first division department addition structure;Next, if necessary to carry out data to the first headquarters
Read operation is, it is necessary to then first to file adds structure read lock, the first thing to first group's addition relation lock to the first headquarters
After industry our department adds structure read lock, the first division department of branch and the second division department are also required in addition where the first headquarters
Structure read lock.From figure 7 it can be seen that due to the first division department, added structure writes lock, and structure writes lock and structure read lock mutual exclusion,
And the lock of mutual exclusion, identical object, therefore the addition structure read lock failure of the first division department can not be contained in the range of lock.
It is now assumed that there was only three business in system:Statistics first group number, second headquarters' number of statistics, first
Division department increases new employee, and the relation of the relation lock and Structural lock that are described by the application Fig. 4~embodiment illustrated in fig. 7 can be seen
Go out, while first group's number is counted, can carry out counting the operation of second headquarters' number, and in the collection of statistics first
While group's number, it is impossible to increase the operation of the first division department new employee, as shown in Fig. 8 (a) and Fig. 8 (b), Fig. 8 (a)~
Fig. 8 (b) operates the schematic diagram of one embodiment for the Data Concurrent in the application data manipulation method.
As shown in Fig. 8 (a), statistics first group number is to carry out data read operation to this object of the first group, because
All objects in this first group and its included branch are all added structure read lock, and count second headquarters' number
Operation is to carry out data read operation to this object of the second headquarters, it is necessary to first group's addition relation lock, to second
Headquarters add structure read lock, and at this moment, the division department of object the 3rd that branch where the second headquarters is included is also required to add
Add structure read lock, because the first group, the second headquarters and the 3rd division department have been added structure read lock, and relation lock and
It is reentrant relation between structure read lock, between structure read lock, therefore, to first group's addition relation lock, to the second thing
Industry our department and the 3rd division department addition structure read lock can add success, and this just illustrates, while first group's number is counted,
The operation of second headquarters' number can be carried out counting.
As shown in Fig. 8 (b), statistics first group number is to carry out data read operation to this object of the first group, because
All objects in this first group and its included branch are all added structure read lock, and increase the first division department new employee's
Operation is to carry out data write operation to this object of the first division department, it is necessary to be closed to the first headquarters and first group's addition
System's lock, lock is write to the first division department addition structure, because the first division department has been added structure read lock, and structure read lock and knot
Structure write lock between be mutual exclusion relation, therefore the first division department addition structure write lock failure, this just illustrates, statistics the first group
While number, it is impossible to increase the operation of the first division department new employee.
Above-mentioned data manipulation method can solve same object concurrent reading and writing operation, different objects concurrent read operation,
The concurrent reading and writing of the concurrent write of different objects and a part of different objects operates.But under same branches, parent object is read, son
The situation that object is write can not solve.That is, subobject writes lock plus structure, but parent object can still add structure
Read lock, or parent object have been tagged with structure read lock, and subobject can still add the contradiction that structure writes the concurrent operations of lock
Can not solve.
The specific solution method of the above situation is described below.
Fig. 9 is the flow chart of the application data manipulation method another embodiment, the application in embodiment illustrated in fig. 1,
After the parent object addition relation lock of operation object is treated in application, apply to the specific of above-mentioned object addition structure read lock to be operated
Embodiment is introduced, as shown in figure 9, can include:
Step 901, the parent object addition relation lock of operation object is treated in application.
In the present embodiment, the parent object addition relation lock that operation object is treated in application can be:Application is to above-mentioned to be operated
Every one-level parent object addition structure read lock of branch where object.
Specifically, relation lock is made up of a series of relation read lock of objects, and as shown in Figure 10, Figure 10 is the application number
The schematic diagram for locking one embodiment according to relation is added in operating method, in the relation lock of the d under applying for c branches, according to successively
Order is, it is necessary to apply adding structure read lock to a successively, to a/c addition structure read locks, to a/c/d addition structure read locks.And releasing
It is inverted order to put when relation is locked, that is, the order when order and addition relation when discharging relation lock are locked is completely opposite.
Step 902, judge above-mentioned object to be operated writes whether counting is the first numerical value;If it is, perform step
903;If the counting of writing of above-mentioned object to be operated is not the first numerical value, step 904 is performed.
Wherein, the size of the first numerical value according to systematic function and/or can realize that demand etc. is voluntarily set in specific implementation
Fixed, the present embodiment is not construed as limiting to the size of above-mentioned first numerical value, and the present embodiment illustrates so that the first numerical value is " 0 " as an example.
Step 903, apply to above-mentioned object addition structure read lock to be operated, and the reading of above-mentioned object to be operated is counted and added
Upper second value.
Wherein, the size of second value according to systematic function and/or can realize that demand etc. is voluntarily set in specific implementation
Fixed, the present embodiment is not construed as limiting to the size of above-mentioned second value, and the present embodiment illustrates so that second value is " 1 " as an example.
Figure 11 is to read to count the schematic diagram of one embodiment in the application data manipulation method, as shown in figure 11, it is necessary to right
Object e carries out data read operation, first to object a and object c addition relation locks, then judges whether write counting on object e
For " 0 ", Tu11Zhong, writing for object e is counted as " 0 ", therefore adds structure read lock to object e, is then counted object e reading and is added
" 1 ", so, object e reading, which counts, is changed into " 1 ", and it is still " 0 ", i.e. (r1, w0) to write counting.Similarly, it is necessary to enter line number to object f
According to read operation, first to object a addition relation locks, whether be " 0 ", Tu11Zhong, object f if then judging that writing on object f counts
Write and be counted as " 0 ", therefore structure read lock is added to object f, then counted object f reading plus " 1 ", so, object f reading
Counting is changed into " 1 ", and it is still " 0 ", i.e. (r1, w0) to write counting.
Step 904, application structure read lock is waited on above-mentioned object to be operated.
In addition, in the present embodiment, after being completed to the data write operation of above-mentioned object to be operated, release is above-mentioned to be waited to grasp
The structure for making to add on object writes lock, then needs every one-level parent object where above-mentioned object to be operated in branch writing meter
Number subtracts second value, and judgement is subtracted after second value, if the parent object write and be counted as the first numerical value be present, if deposited
Then wake-up waiting is writing the operation for the application structure read lock being counted as on the parent object of the first numerical value.
Figure 12 is the schematic diagram that application structure read lock one embodiment is waited in the application data manipulation method, such as Figure 12 institutes
To show, the structure applied to object e writes lock, at this moment, added relation lock on object a and object c, and object a and right
It is " 0 " as c reading counts, it is " 1 " to write counting.At this moment, it is necessary to carry out data read operation to object c, first to file is to right
As a addition relation locks, then judge that object c's writes whether counting is " 0 ", Tu12Zhong, writing for object c is counted as " 1 ", therefore is needed
Application structure read lock is waited on object c, that is to say, that, it is necessary to wait the counting of writing on object c to be changed into " 0 ", then wake up
The operation of the application structure read lock stayed on object c.Specifically, after being completed to object e data write operation, object e
On structure write lock release, then need the counting of writing by parent object a and c in branch where object e to subtract " 1 ", Tu12Zhong, write
After counting subtracts " 1 ", the counting of writing on object c is changed into " 0 ", waits the operation of the application structure read lock stayed on object c to be called out
Wake up.
Figure 13 is the flow chart of the application data manipulation method further embodiment, the application in embodiment illustrated in fig. 1,
After the parent object addition relation lock of operation object is treated in application, apply writing the specific of lock to above-mentioned object addition structure to be operated
Embodiment is introduced, and as shown in figure 13, can include:
Step 1301, the is counted as in every one-level parent object of branch where judging above-mentioned object to be operated with the presence or absence of reading
The parent object of one numerical value.
Read to be counted as the first numerical value if it is, in every one-level parent object of branch where i.e. above-mentioned object to be operated existing
Parent object, then perform step 1302;Meter is read if not, existing in every one-level parent object of branch where i.e. above-mentioned object to be operated
Number is not the parent object of the first numerical value, then performs step 1304.
Wherein, the size of the first numerical value according to systematic function and/or can realize that demand etc. is voluntarily set in specific implementation
Fixed, the present embodiment is not construed as limiting to the size of above-mentioned first numerical value, and the present embodiment illustrates so that the first numerical value is " 0 " as an example.
Step 1302, apply for being counted as reading the parent object addition relation lock of the first numerical value, and the father that the relation of addition is locked
The counting of writing of object adds second value.
Wherein, the size of second value according to systematic function and/or can realize that demand etc. is voluntarily set in specific implementation
Fixed, the present embodiment is not construed as limiting to the size of above-mentioned second value, and the present embodiment illustrates so that second value is " 1 " as an example.
Step 1303, after every one-level parent object of branch where above-mentioned object to be operated adds above-mentioned relation lock,
Application writes lock to above-mentioned object addition structure to be operated.
Figure 14 is that the schematic diagram for counting one embodiment is write in the application data manipulation method, as shown in figure 14, it is necessary to right
Object e carries out data write operation, at this moment firstly the need of judging whether object a and object c reading counting is " 0 ", the present embodiment
In, it is " 0 " that object a and object c reading, which count, at this moment, can be to object a and object c addition relation locks, then by object a
Counting of writing with object c adds " 1 ", and at this moment object a reading is counted as " 0 ", writes and be counted as " 1 ";Object c reading is counted as " 0 ", writes
" 1 " is counted as, i.e. (r0, w1).Similarly, it is necessary to carry out data write operation to object f, it is necessary to first judge that object a reading counts
Whether it is " 0 ", in the present embodiment, object a reading is counted as " 0 ", at this moment, relation lock can be added to object a, then by object
A's writes counting plus " 1 ", and at this moment object a reading is counted as " 0 ", and " 2 " will be changed into by writing counting, i.e. (r0, w2).
Step 1304, it is not that application relation lock is waited on the parent object of the first numerical value reading to count.
In addition, in the present embodiment, after being completed to the data read operation of above-mentioned object to be operated, release is above-mentioned to be waited to grasp
Make the structure read lock added on object, then the reading of above-mentioned object to be operated can be counted and subtract second value, if subtracted
After second value, the reading of above-mentioned object to be operated is counted as the first numerical value, then wake-up waiting is being read to be counted as the first numerical value
The operation of application relation lock on object.
Figure 15 is the schematic diagram for waiting application relation to lock one embodiment in the application data manipulation method, such as Figure 15 institutes
Show, applied for the structure read lock to object c, at this moment, on object a add relation lock, structure read lock is added on object c, and
Object a reading is counted as " 0 ", writes and is counted as " 0 ", and object c reading is counted as " 1 ", writes and is counted as " 0 ".At this moment, it is necessary to object
E carries out data write operation, and whether be " 0 ", object a reading is counted as " 0 ", to right if first judging that object a and object c reading counts
As a addition relation locks, object a is then write into counting plus " 1 ", at this moment object a reading is counted as " 0 ", writes counting and be changed into " 1 ",
That is (r0, w1).Because object c reading is counted as " 1 ", it is therefore desirable to application relation lock is waited on object c, that is to say, that need
Wait the reading on object c to count to be changed into " 0 ", then the operation of application relation lock of the wake-up waiting on object c.Specifically, exist
After object c data read operation completion, the structure read lock release on object c, then need to subtract object c reading counting
" 1 ", Tu15Zhong, after reading counting subtracts " 1 ", the reading on object c, which counts, is changed into " 0 ", waits what the application relation stayed on object c was locked
Operation will be waken up.
The scheme described by the application Fig. 9~embodiment illustrated in fig. 15, it can be seen that can not possibly exist on an object
Read-write counts simultaneously the situation for 0.But in the environment of actual high concurrent, it is possible to such case occur, reason
It is, the read-write for existing while changing same target counts in a flash.
When treating operation object progress data write operation, first judge to read to count, rewrite counting afterwards, and treating behaviour
When making object progress data read operation, first judge to write counting, change reading afterwards and count, so, in the environment of actual high concurrent,
All it is 0 in the presence of read-write counting in a flash, judges all by the way that read-write counts while adds one situation.
In order to solve this problem, the application introduces count synchronization lock, and the judgement on object is counted and modification counts
Operation lock.Specifically, each object after modification counts, is released, it is necessary to plus count synchronization lock before judging to count
Count synchronization lock is put, this is equivalent to pin two counting operations, solves the concurrent problem that read-write counts.
In a kind of implementation of count synchronization lock, before judgement counting operation is carried out, to carrying out judging to count behaviour
The object addition count synchronization lock of work, then after the object to adding above-mentioned count synchronization lock carries out counting modification operation,
Discharge above-mentioned count synchronization lock.
This is the fairness scheme in count synchronization lock, and specifically, as shown in figure 16, Figure 16 is the application data manipulation method
The middle schematic diagram for counting synchrolock fairness scheme one embodiment, in fairness scheme, structure read lock x has been arrived in object c applications, this
When object a on add relation lock, the reading on object a is counted as " 0 ", writes and is counted as " 0 ", be i.e. (r0, w0);Reading meter on object c
Number is " 1 ", writes and is counted as " 0 ", be i.e. (r1, w0).
Then, object e applies for that structure writes lock y, and now y can hold count synchronization lock, then judge object a's and object c
Whether be " 0 ", object a reading is counted as " 0 " if reading to count, to object a addition relation locks, and object a is write into counting plus " 1 ",
Reading so on object a, which counts and writes counting, to be changed into (r0, w1).Because object c reading is counted as " 1 ", therefore apply for that structure is write
Y operation etc. is locked to stay on object c, it is necessary to which waiting object c reading to count is changed into " 0 ", at this moment, if rethinking application object c's
Structure read lock z, then it can wait staying in count synchronization and lock.After x discharges, object c reading, which counts, subtracts " 1 ", the at this moment reading on object c
Counting is changed into " 0 ", and waiting the application structure stayed on object c to write lock y operation can be waken up, and object c is added relation lock, and
Object c's writes counting plus " 1 ", and object c reading, which counts and writes counting, to be changed into (r0, w1), and object e applications structure writes lock y successes.
After changing the counting on object c, the count synchronization lock release on object c, structure read lock z is after synchronous counting lock is obtained, meeting
Etc. staying on object c, that is, the counting of writing on object c is waited to be changed into after " 0 ", application structure read lock z operation can be waken up.
In another implementation of count synchronization lock, before judgement counting operation is carried out, to carrying out judgement counting
The object addition count synchronization lock of operation, if the Shen of the relation lock or Structural lock on the object for adding above-mentioned count synchronization lock
Please operate needs to wait, then discharges above-mentioned count synchronization lock, after the application operation of above-mentioned relation lock or Structural lock is waken up,
Apply for above-mentioned count synchronization lock again again;If the Shen of the relation lock or Structural lock on the object for adding above-mentioned count synchronization lock
It please operate and without waiting for, then after the object to adding above-mentioned count synchronization lock carries out counting modification operation, release is above-mentioned
Count synchronization is locked.
This is the non-fairness scheme of count synchronization lock, and specifically, as shown in figure 17, Figure 17 is the application data manipulation method
The middle schematic diagram for counting the non-fairness scheme one embodiment of synchrolock, in non-fairness scheme, structure read lock has been arrived in object c applications
X, relation is at this moment added on object a and is locked, the reading on object a is counted as " 0 ", writes and is counted as " 0 ", be i.e. (r0, w0);On object c
Reading is counted as " 1 ", writes and is counted as " 0 ", i.e. (r1, w0).
Then object e applies for that structure writes lock y, and now y can hold count synchronization lock, then judge object a and object c reading
Whether counting is " 0 ", and object a reading is counted as " 0 ", to object a addition relation locks, and object a is write into counting plus " 1 ", this
Reading on sample object a, which counts and writes counting, to be changed into (r0, w1).Because object c reading is counted as " 1 ", therefore apply for that structure writes lock y
Operation etc. stay on object c, it is necessary to which waiting object c reading to count is changed into " 0 ", now structure, which writes lock y, can discharge count synchronization
Lock;If rethinking application object c structure read lock z, structure read lock z can obtain count synchronization lock, and object a is added into relation
Lock, judge on object c writing counting whether be " 0 ", writing for object c is counted as " 0 ", thus object c add structure read lock z into
Work(, the reading on object c is counted and adds " 1 ", at this moment, the reading on object c, which counts and writes counting, to be changed into (r2, w0).So application knot
The operation that structure writes lock y needs to wait x and z to obtain count synchronization lock after all discharging, and as shown in figure 17, will not be repeated here.
Figure 18 is the structural representation of the application data operation device one embodiment, the data manipulation dress in the present embodiment
Put the data manipulation method that can realize that the embodiment of the present application provides.As shown in figure 18, above-mentioned data operation device can include:
Receiving module 1801, application module 1802 and data operation modules 1803;
Wherein, receiving module 1801, for receiving data operation request;
Apply for module 1802, after the parent object addition relation lock for applying for treating operation object, apply treating to described
Operation object adds Structural lock;Wherein, above-mentioned relation lock is adding relation to lock an object to keep the lock of dependent objects relation
Afterwards, it can not change from root object to the dependence for locking object, relation is added to the first headquarters as shown in Fig. 2 working as
During lock, can not change from the first group to the dependence of the first headquarters, i.e., the first group and the first headquarters this two
Individual object can not be changed, it is impossible to deletes, but can be with newly-built branch.
Said structure lock is keeping object and its dependence of branch and the lock of content.Said structure lock can include knot
Structure writes lock and structure read lock, and when adding structure to write lock one object, adding structure to write the content of the object of lock can be changed, but
Adding structure to write the dependence of all objects on the object and its branch of lock can not be changed and be read, and add structure to write the object of lock
The content of all objects can not be changed and read in the branch of place.When adding structure read lock to an object, add structure read lock
Object cannot be changed with object relationship and content all in its branch in itself, but can be read.
As shown in figure 3, when adding Structural lock to the first headquarters, it is meant that the first headquarters, the first division department
It is lockable with the dependence and content of the second division department.
In the present embodiment, apply for module 1802, specifically for applying for every one-level to branch where above-mentioned object to be operated
Parent object adds structure read lock.Specifically, relation lock is made up of a series of relation read lock of objects, as shown in Figure 10,
When applying for d relation lock, according to sequencing, it is necessary to apply adding structure read lock to a successively, structure read lock is added to a/c, it is right
A/c/d adds structure read lock.And be inverted order in the relation of release lock, that is, when order when discharging relation lock is with adding relation lock
Order is completely opposite.
Data operation modules 1803, for according to the data operation request that receiving module 1801 receives to above-mentioned to be operated right
As carrying out data manipulation.
In a kind of implementation of the present embodiment, above-mentioned data operation request can be read operation request, and said structure is locked
Including structure read lock;So, module 1802 is applied for, the parent object addition relation that operation object is treated specifically for application locks it
Afterwards, apply to above-mentioned object addition structure read lock to be operated;Data operation modules 1803, specifically for being asked according to above-mentioned read operation
Ask and data read operation is carried out to above-mentioned object to be operated.
In another implementation of the present embodiment, above-mentioned data operation request can be write operation requests, said structure
Lock includes structure and writes lock;So, module 1802 is applied for, the parent object addition relation that operation object is treated specifically for application locks it
Afterwards, apply writing lock to above-mentioned object addition structure to be operated;Data operation modules 1803, specifically for being asked according to above-mentioned write operation
Ask and data write operation is carried out to above-mentioned object to be operated.
In the present embodiment, above-mentioned relation lock between, relation lock structure read lock between and structure read lock between be to weigh
Enter;It is above-mentioned to reentry including carrying out repeating locking to identical object;And/or include in the range of reentrant lock identical
Object.
As shown in figure 4, the first headquarters can apply for that addition relation is locked, such first group and the first headquarters are equal
Addition relation is locked, and then if necessary to carry out reading data manipulation to the first headquarters, then needs to add relation to the first group
Lock, the first headquarters are added with structure read lock, the first division department in branch and the second cause where such first headquarters
Portion is added structure read lock.Figure 4, it is seen that having added two relations to lock in the first group, add in the first headquarters
One relation lock and one structure read lock, this just illustrates, reentrant lock, can be to identical object locking.
As shown in figure 5, it is necessary to which first to file is to the first group and the first thing when carrying out data read operation to the first division department
Industry our department addition relation lock, then applies adding structure read lock to the first division department;Next, if necessary to the first cause sheet
Portion carries out data read operation, it is necessary to then first to file adds structure to first group's addition relation lock to the first headquarters
Read lock, after the first headquarters add structure read lock, the first division department and the second division department of branch where the first headquarters
Also upper structure read lock is added.Locked from fig. 5, it can be seen that with the addition of two relations on this object of the first group, the first cause sheet
Relation lock and one is with the addition of on this object of portion structure read lock, two structures are with the addition of on this object of the first division department
Read lock, this just illustrates, reentrant lock, and identical object can be contained in the range of lock.
In the present embodiment, structure write lock and relation lock between, structure write lock and structure read lock and structure write lock between be
Mutual exclusion;Wherein, the lock of mutual exclusion can not lock same object;And/or identical pair can not be included in the range of the lock of mutual exclusion
As.
As shown in fig. 6, the first headquarters can apply for that addition relation is locked, such first group and the first headquarters are equal
Addition relation is locked, and then if necessary to carry out data writing operation to the first headquarters, then needs to add relation to the first group
Lock, lock is write to the first headquarters addition structure, but because the first headquarters have been added relation lock, and structure writes lock
Mutual exclusion is locked with relation, the lock of mutual exclusion can not lock same object simultaneously, therefore the first headquarters addition structure writes lock failure.
As shown in fig. 7, it is necessary to which first to file is to the first group and the first thing when carrying out data write operation to the first division department
Industry our department addition relation lock, then apply writing lock to the first division department addition structure;Next, if necessary to the first cause sheet
Portion carries out data read operation, it is necessary to then first to file adds structure to first group's addition relation lock to the first headquarters
Read lock, after the first headquarters add structure read lock, the first division department and the second division department of branch where the first headquarters
It is also required to add structure read lock.From figure 7 it can be seen that due to the first division department, added structure writes lock, structure write lock and
Structure read lock mutual exclusion, and the lock of mutual exclusion, identical object can not be contained in the range of lock, therefore the first division department addition structure is read
Lock failure.
It is now assumed that there was only three business in system:Statistics first group number, second headquarters' number of statistics, first
Division department increases new employee, and the relation of the relation lock and Structural lock that are described by the application Fig. 4~embodiment illustrated in fig. 7 can be seen
Go out, while first group's number is counted, can carry out counting the operation of second headquarters' number, and in the collection of statistics first
While group's number, it is impossible to increase the operation of the first division department new employee.
As shown in Fig. 8 (a), statistics first group number is to carry out data read operation to this object of the first group, because
All objects in this first group and its included branch are all added structure read lock, and count second headquarters' number
Operation is to carry out data read operation to this object of the second headquarters, it is necessary to first group's addition relation lock, to second
Headquarters add structure read lock, and at this moment, the division department of object the 3rd that branch where the second headquarters is included is also required to add
Add structure read lock, because the first group, the second headquarters and the 3rd division department have been added structure read lock, and relation lock and
It is reentrant relation between structure read lock, between structure read lock, therefore, to first group's addition relation lock, to the second thing
Industry our department and the 3rd division department addition structure read lock can add success, and this just illustrates, while first group's number is counted,
The operation of second headquarters' number can be carried out counting.
As shown in Fig. 8 (b), statistics first group number is to carry out data read operation to this object of the first group, because
All objects in this first group and its included branch are all added structure read lock, and increase the first division department new employee's
Operation is to carry out data write operation to this object of the first division department, it is necessary to be closed to the first headquarters and first group's addition
System's lock, lock is write to the first division department addition structure, because the first division department has been added structure read lock, and structure read lock and knot
Structure write lock between be mutual exclusion relation, therefore the first division department addition structure write lock failure, this just illustrates, statistics the first group
While number, it is impossible to increase the operation of the first division department new employee.
Above-mentioned data operation device can solve same object concurrent reading and writing operation, different objects concurrent read operation,
The concurrent reading and writing of the concurrent write of different objects and a part of different objects operates.But under same branches, parent object is read, son
The situation that object is write can not solve.That is, subobject writes lock plus structure, but parent object can still add structure
Read lock, or parent object have been tagged with structure read lock, and subobject can still add the contradiction that structure writes the concurrent operations of lock
Can not solve.
Figure 19 is the structural representation of another embodiment of the application data operation device, with the data manipulation shown in Figure 18
Device is compared, and difference is, in the data operation device shown in Figure 19, application module 1802 can include:Application addition
Submodule 18021, count judging submodule 18022 and counting operation submodule 18023;
Wherein, application addition submodule 18021, for applying for treating the parent object addition relation lock of operation object;This reality
Apply in example, application addition submodule 18021 applies for that the parent object addition relation lock for treating operation object can be:Application is to above-mentioned
Every one-level parent object addition structure read lock of branch where object to be operated.
Specifically, relation lock is made up of a series of relation read lock of objects, as shown in Figure 10, in application d relation
During lock, according to sequencing, it is necessary to apply adding structure read lock to a successively, structure read lock is added to a/c, a/c/d is added and tied
Structure read lock.And be inverted order in the relation of release lock, that is, discharge the complete phase of order when the order and addition relation lock when relation is locked
Instead.
Count judging submodule 18022, for judge above-mentioned object to be operated write counting whether be the first numerical value;Its
In, the size of the first numerical value according to systematic function and/or can realize the sets itselfs such as demand, this implementation in specific implementation
Example is not construed as limiting to the size of above-mentioned first numerical value, and the present embodiment illustrates so that the first numerical value is " 0 " as an example.
Application addition submodule 18021, it is additionally operable to when counting judging submodule 18022 determines writing for above-mentioned object to be operated
When being counted as the first numerical value, apply to above-mentioned object addition structure read lock to be operated;
Counting operation submodule 18023, second value is added for the reading of above-mentioned object to be operated to be counted.Wherein,
The size of two numerical value according to systematic function and/or can realize the sets itselfs such as demand, the present embodiment is to upper in specific implementation
The size for stating second value is not construed as limiting, and the present embodiment illustrates so that second value is " 1 " as an example.
As shown in figure 11, it is necessary to carry out data read operation to object e, application addition submodule 18021 first to object a and
Object c addition relation locks, then count judging submodule 18022 and judge to write whether counting is " 0 " on object e, Tu11Zhong is right
As writing for e is counted as " 0 ", therefore apply for that addition submodule 18021 adds structure read lock to object e, then counting operation submodule
Block 18023, which counts object e reading, adds " 1 ", and so, object e reading, which counts, is changed into " 1 ", and it is still " 0 " to write counting, i.e., (r1,
w0).Similarly, it is necessary to carry out data read operation to object f, application addition submodule 18021 is first locked to object a addition relations,
Whether be " 0 ", Tu11Zhong, writing for object f is counted as if judging submodule 18022 is then counted to judge that writing on object f counts
" 0 ", therefore apply for that addition submodule 18021 adds structure read lock to object f, then counting operation submodule 18023 is by object f
Reading count plus " 1 ", so, object f reading, which counts, is changed into " 1 ", and it is still " 0 ", i.e. (r1, w0) to write counting.
Further, above-mentioned application module 1802 can also include:
Application waits submodule 18024, by when counting based on judging submodule 18022 determines the writing of above-mentioned object to be operated
When number is not the first numerical value, application structure read lock is waited on above-mentioned object to be operated.
In addition, above-mentioned data operation device can also include:Release module 1804;
Release module 1804, for after being completed to the data write operation of above-mentioned object to be operated, discharging above-mentioned treat
The structure added in operation object writes lock;
At this moment, counting operation submodule 18023, it is additionally operable to every one-level father couple where above-mentioned object to be operated in branch
The counting of writing of elephant subtracts second value;
Judging submodule 18022 is counted, is additionally operable to after judgement subtracts second value, if exists to write and is counted as the first number
The parent object of value;
Application module 1802 can also include:Application wakes up submodule 18025;
Application wakes up submodule 18025, for after counting judging submodule 18022 determines to subtract second value, depositing
When writing the parent object for being counted as the first numerical value, wake-up waiting is read writing the application structure that is counted as on the parent object of the first numerical value
The operation of lock.
As shown in figure 12, the structure applied to object e writes lock, at this moment, added relation on object a and object c
Lock, and it is " 0 " that object a and object c reading, which count, and it is " 1 " to write counting.At this moment, it is necessary to carry out digital independent to object c
Operation, apply for that the addition first to file of submodule 18021 to object a addition relation locks, then counts the judgement pair of judging submodule 18022
Write whether counting is " 0 " as c, Tu12Zhong, writing for object c is counted as " 1 ", therefore applies waiting submodule 18024 to need
Application structure read lock is waited on object c, that is to say, that application waits submodule 18024 to need to wait the counting of writing on object c to become
For " 0 ", then the operation of the application structure read lock by the application wake-up wake-up waiting of submodule 18025 on object c.Specifically, exist
After object e data write operation completion, the structure on object e writes lock release, and then counting operation submodule 18023 needs
The counting of writing of parent object a and c in branch where object e are subtracted " 1 ", Tu12Zhong, write after counting subtracts " 1 ", on object c
Write counting and be changed into " 0 ", wait the operation of the application structure read lock stayed on object c to be applied wake-up submodule 18025 and wake up.
In another implementation of the present embodiment, application module 1802 can include:Application addition submodule 18021,
Count judging submodule 18022 and counting operation submodule 18023;
Wherein, judging submodule 18022 is counted, every one-level parent object for branch where judging above-mentioned object to be operated
In with the presence or absence of reading to be counted as the parent object of the first numerical value;Wherein, the size of the first numerical value can be in specific implementation, according to being
System and/or realizes the sets itselfs such as demand at performance, and the present embodiment is not construed as limiting to the size of above-mentioned first numerical value, the present embodiment with
First numerical value be " 0 " exemplified by illustrate.
Application addition submodule 18021, for where determining above-mentioned object to be operated when counting judging submodule 18022 points
When in every one-level parent object of branch in the presence of reading to be counted as the parent object of the first numerical value, apply for being counted as reading the father couple of the first numerical value
As addition relation lock;And after every one-level parent object of branch where above-mentioned object to be operated adds above-mentioned relation lock,
Application writes lock to above-mentioned object addition structure to be operated;
Counting operation submodule 18023, the counting of writing of the parent object for addition relation to be locked add second value.Its
In, the size of second value according to systematic function and/or can realize the sets itselfs such as demand, this implementation in specific implementation
Example is not construed as limiting to the size of above-mentioned second value, and the present embodiment illustrates so that second value is " 1 " as an example.
As shown in figure 14, it is necessary to carry out data write operation to object e, at this moment count judging submodule 18022 needs first
Whether be " 0 ", in the present embodiment, it is " 0 " that object a and object c reading, which count, if judging that object a and object c reading counts, this
When, application addition submodule 18021 can be to object a and object c addition relation locks, and then counting operation submodule 18023 will
Object a's and object c writes counting plus " 1 ", and at this moment object a reading is counted as " 0 ", writes and be counted as " 1 ";Object c reading is counted as
" 0 ", write and be counted as " 1 ", be i.e. (r0, w1).Similarly, it is necessary to carry out data write operation to object f, judging submodule is counted
Whether 18022 to need first to judge that object a reading counts be " 0 ", and in the present embodiment, object a reading is counted as " 0 ", at this moment, application
Relation lock can be added to object a by adding submodule 18021, and then counting operation submodule 18023 adds object a counting of writing
" 1 ", at this moment object a reading are counted as " 0 ", and " 2 " will be changed into by writing counting, i.e. (r0, w2).
Further, above-mentioned application module 1802 can also include:
Application waits submodule 18024, for where determining above-mentioned object to be operated when counting judging submodule 18022 points
Exist in every one-level parent object of branch and read to count when not being the parent object of the first numerical value, reading the father couple that counting is not the first numerical value
As upper wait application relation lock.
In addition, above-mentioned data operation device can also include:Release module 1804;
Release module 1804, for after being completed to the data read operation of above-mentioned object to be operated, discharging above-mentioned treat
The structure read lock added in operation object;
Counting operation submodule 18023, it is additionally operable to the reading counting of above-mentioned object to be operated subtracting second value;
Above-mentioned application module 1802 can also include:
Application wakes up submodule 18025, and for after second value is subtracted, the reading of above-mentioned object to be operated is counted as the
During one numerical value, operation of the wake-up waiting in the application relation lock for reading to be counted as on the object of the first numerical value.
As shown in figure 15, the structure read lock to object c has been applied for, at this moment, on object a has added relation lock, add on object c
Add structure read lock, and object a reading is counted as " 0 ", writes and is counted as " 0 ", and object c reading is counted as " 1 ", writes and is counted as " 0 ".
At this moment, it is necessary to carry out data write operation to object e, the reading meter that judging submodule 18022 first judges object a and object c is counted
Whether number is " 0 ", and object a reading is counted as " 0 ", then application addition submodule 18021 counts to object a addition relation locks
Operation submodule writes counting plus " 1 " by object a's, and at this moment object a reading is counted as " 0 ", writes counting and be changed into " 1 ", i.e., (r0,
w1).Because object c reading is counted as " 1 ", therefore apply waiting submodule 18024 to need to wait application relation on object c
Lock, that is to say, that application waits submodule 18024 to need to wait the reading counting on object c to be changed into " 0 ", then wakes up son by application
The operation of application relation lock of the wake-up waiting of module 18025 on object c.Specifically, it is complete in the data read operation to object c
Into afterwards, the structure read lock release on object c, then counting operation submodule 18023, which needs to count object c reading, subtracts " 1 ",
In Figure 15, after reading counting subtracts " 1 ", the reading on object c, which counts, is changed into " 0 ", waits the operation of the application relation lock stayed on object c
Wake-up submodule 18025 will be applied to wake up.
Pass through scheme described above, it can be seen that there can not possibly be read-write on an object and count simultaneously the feelings for 0
Condition.But in the environment of actual high concurrent, it is possible to such case occur, reason is, exists while changes same
The read-write of object counts in a flash.
When treating operation object progress data write operation, first judge to read to count by counting judging submodule 18022, it
Counting operation submodule 18023, which is rewritten, afterwards counts, and when treating operation object progress data read operation, first judged by counting
Counting is write in the judgement of submodule 18022, and counting operation submodule 18023 changes reading and counted afterwards, so, in the environment of actual high concurrent
Under, read-write counting in a flash be present all is 0, is judged all by the way that read-write counts while adds one situation.
In order to solve this problem, the application introduces count synchronization lock, and the judgement on object is counted and modification counts
Operation lock.Specifically, each object count judging submodule 18022 judge count before, it is necessary to add count synchronization
Lock, after the modification of counting operation submodule 18023 counts, release count synchronization lock, this is equivalent to two counting operations
Pin, solve the concurrent problem that read-write counts.
In a kind of implementation of count synchronization lock, above-mentioned data operation device can also include:Release module 1804;
Application addition submodule 18021, is additionally operable to before counting judging submodule 18022 and carrying out judgement counting operation,
Object addition count synchronization lock to judge counting operation;
Release module 1804, for being carried out in counting operation submodule 18023 to the object for adding above-mentioned count synchronization lock
After counting modification operation, above-mentioned count synchronization lock is discharged.
This is the fairness scheme in count synchronization lock, and specifically, as shown in figure 16, in fairness scheme, object c applications are arrived
Structure read lock x, at this moment adds relation lock on object a, the reading on object a is counted as " 0 ", writes and is counted as " 0 ", i.e. (r0, w0);
Reading on object c is counted as " 1 ", writes and is counted as " 0 ", i.e. (r1, w0).
Then, object e applies for that structure writes lock y, and now y can hold count synchronization lock, then count judging submodule 18022
Whether be " 0 ", object a reading is counted as " 0 " if judging that object a and object c reading counts, application addition submodule 18021 is to right
As a addition relation locks, object a counting of writing is added " 1 " by counting operation submodule 18023, and the reading on such object a is counted and write
Counting is changed into (r0, w1).Because object c reading is counted as " 1 ", therefore apply for that structure is write lock y operation etc. and stayed on object c,
Application waits submodule 18024 to need to wait object c reading counting to be changed into " 0 ", at this moment, if rethinking application object c structure
Read lock z, then it can wait staying in count synchronization and lock.After x discharges, object c reading, which counts, subtracts " 1 ", and the at this moment reading on object c counts
Be changed into " 0 ", wait the application structure stayed on object c write lock y operation can be applied wake up submodule 18025 wake up, object c quilts
Addition relation is locked, and object c counting of writing adds " 1 ", and object c reading, which counts and writes counting, to be changed into (r0, w1), object e applications
Structure writes lock y successes.After the counting that counting operation submodule 18023 changes on object c, the count synchronization lock on object c
Discharge, for structure read lock z after synchronous counting lock is obtained, application waits meeting of submodule 18024 etc. to stay on object c, that is, waits object c
On counting of writing be changed into after " 0 ", application structure read lock z operation, which can be applied to wake up submodule 18025, to be waken up.
In another implementation of count synchronization lock, above-mentioned data operation device can also include:Release module
1804;
Application addition submodule 18021, is additionally operable to before counting judging submodule 18022 and carrying out judgement counting operation,
Object addition count synchronization lock to judge counting operation;
Release module 1804, for the relation lock on the object for adding above-mentioned count synchronization lock or the application behaviour of Structural lock
When needing to wait, above-mentioned count synchronization lock is discharged;And relation lock or knot on the object for adding above-mentioned count synchronization lock
When the application operation of structure lock withouts waiting for, after the object to adding above-mentioned count synchronization lock carries out counting modification operation,
Discharge above-mentioned count synchronization lock;
Application addition submodule 18021, be additionally operable to above-mentioned relation lock or Structural lock application operation be waken up and then
Again above-mentioned count synchronization lock is applied for.
This is the non-fairness scheme of count synchronization lock, specifically, as shown in figure 17, in non-fairness scheme, object c applications
Structure read lock x have been arrived, relation is at this moment added on object a and is locked, the reading on object a is counted as " 0 ", writes and is counted as " 0 ", i.e., (r0,
w0);Reading on object c is counted as " 1 ", writes and is counted as " 0 ", i.e. (r1, w0).
Then object e applies for that structure writes lock y, and now y can hold count synchronization lock, then count judging submodule 18022
Whether be " 0 ", object a reading is counted as " 0 " if judging that object a and object c reading counts, application addition submodule 18021 is to right
As a addition relation locks, object a counting of writing is added " 1 " by counting operation submodule 18023, and the reading on such object a is counted and write
Counting is changed into (r0, w1).Because object c reading is counted as " 1 ", therefore apply for that structure is write lock y operation etc. and stayed on object c,
Application waits submodule 18024 to need to wait object c reading counting to be changed into " 0 ", and now structure, which writes lock y, can discharge count synchronization
Lock;If rethinking application object c structure read lock z, structure read lock z can obtain count synchronization lock, application addition submodule
18021 by object a addition relation locks, and whether be " 0 ", object c if counting judging submodule 18022 to judge that writing on object c counts
Write and be counted as " 0 ", therefore object c addition structure read lock z successes, counting operation submodule 18023 count the reading on object c
Add " 1 ", at this moment, the reading on object c, which counts and writes counting, to be changed into (r2, w0).So application addition submodule 18021 applies for structure
Writing lock y operation needs to wait x and z to obtain count synchronization lock after all discharging, and as shown in figure 17, will not be repeated here.
Figure 20 is the structural representation of the application computer equipment one embodiment, and above computer equipment can include depositing
Reservoir, processor and it is stored in the computer program that can be run on above-mentioned memory and on above-mentioned processor, above-mentioned processor
When performing above computer program, it is possible to achieve the data manipulation method that the embodiment of the present application provides.
Wherein, above computer equipment can be server, personal computer (Personal Computer;Following letter
Claim:PC), the equipment such as notebook computer, tablet personal computer or smart mobile phone, specific shape of the present embodiment to above computer equipment
State is not construed as limiting.
Figure 20 shows the block diagram suitable for being used for the exemplary computer device 12 for realizing the application embodiment.Figure 20 shows
The computer equipment 12 shown is only an example, should not bring any limit to the function and use range of the embodiment of the present application
System.
As shown in figure 20, computer equipment 12 is showed in the form of universal computing device.The component of computer equipment 12 can
To include but is not limited to:One or more processor or processing unit 16, system storage 28, connect different system component
The bus 18 of (including system storage 28 and processing unit 16).
Bus 18 represents the one or more in a few class bus structures, including memory bus or Memory Controller,
Peripheral bus, graphics acceleration port, processor or the local bus using any bus structures in a variety of bus structures.Lift
For example, these architectures include but is not limited to industry standard architecture (Industry Standard
Architecture;Hereinafter referred to as:ISA) bus, MCA (Micro Channel Architecture;Below
Referred to as:MAC) bus, enhanced isa bus, VESA (Video Electronics Standards
Association;Hereinafter referred to as:VESA) local bus and periphery component interconnection (Peripheral Component
Interconnection;Hereinafter referred to as:PCI) bus.
Computer equipment 12 typically comprises various computing systems computer-readable recording medium.These media can be it is any can be by
The usable medium that computer equipment 12 accesses, including volatibility and non-volatile media, moveable and immovable medium.
System storage 28 can include the computer system readable media of form of volatile memory, such as arbitrary access
Memory (Random Access Memory;Hereinafter referred to as:RAM) 30 and/or cache memory 32.Computer equipment 12
It may further include other removable/nonremovable, volatile/non-volatile computer system storage mediums.Only conduct
Citing, storage system 34 can be used for reading and writing immovable, non-volatile magnetic media, and (Figure 20 do not show, commonly referred to as " hard disk
Driver ").Although not shown in Figure 20, it can provide for may move non-volatile magnetic disk (such as " floppy disk ") read-write
Disc driver, and to removable anonvolatile optical disk (such as:Compact disc read-only memory (Compact Disc Read
Only Memory;Hereinafter referred to as:CD-ROM), digital multi read-only optical disc (Digital Video Disc Read Only
Memory;Hereinafter referred to as:DVD-ROM) or other optical mediums) read-write CD drive.In these cases, each driving
Device can be connected by one or more data media interfaces with bus 18.Memory 28 can include at least one program and produce
Product, the program product have one group of (for example, at least one) program module, and it is each that these program modules are configured to perform the application
The function of embodiment.
Program/utility 40 with one group of (at least one) program module 42, such as memory 28 can be stored in
In, such program module 42 includes --- but being not limited to --- operating system, one or more application program, other programs
Module and routine data, the realization of network environment may be included in each or certain combination in these examples.Program mould
Block 42 generally performs function and/or method in embodiments described herein.
Computer equipment 12 can also be with one or more external equipments 14 (such as keyboard, sensing equipment, display 24
Deng) communication, the equipment communication interacted with the computer equipment 12 can be also enabled a user to one or more, and/or with making
Obtain any equipment that the computer equipment 12 can be communicated with one or more of the other computing device (such as network interface card, modulatedemodulate
Adjust device etc.) communication.This communication can be carried out by input/output (I/O) interface 22.Also, computer equipment 12 may be used also
To pass through network adapter 20 and one or more network (such as LAN (Local Area Network;Hereinafter referred to as:
LAN), wide area network (Wide Area Network;Hereinafter referred to as:WAN) and/or public network, for example, internet) communication.Such as figure
Shown in 20, network adapter 20 is communicated by bus 18 with other modules of computer equipment 12.It should be understood that although in Figure 20
It is not shown, computer equipment 12 can be combined and use other hardware and/or software module, included but is not limited to:Microcode, equipment
Driver, redundant processing unit, external disk drive array, RAID system, tape drive and data backup storage system
Deng.
Processing unit 16 is stored in program in system storage 28 by operation, so as to perform various function application and
Data processing, such as realize the data manipulation method that the embodiment of the present application provides.
The embodiment of the present application also provides a kind of non-transitorycomputer readable storage medium, is stored thereon with computer journey
Sequence, above computer program realize the data manipulation method that the embodiment of the present application provides when being executed by processor.
Above-mentioned non-transitorycomputer readable storage medium can use appointing for one or more computer-readable media
Meaning combination.Computer-readable medium can be computer-readable signal media or computer-readable recording medium.Computer can
Read storage medium and for example may be-but not limited to-the system of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, device
Or device, or any combination above.The more specifically example (non exhaustive list) of computer-readable recording medium includes:
Electrical connection, portable computer diskette, hard disk, random access memory (RAM), read-only storage with one or more wires
Device (Read Only Memory;Hereinafter referred to as:ROM), erasable programmable read only memory (Erasable
Programmable Read Only Memory;Hereinafter referred to as:EPROM) or flash memory, optical fiber, portable compact disc are read-only deposits
Reservoir (CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.In this document, computer
Readable storage medium storing program for executing can be any includes or the tangible medium of storage program, the program can be commanded execution system, device
Either device use or in connection.
Computer-readable signal media can include in a base band or as carrier wave a part propagation data-signal,
Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including --- but
It is not limited to --- electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be
Any computer-readable medium beyond computer-readable recording medium, the computer-readable medium can send, propagate or
Transmit for by instruction execution system, device either device use or program in connection.
The program code included on computer-readable medium can be transmitted with any appropriate medium, including --- but it is unlimited
In --- wireless, electric wire, optical cable, RF etc., or above-mentioned any appropriate combination.
Can with one or more programming languages or its combination come write for perform the application operation computer
Program code, described program design language include object oriented program language-such as Java, Smalltalk, C++,
Also include conventional procedural programming language-such as " C " language or similar programming language.Program code can be with
Fully perform, partly perform on the user computer on the user computer, the software kit independent as one performs, portion
Divide and partly perform or performed completely on remote computer or server on the remote computer on the user computer.
It is related in the situation of remote computer, remote computer can pass through the network of any kind --- including LAN (Local
Area Network;Hereinafter referred to as:) or wide area network (Wide Area Network LAN;Hereinafter referred to as:WAN) it is connected to user
Computer, or, it may be connected to outer computer (such as passing through Internet connection using ISP).
The embodiment of the present application also provides a kind of computer program product, when the instruction in above computer program product by
When managing device execution, it is possible to achieve the data manipulation method that the embodiment of the present application provides.
In the description of this specification, reference term " one embodiment ", " some embodiments ", " example ", " specifically show
The description of example " or " some examples " etc. means specific features, structure, material or the spy for combining the embodiment or example description
Point is contained at least one embodiment or example of the application.In this manual, to the schematic representation of above-mentioned term not
Identical embodiment or example must be directed to.Moreover, specific features, structure, material or the feature of description can be with office
Combined in an appropriate manner in one or more embodiments or example.In addition, in the case of not conflicting, the skill of this area
Art personnel can be tied the different embodiments or example and the feature of different embodiments or example described in this specification
Close and combine.
In addition, term " first ", " second " are only used for describing purpose, and it is not intended that instruction or hint relative importance
Or the implicit quantity for indicating indicated technical characteristic.Thus, define " first ", the feature of " second " can be expressed or
Implicitly include at least one this feature.In the description of the present application, " multiple " are meant that at least two, such as two, three
It is individual etc., unless otherwise specifically defined.
Any process or method described otherwise above description in flow chart or herein is construed as, and represents to include
Module, fragment or the portion of the code of the executable instruction of one or more the step of being used to realize custom logic function or process
Point, and the scope of the preferred embodiment of the application includes other realization, wherein can not press shown or discuss suitable
Sequence, including according to involved function by it is basic simultaneously in the way of or in the opposite order, carry out perform function, this should be by the application
Embodiment person of ordinary skill in the field understood.
Expression or logic and/or step described otherwise above herein in flow charts, for example, being considered use
In the order list for the executable instruction for realizing logic function, may be embodied in any computer-readable medium, for
Instruction execution system, device or equipment (such as computer based system including the system of processor or other can be held from instruction
The system of row system, device or equipment instruction fetch and execute instruction) use, or combine these instruction execution systems, device or set
It is standby and use.For the purpose of this specification, " computer-readable medium " can any can be included, store, communicate, propagate or pass
Defeated program is for instruction execution system, device or equipment or the dress used with reference to these instruction execution systems, device or equipment
Put.The more specifically example (non-exhaustive list) of computer-readable medium includes following:Electricity with one or more wiring
Connecting portion (electronic installation), portable computer diskette box (magnetic device), random access memory (Random Access
Memory;Hereinafter referred to as:RAM), read-only storage (Read Only Memory;Hereinafter referred to as:ROM), erasable editable
Read memory (Erasable Programmable Read Only Memory;Hereinafter referred to as:EPROM) or flash memory,
Fiber device, and portable optic disk read-only storage (Compact Disc Read Only Memory;Hereinafter referred to as:CD-
ROM).In addition, computer-readable medium, which can even is that, to print the paper or other suitable media of described program thereon, because
Can then to enter edlin, interpretation or suitable with other if necessary for example by carrying out optical scanner to paper or other media
Mode is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each several part of the application can be realized with hardware, software, firmware or combinations thereof.Above-mentioned
In embodiment, software that multiple steps or method can be performed in memory and by suitable instruction execution system with storage
Or firmware is realized.Such as, if realized with hardware with another embodiment, following skill well known in the art can be used
Any one of art or their combination are realized:With the logic gates for realizing logic function to data-signal from
Logic circuit is dissipated, the application specific integrated circuit with suitable combinational logic gate circuit, programmable gate array (Programmable
Gate Array;Hereinafter referred to as:PGA), field programmable gate array (Field Programmable Gate Array;Below
Referred to as:FPGA) etc..
Those skilled in the art are appreciated that to realize all or part of step that above-described embodiment method carries
Suddenly it is that by program the hardware of correlation can be instructed to complete, described program can be stored in a kind of computer-readable storage medium
In matter, the program upon execution, including one or a combination set of the step of embodiment of the method.
In addition, each functional unit in each embodiment of the application can be integrated in a processing module, can also
That unit is individually physically present, can also two or more units be integrated in a module.Above-mentioned integrated mould
Block can both be realized in the form of hardware, can also be realized in the form of software function module.The integrated module is such as
Fruit is realized in the form of software function module and as independent production marketing or in use, can also be stored in a computer
In read/write memory medium.
Storage medium mentioned above can be read-only storage, disk or CD etc..Although have been shown and retouch above
Embodiments herein is stated, it is to be understood that above-described embodiment is exemplary, it is impossible to be interpreted as the limit to the application
System, one of ordinary skill in the art can be changed to above-described embodiment, change, replace and become within the scope of application
Type.
Claims (10)
- A kind of 1. data manipulation method, it is characterised in that including:Receive data operation request;After the parent object addition relation lock of operation object is treated in application, apply to the object addition Structural lock to be operated;Data manipulation is carried out to the object to be operated according to the data operation request.
- 2. according to the method for claim 1, it is characterised in that the data operation request includes read operation request, described Structural lock includes structure read lock;After the parent object addition relation lock of operation object is treated in the application, apply to the object addition Structural lock to be operated Including:After the parent object addition relation lock of operation object is treated in application, apply to the object addition structure read lock to be operated;It is described that the object progress data manipulation to be operated is included according to the data operation request:Data read operation is carried out to the object to be operated according to the read operation request.
- 3. according to the method for claim 1, it is characterised in that the data operation request includes write operation requests, described Structural lock writes lock including structure;After the parent object addition relation lock of operation object is treated in the application, apply to the object addition Structural lock to be operated Including:After the parent object addition relation lock of operation object is treated in application, apply writing lock to the object addition structure to be operated;It is described that the object progress data manipulation to be operated is included according to the data operation request:Data write operation is carried out to the object to be operated according to the write operation requests.
- 4. according to the method for claim 2, it is characterised in that between the relation lock, the relation is locked and the structure It is reentrant between read lock and between the structure read lock;It is described to reentry including carrying out repeating to add to identical object Lock;And/or include identical object in the range of reentrant lock.
- 5. according to the method for claim 3, it is characterised in that the structure is write between lock and relation lock, the knot Structure write lock and structure read lock and the structure write lock between be mutual exclusion;Wherein, the lock of mutual exclusion can not lock same object; And/or identical object can not be included in the range of the lock of mutual exclusion.
- 6. according to the method for claim 2, it is characterised in that the parent object addition relation for applying treating operation object After lock, apply including the object addition structure read lock to be operated:The parent object addition relation lock of operation object is treated in application;Judge the object to be operated writes whether counting is the first numerical value;If it is, application adds structure read lock to the object to be operated, and the reading of the object to be operated is counted and added Second value.
- A kind of 7. data operation device, it is characterised in that including:Receiving module, for receiving data operation request;Apply for module, after the parent object addition relation lock for applying for treating operation object, apply to the object to be operated Add Structural lock;Data operation modules, for entering line number to the object to be operated according to the data operation request that the receiving module receives According to operation.
- 8. a kind of computer equipment, it is characterised in that including memory, processor and be stored on the memory and can be in institute The computer program run on processor is stated, described in the computing device during computer program, is realized as in claim 1-6 Any described method.
- 9. a kind of non-transitorycomputer readable storage medium, is stored thereon with computer program, it is characterised in that the calculating The method as described in any in claim 1-6 is realized when machine program is executed by processor.
- 10. a kind of computer program product, when the instruction in the computer program product is by computing device, realize as weighed Profit requires any described method in 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710657501.0A CN107688612B (en) | 2017-08-03 | 2017-08-03 | Data operation method and device and computer equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710657501.0A CN107688612B (en) | 2017-08-03 | 2017-08-03 | Data operation method and device and computer equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107688612A true CN107688612A (en) | 2018-02-13 |
CN107688612B CN107688612B (en) | 2021-03-30 |
Family
ID=61153108
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710657501.0A Active CN107688612B (en) | 2017-08-03 | 2017-08-03 | Data operation method and device and computer equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107688612B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111475262A (en) * | 2020-04-02 | 2020-07-31 | 百度国际科技(深圳)有限公司 | Transaction request processing method, device, equipment and medium in block chain |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6714951B2 (en) * | 2001-04-16 | 2004-03-30 | International Business Machines Corporation | Continuous journaling of objects within a hierarchical directory tree |
CN101702176A (en) * | 2009-11-25 | 2010-05-05 | 南开大学 | XML data concurrency control method based on local path lock |
CN101771670A (en) * | 2008-12-30 | 2010-07-07 | 北京天融信网络安全技术有限公司 | Method for concurrently identifying and processing sub-joins in multi-core systems |
CN102385600A (en) * | 2010-09-03 | 2012-03-21 | 上海实方软件有限公司 | XML (Extensive Makeup Language) multi-granularity lock based on relation-XML dual-mode data base |
CN105389360A (en) * | 2015-11-05 | 2016-03-09 | 浪潮(北京)电子信息产业有限公司 | AVL tree-based data writing method and apparatus |
US20160182630A1 (en) * | 2012-11-01 | 2016-06-23 | Netapp, Inc. | Lock State Synchronization for Non-Disruptive Persistent Operation |
-
2017
- 2017-08-03 CN CN201710657501.0A patent/CN107688612B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6714951B2 (en) * | 2001-04-16 | 2004-03-30 | International Business Machines Corporation | Continuous journaling of objects within a hierarchical directory tree |
CN101771670A (en) * | 2008-12-30 | 2010-07-07 | 北京天融信网络安全技术有限公司 | Method for concurrently identifying and processing sub-joins in multi-core systems |
CN101702176A (en) * | 2009-11-25 | 2010-05-05 | 南开大学 | XML data concurrency control method based on local path lock |
CN102385600A (en) * | 2010-09-03 | 2012-03-21 | 上海实方软件有限公司 | XML (Extensive Makeup Language) multi-granularity lock based on relation-XML dual-mode data base |
US20160182630A1 (en) * | 2012-11-01 | 2016-06-23 | Netapp, Inc. | Lock State Synchronization for Non-Disruptive Persistent Operation |
CN105389360A (en) * | 2015-11-05 | 2016-03-09 | 浪潮(北京)电子信息产业有限公司 | AVL tree-based data writing method and apparatus |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111475262A (en) * | 2020-04-02 | 2020-07-31 | 百度国际科技(深圳)有限公司 | Transaction request processing method, device, equipment and medium in block chain |
CN111475262B (en) * | 2020-04-02 | 2024-02-06 | 百度国际科技(深圳)有限公司 | Transaction request processing method, device, equipment and medium in blockchain |
Also Published As
Publication number | Publication date |
---|---|
CN107688612B (en) | 2021-03-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9223610B2 (en) | Management of virtual machine snapshots | |
US20070174509A1 (en) | System for asynchronous dma command completion notification | |
CN109062512A (en) | A kind of distributed storage cluster, data read-write method, system and relevant apparatus | |
US20190012005A1 (en) | Method and device for asynchronous touch and asynchronous display on dual-screen and computer readable storage medium | |
CN103019810A (en) | Scheduling and management of compute tasks with different execution priority levels | |
CN104731574A (en) | Method and system for resource bottleneck identification for multi-stage workflows processing | |
CN110347493A (en) | Processing method, display methods, device, equipment and the storage medium of page data | |
CN107423894A (en) | The task measures and procedures for the examination and approval, device and computer equipment | |
CN108038112A (en) | Document handling method, mobile terminal and computer-readable recording medium | |
CN112256886A (en) | Probability calculation method and device in map, computer equipment and storage medium | |
US20180324222A1 (en) | Testing distributed applications that have an established exchange in an advanced message queuing protocol (amqp) message broker | |
CN109818810A (en) | A kind of access server connection optimization method, access server and communication system | |
CN103294556A (en) | Method and system for host system admission control | |
CN107943584A (en) | The processing method and processing device of batch transaction request | |
CN113052696A (en) | Financial business task processing method and device, computer equipment and storage medium | |
CN107506494B (en) | Document handling method, mobile terminal and computer readable storage medium | |
CN109376165A (en) | The implementation method and device and computer readable storage medium of memory database lock | |
CN100583064C (en) | Method and equipment for removing alias addresses from an alias address pool | |
CN107506200A (en) | A kind of screen content switching method, terminal and computer-readable recording medium | |
CN107688612A (en) | Data manipulation method, device and computer equipment | |
CN112558937B (en) | Page management method, device, electronic equipment, medium and product | |
CN107368255B (en) | Unlocking method, mobile terminal and computer readable storage medium | |
CN111258950A (en) | Atomic access and storage method, storage medium, computer equipment, device and system | |
US20170068576A1 (en) | Managing a free list of resources to decrease control complexity and reduce power consumption | |
US12066974B2 (en) | Systems and methods for end-to-end workload modeling for servers |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |