SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Public Attributes | List of all members
sdbclient::sdbCollection Class Reference

Database operation interfaces of collection. More...

#include <client.hpp>

Public Member Functions

 sdbCollection ()
 Default constructor.
 
 ~sdbCollection ()
 Destructor.
 
INT32 getCount (SINT64 &count, const bson::BSONObj &condition=_sdbStaticObject)
 Get the count of matching documents in current collection.
 
INT32 split (const CHAR *pSourceGroupName, const CHAR *pTargetGroupName, const bson::BSONObj &splitCondition, const bson::BSONObj &splitEndCondition=_sdbStaticObject)
 Split the specified collection from source replica group to target replica group by range.
 
INT32 split (const CHAR *pSourceGroupName, const CHAR *pTargetGroupName, FLOAT64 percent)
 Split the specified collection from source replica group to target replica group by percent.
 
INT32 splitAsync (SINT64 &taskID, const CHAR *pSourceGroupName, const CHAR *pTargetGroupName, const bson::BSONObj &splitCondition, const bson::BSONObj &splitEndCondition=_sdbStaticObject)
 Split the specified collection from source replica group to target replica group by range.
 
INT32 splitAsync (const CHAR *pSourceGroupName, const CHAR *pTargetGroupName, FLOAT64 percent, SINT64 &taskID)
 Split the specified collection from source replica group to target replica group by percent.
 
INT32 alterCollection (const bson::BSONObj &options)
 Alter the current collection.
 
INT32 bulkInsert (SINT32 flags, std::vector< bson::BSONObj > &obj)
 Insert a bulk of bson objects into current collection.
 
INT32 insert (const bson::BSONObj &obj, bson::OID *id=NULL)
 Insert a bson object into current collection.
 
INT32 update (const bson::BSONObj &rule, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject)
 Update the matching documents in current collection.
 
INT32 upsert (const bson::BSONObj &rule, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, const bson::BSONObj &setOnInsert=_sdbStaticObject)
 Update the matching documents in current collection, insert if no matching.
 
INT32 del (const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject)
 Delete the matching documents in current collection.
 
INT32 query (_sdbCursor **cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &selected=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1, INT32 flags=0)
 
INT32 query (sdbCursor &cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &selected=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1, INT32 flag=0)
 Get the matching documents in current collection.
 
INT32 queryOne (bson::BSONObj &obj, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &selected=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT32 flag=0)
 Get the first matching documents in current collection.
 
INT32 queryAndUpdate (sdbCursor &cursor, const bson::BSONObj &update, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &selected=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1, INT32 flag=0, BOOLEAN returnNew=FALSE)
 Get the matching documents in current collection and update.
 
INT32 queryAndRemove (sdbCursor &cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &selected=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1, INT32 flag=0)
 Get the matching documents in current collection and remove.
 
INT32 createIndex (const bson::BSONObj &indexDef, const CHAR *pIndexName, BOOLEAN isUnique, BOOLEAN isEnforced)
 Create the index in current collection.
 
INT32 createIndex (const bson::BSONObj &indexDef, const CHAR *pIndexName, BOOLEAN isUnique, BOOLEAN isEnforced, INT32 sortBufferSize)
 Create the index in current collection.
 
INT32 getIndexes (_sdbCursor **cursor, const CHAR *pIndexName)
 
INT32 getIndexes (sdbCursor &cursor, const CHAR *pIndexName)
 Get all of or one of the indexes in current collection.
 
INT32 dropIndex (const CHAR *pIndexName)
 Drop the index in current collection.
 
INT32 create ()
 create the specified collection of current collection space
 
INT32 drop ()
 Drop the specified collection of current collection space.
 
const CHAR * getCollectionName ()
 Get the name of specified collection in current collection space.
 
const CHAR * getCSName ()
 Get the name of current collection space.
 
const CHAR * getFullName ()
 Get the full name of specified collection in current collection space.
 
INT32 aggregate (_sdbCursor **cursor, std::vector< bson::BSONObj > &obj)
 
INT32 aggregate (sdbCursor &cursor, std::vector< bson::BSONObj > &obj)
 Execute aggregate operation in specified collection.
 
INT32 getQueryMeta (_sdbCursor **cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1)
 
INT32 getQueryMeta (sdbCursor &cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1)
 Get the index blocks' or data blocks' infomations for concurrent query.
 
INT32 attachCollection (const CHAR *subClFullName, const bson::BSONObj &options)
 Attach the specified collection.
 
INT32 detachCollection (const CHAR *subClFullName)
 Dettach the specified collection.
 
INT32 explain (sdbCursor &cursor, const bson::BSONObj &condition=_sdbStaticObject, const bson::BSONObj &select=_sdbStaticObject, const bson::BSONObj &orderBy=_sdbStaticObject, const bson::BSONObj &hint=_sdbStaticObject, INT64 numToSkip=0, INT64 numToReturn=-1, INT32 flag=0, const bson::BSONObj &options=_sdbStaticObject)
 Get access plan of query.
 
INT32 createLob (sdbLob &lob, const bson::OID *oid=NULL)
 Create large object.
 
INT32 removeLob (const bson::OID &oid)
 Remove large object.
 
INT32 openLob (sdbLob &lob, const bson::OID &oid)
 Open an existing large object for reading.
 
INT32 listLobs (sdbCursor &cursor)
 List all the lobs' meta data in current collection.
 
INT32 truncate ()
 truncate the collection
 
INT32 createIdIndex (const bson::BSONObj &options=_sdbStaticObject)
 Create $id index in collection.
 
INT32 dropIdIndex ()
 Drop $id index in collection.
 

Public Attributes

_sdbCollectionpCollection
 

Detailed Description

Database operation interfaces of collection.

Member Function Documentation

INT32 sdbclient::sdbCollection::aggregate ( sdbCursor cursor,
std::vector< bson::BSONObj > &  obj 
)
inline

Execute aggregate operation in specified collection.

Parameters
[in]objThe array of bson objects
[out]cursorThe cursor object of result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::alterCollection ( const bson::BSONObj &  options)
inline

Alter the current collection.

Parameters
[in]optionsThe modified options as following:
ReplSize     : Assign how many replica nodes need to be synchronized when a write request(insert, update, etc) is executed
ShardingKey  : Assign the sharding key
ShardingType : Assign the sharding type
Partition    : When the ShardingType is "hash", need to assign Partition, it's the bucket number for hash, the range is [2^3,2^20]
               e.g. {RepliSize:0, ShardingKey:{a:1}, ShardingType:"hash", Partition:1024}
Note
Can't alter attributes about split in partition collection; After altering a collection to be a partition collection, need to split this collection manually
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::attachCollection ( const CHAR *  subClFullName,
const bson::BSONObj &  options 
)
inline

Attach the specified collection.

Parameters
[in]subClFullNameThe name of the subcollection
[in]optionsThe low boudary and up boudary eg: {"LowBound":{a:1},"UpBound":{a:100}}
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::bulkInsert ( SINT32  flags,
std::vector< bson::BSONObj > &  obj 
)
inline

Insert a bulk of bson objects into current collection.

Parameters
[in]flagsThe flag to control the behavior of inserting. The value of flag default to be 0, and it can choose the follow values:
  • 0: while 0 is set(default to be 0), database will stop inserting when some records hit index key duplicate error.
  • FLG_INSERT_CONTONDUP: if some records hit index key duplicate error, database will skip them and go on inserting.
  • FLG_INSERT_REPLACEONDUP: if the record hit index key duplicate error, database will replace the existing record by the inserting new record and then go on inserting.

[in]objThe array of inserted bson objects
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::create ( )
inline

create the specified collection of current collection space

Deprecated:
This function will be deprecated in SequoiaDB1.6, use sdbCollectionSpace::createCollection instead of it.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::createIdIndex ( const bson::BSONObj &  options = _sdbStaticObject)
inline

Create $id index in collection.

Parameters
[in]optionsThe arguments of creating id index.e.g.{SortBufferSize:64}
SortBufferSize     : The size of sort buffer used when creating index, the unit is MB,
                     zero means don't use sort buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::createIndex ( const bson::BSONObj &  indexDef,
