mirror of https://gitee.com/bigwinds/arangodb
comments
This commit is contained in:
parent
33d5abbd91
commit
562ace7d89
|
@ -40,18 +40,58 @@
|
|||
namespace triagens {
|
||||
namespace arango {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class TransactionCollectionsList
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class TransactionCollectionsList {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief typedef for contained collections list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef map<string, TransactionCollection*> ListType;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief TransactionCollectionsList copy ctor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
TransactionCollectionsList& operator= (const TransactionCollectionsList&);
|
||||
TransactionCollectionsList (const TransactionCollectionsList&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create an empty list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TransactionCollectionsList () :
|
||||
_collections() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a list with a single collection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TransactionCollectionsList (TRI_vocbase_t* const vocbase,
|
||||
const string& name,
|
||||
TRI_transaction_type_e accessType) :
|
||||
|
@ -61,6 +101,10 @@ namespace triagens {
|
|||
|
||||
addCollection(name, accessType, false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a list with a single collection, with implicit create flag
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TransactionCollectionsList (TRI_vocbase_t* const vocbase,
|
||||
const string& name,
|
||||
|
@ -72,6 +116,10 @@ namespace triagens {
|
|||
|
||||
addCollection(name, accessType, true, createType);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a list with a single collection, with explicit create flag
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TransactionCollectionsList (TRI_vocbase_t* const vocbase,
|
||||
const string& name,
|
||||
|
@ -84,6 +132,10 @@ namespace triagens {
|
|||
|
||||
addCollection(name, accessType, create, createType);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a list with multiple collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TransactionCollectionsList (TRI_vocbase_t* const vocbase,
|
||||
const vector<string>& readCollections,
|
||||
|
@ -101,6 +153,10 @@ namespace triagens {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief dtor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~TransactionCollectionsList () {
|
||||
ListType::iterator it;
|
||||
|
||||
|
@ -111,10 +167,33 @@ namespace triagens {
|
|||
_collections.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get potential raised during list setup
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline int getError () const {
|
||||
return _error;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns all collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const vector<TransactionCollection*> getCollections () {
|
||||
ListType::iterator it;
|
||||
vector<TransactionCollection*> collections;
|
||||
|
@ -126,6 +205,10 @@ namespace triagens {
|
|||
return collections;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief add a collection to the list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void addCollection (const string& name,
|
||||
TRI_transaction_type_e type,
|
||||
bool create,
|
||||
|
@ -158,8 +241,10 @@ namespace triagens {
|
|||
realName = name;
|
||||
}
|
||||
|
||||
// check if we already have the collection in our list
|
||||
it = _collections.find(realName);
|
||||
if (it != _collections.end()) {
|
||||
// yes, now update the collection in the list
|
||||
TransactionCollection* c = (*it).second;
|
||||
|
||||
if (type == TRI_TRANSACTION_WRITE && type != c->getAccessType()) {
|
||||
|
@ -168,6 +253,7 @@ namespace triagens {
|
|||
}
|
||||
}
|
||||
else {
|
||||
// collection not yet contained in our list
|
||||
|
||||
// check whether the collection exists. if not, create it
|
||||
if (( create && TRI_FindCollectionByNameOrBearVocBase(_vocbase, realName.c_str(), createType) == NULL) ||
|
||||
|
@ -180,13 +266,43 @@ namespace triagens {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoDB
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief vocbase
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vocbase_t* _vocbase;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the list of collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ListType _collections;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief error number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _error;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue