public class DBCollection extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
FLG_INSERT_CONTONDUP |
| 限定符和类型 | 方法和说明 |
|---|---|
DBCursor |
aggregate(List<BSONObject> obj) |
void |
alterCollection(BSONObject options) |
void |
attachCollection(String subClFullName,
BSONObject options) |
void |
bulkInsert(List<BSONObject> insertor,
int flag) |
void |
createIndex(String name,
BSONObject key,
boolean isUnique,
boolean enforced) |
void |
createIndex(String name,
String key,
boolean isUnique,
boolean enforced) |
DBLob |
createLob() |
DBLob |
createLob(ObjectId id) |
void |
delete(BSONObject matcher) |
void |
delete(BSONObject matcher,
BSONObject hint) |
void |
delete(String matcher) |
void |
delete(String matcher,
String hint) |
void |
detachCollection(String subClFullName) |
void |
dropIndex(String name) |
DBCursor |
explain(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
long skipRows,
long returnRows,
int flag,
BSONObject options) |
CollectionSpace |
getCollectionSpace() |
IConnection |
getConnection() |
long |
getCount() |
long |
getCount(BSONObject matcher) |
long |
getCount(BSONObject condition,
BSONObject hint) |
long |
getCount(String matcher) |
String |
getCSName() |
String |
getFullName() |
DBCursor |
getIndex(String name) |
DBCursor |
getIndexes() |
String |
getName() |
DBCursor |
getQueryMeta(BSONObject query,
BSONObject orderBy,
BSONObject hint,
long skipRows,
long returnRows,
int flag) |
Sequoiadb |
getSequoiadb() |
Object |
insert(BSONObject insertor) |
Object |
insert(String insertor) |
DBCursor |
listLobs() |
DBLob |
openLob(ObjectId id) |
DBCursor |
query() |
DBCursor |
query(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint) |
DBCursor |
query(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
int flag) |
DBCursor |
query(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
long skipRows,
long returnRows) |
DBCursor |
query(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
long skipRows,
long returnRows,
int flag) |
DBCursor |
query(DBQuery matcher) |
DBCursor |
query(String matcher,
String selector,
String orderBy,
String hint) |
DBCursor |
query(String matcher,
String selector,
String orderBy,
String hint,
int flag) |
DBCursor |
query(String matcher,
String selector,
String orderBy,
String hint,
long skipRows,
long returnRows) |
BSONObject |
queryOne() |
BSONObject |
queryOne(BSONObject matcher,
BSONObject selector,
BSONObject orderBy,
BSONObject hint,
int flag) |
void |
removeLob(ObjectId lobID) |
<T> void |
save(List<T> type) |
<T> void |
save(T type) |
void |
setConnection(IConnection connection) |
void |
setMainKeys(String[] keys) |
void |
split(String sourceGroupName,
String destGroupName,
BSONObject splitCondition,
BSONObject splitEndCondition) |
void |
split(String sourceGroupName,
String destGroupName,
double percent) |
long |
splitAsync(String sourceGroupName,
String destGroupName,
BSONObject splitCondition,
BSONObject splitEndCondition) |
long |
splitAsync(String sourceGroupName,
String destGroupName,
double percent) |
void |
update(BSONObject matcher,
BSONObject modifier,
BSONObject hint) |
void |
update(DBQuery query) |
void |
update(String matcher,
String modifier,
String hint) |
void |
upsert(BSONObject matcher,
BSONObject modifier,
BSONObject hint) |
public static final int FLG_INSERT_CONTONDUP
public IConnection getConnection()
public void setConnection(IConnection connection)
public String getName()
public String getFullName()
public String getCSName()
public Sequoiadb getSequoiadb()
public CollectionSpace getCollectionSpace()
public void setMainKeys(String[] keys) throws BaseException
keys - the main keys specified by user.com.sequoiadb.Exception.BaseException - when keys is nullBaseExceptionpublic Object insert(BSONObject insertor) throws BaseException
insertor - The Bson object of insertor, can't be nullBaseExceptionpublic Object insert(String insertor) throws BaseException
insertor - The string of insertorBaseExceptionpublic <T> void save(T type)
throws BaseException
type - The object of insertor, can't be nullBaseException - 1.when the type is not support, throw BaseException with the type "SDB_INVALIDARG"
2.when offer main keys by setMainKeys(), and try to update "_id" field,
it may get a BaseException with the type of "SDB_IXM_DUP_KEY"com.sequoiadb.base.DBCollection.setMainKeyspublic <T> void save(List<T> type) throws BaseException
type - The List instance of insertor, can't be null or emptyBaseException - 1.while the input argument is null or the List instance is empty
2.while the type is not support, throw BaseException with the type "SDB_INVALIDARG"
3.while offer main keys by setMainKeys(), and try to update "_id" field,
it may get a BaseException with the type of "SDB_IXM_DUP_KEY" when the "_id" field you
want to update to had been existing in databasecom.sequoiadb.base.DBCollection.setMainKeyspublic void bulkInsert(List<BSONObject> insertor, int flag) throws BaseException
insertor - The Bson object of insertor list, can't be nullflag - available value is FLG_INSERT_CONTONDUP or 0.
if flag = FLG_INSERT_CONTONDUP, bulkInsert will continue when Duplicate
key exist.(the duplicate record will be ignored);
if flag = 0, bulkInsert will interrupt when Duplicate key exist.BaseExceptionpublic void delete(BSONObject matcher) throws BaseException
matcher - The matching conditionBaseExceptionpublic void delete(String matcher) throws BaseException
matcher - The matching conditionBaseExceptionpublic void delete(String matcher, String hint) throws BaseException
matcher - The matching conditionhint - HintBaseExceptionpublic void delete(BSONObject matcher, BSONObject hint) throws BaseException
matcher - The matching conditionhint - HintBaseExceptionpublic void update(DBQuery query) throws BaseException
query - DBQuery with matching condition, updating rule and hintBaseExceptionpublic void update(BSONObject matcher, BSONObject modifier, BSONObject hint) throws BaseException
matcher - The matching conditionmodifier - The updating rulehint - HintBaseExceptionpublic void update(String matcher, String modifier, String hint) throws BaseException
matcher - The matching conditionmodifier - The updating rulehint - HintBaseExceptionpublic void upsert(BSONObject matcher, BSONObject modifier, BSONObject hint) throws BaseException
matcher - The matching conditionmodifier - The updating rulehint - HintBaseExceptionpublic DBCursor explain(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, long skipRows, long returnRows, int flag, BSONObject options) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullskipRows - skip the first numToSkip documents, never skip if this parameter is 0returnRows - only return returnRows documents, return all if this parameter is -1flag - the flag is used to choose the way to query, the optional options are as below:
options - The rules of query explain, the options are as below:
BaseExceptionpublic DBCursor query() throws BaseException
BaseExceptionpublic DBCursor query(DBQuery matcher) throws BaseException
matcher - the matching rule, return all the documents if nullBaseExceptionDBQuerypublic DBCursor query(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullBaseExceptionpublic DBCursor query(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, int flag) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullflag - the flag is used to choose the way to query, the optional options are as below:
BaseExceptionpublic DBCursor query(String matcher, String selector, String orderBy, String hint) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullBaseExceptionpublic DBCursor query(String matcher, String selector, String orderBy, String hint, int flag) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullflag - the flag is used to choose the way to query, the optional options are as below:
BaseExceptionpublic DBCursor query(String matcher, String selector, String orderBy, String hint, long skipRows, long returnRows) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullskipRows - skip the first numToSkip documents, never skip if this parameter is 0returnRows - only return returnRows documents, return all if this parameter is -1BaseExceptionpublic DBCursor query(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, long skipRows, long returnRows) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullskipRows - skip the first numToSkip documents, never skip if this parameter is 0returnRows - only return returnRows documents, return all if this parameter is -1BaseExceptionpublic DBCursor query(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, long skipRows, long returnRows, int flag) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullskipRows - skip the first numToSkip documents, never skip if this parameter is 0returnRows - only return returnRows documents, return all if this parameter is -1flag - the flag is used to choose the way to query, the optional options are as below:
BaseExceptionpublic BSONObject queryOne(BSONObject matcher, BSONObject selector, BSONObject orderBy, BSONObject hint, int flag) throws BaseException
matcher - the matching rule, return all the documents if nullselector - the selective rule, return the whole document if nullorderBy - the ordered rule, never sort if nullhint - the hint, automatically match the optimal hint if nullflag - the flag is used to choose the way to query, the optional options are as below:
BaseExceptionpublic BSONObject queryOne() throws BaseException
BaseExceptionpublic DBCursor getIndexes() throws BaseException
BaseExceptionpublic DBCursor getIndex(String name) throws BaseException
name - The index name, returns all of the indexes if this parameter
is nullBaseExceptionpublic void createIndex(String name, BSONObject key, boolean isUnique, boolean enforced) throws BaseException
name - The index namekey - The index key, like: {"key":1/-1}, ASC(1)/DESC(-1)isUnique - Whether the index elements are unique or notenforced - Whether the index is enforced unique This element is
meaningful when isUnique is set to trueBaseExceptionpublic void createIndex(String name, String key, boolean isUnique, boolean enforced) throws BaseException
name - The index namekey - The index key, like: {"key":1/-1}, ASC(1)/DESC(-1)isUnique - Whether the index elements are unique or notenforced - Whether the index is enforced unique This element is
meaningful when isUnique is set to trueBaseExceptionpublic void dropIndex(String name) throws BaseException
name - The index nameBaseExceptionpublic long getCount()
throws BaseException
BaseExceptionpublic long getCount(String matcher) throws BaseException
matcher - the matching ruleBaseExceptionpublic long getCount(BSONObject matcher) throws BaseException
matcher - The matching ruleBaseExceptionpublic long getCount(BSONObject condition, BSONObject hint) throws BaseException
condition - The matching rulehint - The hint, automatically match the optimal hint if nullBaseExceptionpublic void split(String sourceGroupName, String destGroupName, BSONObject splitCondition, BSONObject splitEndCondition) throws BaseException
sourceGroupName - the source group namedestGroupName - the destination group namesplitCondition - the split conditionsplitEndCondition - 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 group will get the records whose age's hash value are in [30,60). If splitEndCondition is null,
they are in [30,max).BaseExceptionpublic void split(String sourceGroupName, String destGroupName, double percent) throws BaseException
sourceGroupName - the source group namedestGroupName - the destination group namepercent - the split percent, Range:(0,100]BaseExceptionpublic long splitAsync(String sourceGroupName, String destGroupName, BSONObject splitCondition, BSONObject splitEndCondition) throws BaseException
sourceGroupName - the source group namedestGroupName - the destination group namesplitCondition - the split conditionsplitEndCondition - 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 targe group will get the records whose age's hash values are in [30,60). If splitEndCondition is null,
they are in [30,max).BaseExceptionlistTask, cancelTaskpublic long splitAsync(String sourceGroupName, String destGroupName, double percent) throws BaseException
sourceGroupName - the source group namedestGroupName - the destination group namepercent - the split percent, Range:(0,100]BaseExceptionpublic DBCursor aggregate(List<BSONObject> obj) throws BaseException
obj - The Bson object of rule list, can't be nullBaseExceptionpublic DBCursor getQueryMeta(BSONObject query, BSONObject orderBy, BSONObject hint, long skipRows, long returnRows, int flag) throws BaseException
query - The matching conditionorderBy - The ordered rulehint - One of the indexs of current collection,
using default index to query if not provided
eg:{"":"ageIndex"}skipRows - The rows to be skippedreturnRows - The rows to returnflag - The flag to use which form for record data
0: bson stream
1: binary data stream, form: col1|col2|col3BaseExceptionpublic void attachCollection(String subClFullName, BSONObject options) throws BaseException
subClFullName - The full name of the subcollectionoptions - The low boudary and up boudary
eg: {"LowBound":{a:1},"UpBound":{a:100}}BaseExceptionpublic void detachCollection(String subClFullName) throws BaseException
subClFullName - The full name of the subcollectionBaseExceptionpublic void alterCollection(BSONObject options) throws BaseException
options - The options for altering current collection are as below:
BaseExceptionpublic DBCursor listLobs() throws BaseException
BaseExceptionpublic DBLob createLob() throws BaseException
com.sequoiadb.exception.BaseException.BaseExceptionpublic DBLob createLob(ObjectId id) throws BaseException
id - the lob's id. if id is null, it will be generated in
this functioncom.sequoiadb.exception.BaseException.BaseExceptionpublic DBLob openLob(ObjectId id) throws BaseException
id - the lob's id.com.sequoiadb.exception.BaseException.BaseExceptionpublic void removeLob(ObjectId lobID) throws BaseException
id - the lob's id.com.sequoiadb.exception.BaseException.BaseExceptionCopyright © 2015. All Rights Reserved.