const CHAR *  pIndexName,
BOOLEAN  isUnique,
BOOLEAN  isEnforced 
)
inline

Create the index in current collection.

Parameters
[in]indexDefThe bson structure of index element, e.g. {name:1, age:-1}
[in]pIndexNameThe index name
[in]isUniqueWhether the index elements are unique or not
[in]isEnforcedWhether the index is enforced unique This element is meaningful when isUnique is set to true
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::createIndex ( const bson::BSONObj &  indexDef,
const CHAR *  pIndexName,
BOOLEAN  isUnique,
BOOLEAN  isEnforced,
INT32  sortBufferSize 
)
inline

Create the index in current collection.

Parameters
[in]indexDefThe bson structure of index element, e.g. {name:1, age:-1}
[in]pIndexNameThe index name
[in]isUniqueWhether the index elements are unique or not
[in]isEnforcedWhether the index is enforced unique This element is meaningful when isUnique is set to true
[in]sortBufferSizeThe size of sort buffer used when creating index, the unit is MB, zero means don't use sort buffer
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::createLob ( sdbLob lob,
const bson::OID *  oid = NULL 
)
inline

Create large object.

Parameters
[in]oidThe id of the large object
[out]lobThe newly create large object
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
When oid is offered, use it to create a lob for writing, otherwise, API will generate one. After finish writing the newly created lob, need to close it to release resource.
INT32 sdbclient::sdbCollection::del ( const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject 
)
inline

Delete the matching documents in current collection.

Parameters
[in]conditionThe matching rule, delete all the documents if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::detachCollection ( const CHAR *  subClFullName)
inline

Dettach the specified collection.

Parameters
[in]subClFullNameThe name of the subcollection
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::drop ( )
inline

Drop the specified collection of current collection space.

Deprecated:
This function will be deprecated in SequoiaDB1.6, use sdbCollectionSpace::dropCollection instead of it.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::dropIdIndex ( )
inline

Drop $id index in collection.

Return values
SDB_OKOperation Success
OthersOperation Fail
Note
delete, update and upsert do not work after index "$id" was drop
INT32 sdbclient::sdbCollection::dropIndex ( const CHAR *  pIndexName)
inline

Drop the index in current collection.

Parameters
[in]pIndexNameThe index name
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::explain ( sdbCursor cursor,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  select = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
INT64  numToSkip = 0,
INT64  numToReturn = -1,
INT32  flag = 0,
const bson::BSONObj &  options = _sdbStaticObject 
)
inline

Get access plan of query.

Parameters
[in]conditionThe matching rule, return all the documents if null
[in]selectThe selective rule, return the whole document if null
[in]orderByThe ordered rule, never sort if null
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, never skip if this parameter is 0
[in]numToReturnOnly return numToReturn documents, return all if this parameter is -1
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[in]optionsthe rules of explain, the options are as below:
Run     : Whether execute query explain or not, true for excuting query explain then get
          the data and time information; false for not excuting query explain but get the
          query explain information only. e.g. {Run:true}
[out]cursorThe cursor of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
const CHAR * sdbclient::sdbCollection::getCollectionName ( )
inline

Get the name of specified collection in current collection space.

Returns
The name of specified collection.
INT32 sdbclient::sdbCollection::getCount ( SINT64 &  count,
const bson::BSONObj &  condition = _sdbStaticObject 
)
inline

Get the count of matching documents in current collection.

Parameters
[in]conditionThe matching rule, return the count of all documents if this parameter is empty
[out]countThe count of matching documents, matches all records if not provided.
Return values
SDB_OKOperation Success
OthersOperation Fail
const CHAR * sdbclient::sdbCollection::getCSName ( )
inline

Get the name of current collection space.

Returns
The name of current collection space.
const CHAR * sdbclient::sdbCollection::getFullName ( )
inline

Get the full name of specified collection in current collection space.

Returns
The full name of specified collection.
INT32 sdbclient::sdbCollection::getIndexes ( sdbCursor cursor,
const CHAR *  pIndexName 
)
inline

