On 02/26/2013 02:57 PM, Michael Davidsaver wrote:
For some time now I've had the idea that it would be useful to have
API for executing a list of get/put DB operations. What would make
this most useful, and most difficult to implement, would be an option
to make such batch operations atomic (wrt. record locking). I've done
some investigations into how this might be implemented, and I think I
have a clear strategy. However, there are two questions I need to get
answered before I can proceed.
1) Can the three functions from dbLock.h mentioned below be removed
(replaced)?
2) Is the proposed API for batch operations acceptable?
As I have not had any negative answers I've created a working demo of
this new API using the existing locking API. The DBOP_ATOMIC option is
implemented using dbLockSetRecordLock(), so it really is
uninterpretable, but this comes at the cost of serializing all operations.
https://pubweb.bnl.gov/~mdavidsaver/files/dbbatch-pre1.tar.gz
The interesting files are
dbbatch-pre1/batchApp/src/dbAccessBatch.c
dbbatch-pre1/batchApp/src/dbAccessBatch.h
dbbatch-pre1/batchApp/src/testBatch.c
testBatch.c is a unit-test which demonstrates two batched operations.
The first is a get to one record, then a put to another. The second is
a compare and swap operation on a single field.
Note that testBatch is meant to be run from the top level of the source
tree in order to find needed .db and .dbd files.
tar -xzf dbbatch-pre1.tar.gz
cd dbbatch-pre1/
make
./batchApp/src/O.linux-x86/testBatch
The following is extracted from dbAccessBatch.h
/** @brief Batched Field Operations
*
* dbOpFields() executes a list of operations (DBOp structures).
* Execution stop on the first error. DBOp::status indicates
* completion status of each operation.
*
* The return value of dbOpFields() indicates a program logic
* error (invalid inputs). When an error is returned, the first
* DBOp with a non-zero status was the cause.
*
* Supported operations:
*
* - DBOpGet - Read the current field value into DBOp::userbuf
* - DBOpPut* - Write DBOp::userbuf into the field. Plain
* DBOpPut will process the record if the field
* has the PP attribute. DBOpPutNPP will never
* process, and DBOpPutPP will always process.
* - DBOpProc - Same as DBOpPutPP except the field is not modified.
* - DBOpEqual- Succeeds if the DBOp::userbuf is equal to the
* current field value. Only works for scalars.
*
* Modifier flags
*
* DBOP_FAST - Execute operations as quickly as possible.
* Locking is done for individual operations.
* DBOP_ATOMIC - Lock all effected record before first
* operation. No concurrent operation can intrude.
* May be quite slow when large numbers of records
* are involved.
*/
- References:
- New API for batched dbGet/dbPut Michael Davidsaver
- Navigate by Date:
- Prev:
gethostbyname and getaddrinfo - multiple DNS entries for a hostname matthew.pearson
- Next:
PMAC Gaudiello, Phillip
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
New API for batched dbGet/dbPut Michael Davidsaver
- Next:
Proposal to add site-specific TOP_RULES Benjamin Franksen
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|