|
SequoiaDB
|
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 | |
| _sdbCollection * | pCollection |
Database operation interfaces of collection.
|
inline |
Execute aggregate operation in specified collection.
| [in] | obj | The array of bson objects |
| [out] | cursor | The cursor object of result |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Alter the current collection.
| [in] | options | The 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}
|
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Attach the specified collection.
| [in] | subClFullName | The name of the subcollection |
| [in] | options | The low boudary and up boudary eg: {"LowBound":{a:1},"UpBound":{a:100}} |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Insert a bulk of bson objects into current collection.
| [in] | flags | The flag to control the behavior of inserting. The value of flag default to be 0, and it can choose the follow values:
|
| [in] | obj | The array of inserted bson objects |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
create the specified collection of current collection space
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Create $id index in collection.
| [in] | options | The 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
|
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Create the index in current collection.
| [in] | indexDef | The bson structure of index element, e.g. {name:1, age:-1} |
| [in] | pIndexName | The index name |
| [in] | isUnique | Whether the index elements are unique or not |
| [in] | isEnforced | Whether the index is enforced unique This element is meaningful when isUnique is set to true |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Create the index in current collection.
| [in] | indexDef | The bson structure of index element, e.g. {name:1, age:-1} |
| [in] | pIndexName | The index name |
| [in] | isUnique | Whether the index elements are unique or not |
| [in] | isEnforced | Whether the index is enforced unique This element is meaningful when isUnique is set to true |
| [in] | sortBufferSize | The size of sort buffer used when creating index, the unit is MB, zero means don't use sort buffer |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Create large object.
| [in] | oid | The id of the large object |
| [out] | lob | The newly create large object |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Delete the matching documents in current collection.
| [in] | condition | The matching rule, delete all the documents if not provided |
| [in] | hint | Specified 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 |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Dettach the specified collection.
| [in] | subClFullName | The name of the subcollection |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Drop the specified collection of current collection space.
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Drop $id index in collection.
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Drop the index in current collection.
| [in] | pIndexName | The index name |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get access plan of query.
| [in] | condition | The matching rule, return all the documents if null |
| [in] | select | The selective rule, return the whole document if null |
| [in] | orderBy | The ordered rule, never sort if null |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, never skip if this parameter is 0 |
| [in] | numToReturn | Only return numToReturn documents, return all if this parameter is -1 |
| [in] | flag | The 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] | options | the 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] | cursor | The cursor of current query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the name of specified collection in current collection space.
|
inline |
Get the count of matching documents in current collection.
| [in] | condition | The matching rule, return the count of all documents if this parameter is empty |
| [out] | count | The count of matching documents, matches all records if not provided. |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the name of current collection space.
|
inline |
Get the full name of specified collection in current collection space.
|
inline |
Get all of or one of the indexes in current collection.
| [in] | pIndexName | The index name, returns all of the indexes if this parameter is null |
| [out] | cursor | The cursor of all the result for current query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the index blocks' or data blocks' infomations for concurrent query.
| [in] | condition | The matching rule, return the whole range of index blocks if not provided eg:{"age":{"$gt":25},"age":{"$lt":75}} |
| [in] | orderBy | The ordered rule, result set is unordered if not provided |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, default is 0 |
| [in] | numToReturn | Only return numToReturn documents, default is -1 for returning all results |
| [out] | cursor | The result of query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Insert a bson object into current collection.
| [in] | obj | The inserted bson object |
| [out] | id | The 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 |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
List all the lobs' meta data in current collection.
| [out] | cursor | The curosr reference of the result |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Open an existing large object for reading.
| [in] | oid | The id of the large object |
| [out] | lob | The large object to get |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the matching documents in current collection.
| [in] | condition | The matching rule, return all the documents if not provided |
| [in] | selected | The selective rule, return the whole document if not provided |
| [in] | orderBy | The ordered rule, result set is unordered if not provided |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, default is 0 |
| [in] | numToReturn | Only return numToReturn documents, default is -1 for returning all results |
| [in] | flag | The 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] | cursor | The cursor of current query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the matching documents in current collection and remove.
| [in] | condition | The matching rule, return all the documents if not provided |
| [in] | selected | The selective rule, return the whole document if not provided |
| [in] | orderBy | The ordered rule, result set is unordered if not provided |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, default is 0 |
| [in] | numToReturn | Only return numToReturn documents, default is -1 for returning all results |
| [in] | flag | The 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] | cursor | The cursor of current query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the matching documents in current collection and update.
| [in] | update | The update rule, can't be empty |
| [in] | condition | The matching rule, return all the documents if not provided |
| [in] | selected | The selective rule, return the whole document if not provided |
| [in] | orderBy | The ordered rule, result set is unordered if not provided |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, default is 0 |
| [in] | numToReturn | Only return numToReturn documents, default is -1 for returning all results |
| [in] | flag | The 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] | returnNew | When TRUE, returns the updated document rather than the original |
| [out] | cursor | The cursor of current query |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Get the first matching documents in current collection.
| [in] | condition | The matching rule, return all the documents if not provided |
| [in] | selected | The selective rule, return the whole document if not provided |
| [in] | orderBy | The ordered rule, result set is unordered if not provided |
| [in] | hint | Specified 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] | numToSkip | Skip the first numToSkip documents, default is 0 |
| [in] | flag | The 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] | obj | The first matching object |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Remove large object.
| [in] | oid | The id of the large object |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Split the specified collection from source replica group to target replica group by range.
| [in] | pSourceGroupName | The source replica group name |
| [in] | pTargetGroupName | The target replica group name |
| [in] | splitCondition | The split condition |
| [in] | splitEndCondition | The 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). |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Split the specified collection from source replica group to target replica group by percent.
| [in] | pSourceGroupName | The source replica group name |
| [in] | pTargetGroupName | The target replica group name |
| [in] | percent | The split percent, Range:(0,100] |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Split the specified collection from source replica group to target replica group by range.
| [out] | taskID | The id of current split task |
| [in] | pSourceGroupName | The source replica group name |
| [in] | pTargetGroupName | The target replica group name |
| [in] | splitCondition | The split condition |
| [in] | splitEndCondition | The 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). |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Split the specified collection from source replica group to target replica group by percent.
| [in] | pSourceGroupName | The source replica group name |
| [in] | pTargetGroupName | The target replica group name |
| [in] | percent | The split percent, Range:(0.0, 100.0] |
| [out] | taskID | The id of current split task |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
truncate the collection
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Update the matching documents in current collection.
| [in] | rule | The updating rule |
| [in] | condition | The matching rule, update all the documents if not provided |
| [in] | hint | Specified 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 |
| SDB_OK | Operation Success |
| Others | Operation Fail |
|
inline |
Update the matching documents in current collection, insert if no matching.
| [in] | rule | The updating rule |
| [in] | condition | The matching rule, update all the documents if not provided |
| [in] | hint | Specified 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] | setOnInsert | The setOnInsert assigns the specified values to the fileds when insert |
| SDB_OK | Operation Success |
| Others | Operation Fail |
| 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.
1.8.2