Get all of or one of the indexes in current collection.

Parameters
[in]pIndexNameThe index name, returns all of the indexes if this parameter is null
[out]cursorThe cursor of all the result for current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::getQueryMeta ( sdbCursor cursor,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  selected = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
INT64  numToSkip = 0,
INT64  numToReturn = -1 
)
inline

Get the index blocks' or data blocks' infomations for concurrent query.

Parameters
[in]conditionThe matching rule, return the whole range of index blocks if not provided eg:{"age":{"$gt":25},"age":{"$lt":75}}
[in]orderByThe ordered rule, result set is unordered if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, default is 0
[in]numToReturnOnly return numToReturn documents, default is -1 for returning all results
[out]cursorThe result of query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::insert ( const bson::BSONObj &  obj,
bson::OID *  id = NULL 
)
inline

Insert a bson object into current collection.

Parameters
[in]objThe inserted bson object
[out]idThe object id of inserted bson object in current collection, the memory of id will be invalidated when next insert/bulkInsert is performed or the obj is destroyed
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::listLobs ( sdbCursor cursor)
inline

List all the lobs' meta data in current collection.

Parameters
[out]cursorThe curosr reference of the result
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::openLob ( sdbLob lob,
const bson::OID &  oid 
)
inline

Open an existing large object for reading.

Parameters
[in]oidThe id of the large object
[out]lobThe large object to get
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
Need to close lob to release resource, after opening a lob.
INT32 sdbclient::sdbCollection::query ( sdbCursor cursor,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  selected = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
INT64  numToSkip = 0,
INT64  numToReturn = -1,
INT32  flag = 0 
)
inline

Get the matching documents in current collection.

Parameters
[in]conditionThe matching rule, return all the documents if not provided
[in]selectedThe selective rule, return the whole document if not provided
[in]orderByThe ordered rule, result set is unordered if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, default is 0
[in]numToReturnOnly return numToReturn documents, default is -1 for returning all results
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[out]cursorThe cursor of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::queryAndRemove ( sdbCursor cursor,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  selected = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
INT64  numToSkip = 0,
INT64  numToReturn = -1,
INT32  flag = 0 
)
inline

Get the matching documents in current collection and remove.

Parameters
[in]conditionThe matching rule, return all the documents if not provided
[in]selectedThe selective rule, return the whole document if not provided
[in]orderByThe ordered rule, result set is unordered if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, default is 0
[in]numToReturnOnly return numToReturn documents, default is -1 for returning all results
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[out]cursorThe cursor of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::queryAndUpdate ( sdbCursor cursor,
const bson::BSONObj &  update,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  selected = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
INT64  numToSkip = 0,
INT64  numToReturn = -1,
INT32  flag = 0,
BOOLEAN  returnNew = FALSE 
)
inline

Get the matching documents in current collection and update.

Parameters
[in]updateThe update rule, can't be empty
[in]conditionThe matching rule, return all the documents if not provided
[in]selectedThe selective rule, return the whole document if not provided
[in]orderByThe ordered rule, result set is unordered if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, default is 0
[in]numToReturnOnly return numToReturn documents, default is -1 for returning all results
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[in]returnNewWhen TRUE, returns the updated document rather than the original
[out]cursorThe cursor of current query
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::queryOne ( bson::BSONObj &  obj,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  selected = _sdbStaticObject,
const bson::BSONObj &  orderBy = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
INT64  numToSkip = 0,
INT32  flag = 0 
)
inline

Get the first matching documents in current collection.

Parameters
[in]conditionThe matching rule, return all the documents if not provided
[in]selectedThe selective rule, return the whole document if not provided
[in]orderByThe ordered rule, result set is unordered if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]numToSkipSkip the first numToSkip documents, default is 0
[in]flagThe query flag, default to be 0. Please see the definition of follow flags for more detail. Usage: e.g. set ( QUERY_FORCE_HINT | QUERY_WITH_RETURNDATA ) to param flag
QUERY_FORCE_HINT
QUERY_PARALLED
QUERY_WITH_RETURNDATA
[out]objThe first matching object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::removeLob ( const bson::OID &  oid)
inline

Remove large object.

Parameters
[in]oidThe id of the large object
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::split ( const CHAR *  pSourceGroupName,
const CHAR *  pTargetGroupName,
const bson::BSONObj &  splitCondition,
const bson::BSONObj &  splitEndCondition = _sdbStaticObject 
)
inline

Split the specified collection from source replica group to target replica group by range.

Parameters
[in]pSourceGroupNameThe source replica group name
[in]pTargetGroupNameThe target replica group name
[in]splitConditionThe split condition
[in]splitEndConditionThe split end condition or null eg:If we create a collection with the option {ShardingKey:{"age":1},ShardingType:"Hash",Partition:2^10}, we can fill {age:30} as the splitCondition, and fill {age:60} as the splitEndCondition. when split, the target replica group will get the records whose age's hash value are in [30,60). If splitEndCondition is null, they are in [30,max).
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::split ( const CHAR *  pSourceGroupName,
const CHAR *  pTargetGroupName,
FLOAT64  percent 
)
inline

Split the specified collection from source replica group to target replica group by percent.

Parameters
[in]pSourceGroupNameThe source replica group name
[in]pTargetGroupNameThe target replica group name
[in]percentThe split percent, Range:(0,100]
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::splitAsync ( SINT64 &  taskID,
const CHAR *  pSourceGroupName,
const CHAR *  pTargetGroupName,
const bson::BSONObj &  splitCondition,
const bson::BSONObj &  splitEndCondition = _sdbStaticObject 
)
inline

Split the specified collection from source replica group to target replica group by range.

Parameters
[out]taskIDThe id of current split task
[in]pSourceGroupNameThe source replica group name
[in]pTargetGroupNameThe target replica group name
[in]splitConditionThe split condition
[in]splitEndConditionThe split end condition or null eg:If we create a collection with the option {ShardingKey:{"age":1},ShardingType:"Hash",Partition:2^10}, we can fill {age:30} as the splitCondition, and fill {age:60} as the splitEndCondition. when split, the target replica group will get the records whose age's hash value are in [30,60). If splitEndCondition is null, they are in [30,max).
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 INT32 sdbclient::sdbCollection::splitAsync ( const CHAR *  pSourceGroup,
const CHAR *  pTargetGroup,
FLOAT64  percent,
SINT64 &  taskID 
)
inline

Split the specified collection from source replica group to target replica group by percent.

Parameters
[in]pSourceGroupNameThe source replica group name
[in]pTargetGroupNameThe target replica group name
[in]percentThe split percent, Range:(0.0, 100.0]
[out]taskIDThe id of current split task
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::truncate ( )
inline

truncate the collection

Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbCollection::update ( const bson::BSONObj &  rule,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject 
)
inline

Update the matching documents in current collection.

Parameters
[in]ruleThe updating rule
[in]conditionThe matching rule, update all the documents if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
It won't work to update the "ShardingKey" field, but the other fields take effect
INT32 sdbclient::sdbCollection::upsert ( const bson::BSONObj &  rule,
const bson::BSONObj &  condition = _sdbStaticObject,
const bson::BSONObj &  hint = _sdbStaticObject,
const bson::BSONObj &  setOnInsert = _sdbStaticObject 
)
inline

Update the matching documents in current collection, insert if no matching.

Parameters
[in]ruleThe updating rule
[in]conditionThe matching rule, update all the documents if not provided
[in]hintSpecified the index used to scan data. e.g. {"":"ageIndex"} means using index "ageIndex" to scan data(index scan); {"":null} means table scan. when hint is not provided, database automatically match the optimal index to scan data
[in]setOnInsertThe setOnInsert assigns the specified values to the fileds when insert
Return values
SDB_OKOperation Success
OthersOperation Fail
Note
It won't work to upsert the "ShardingKey" field, but the other fields take effect

Member Data Documentation

sdbclient::sdbCollection::pCollection

A pointer of virtual base class _sdbCollection

Class sdbCollection is a shell for _sdbCollection. We use pCollection to call the methods in class _sdbCollection.


The documentation for this class was generated from the following file: