當前位置: 首頁>>代碼示例>>Java>>正文


Java BSONObject類代碼示例

本文整理匯總了Java中org.bson.BSONObject的典型用法代碼示例。如果您正苦於以下問題:Java BSONObject類的具體用法?Java BSONObject怎麽用?Java BSONObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BSONObject類屬於org.bson包,在下文中一共展示了BSONObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: marshalRow

import org.bson.BSONObject; //導入依賴的package包/類
/**
 * Marshals a Cassandra row into a Document object.
 *
 * @param row Row to marshal.
 * @return A document based on the provided row.
 */
public static Document marshalRow(Row row)
{
    if (row == null)
    {
        return null;
    }
    Document d = new Document();
    d.setUuid(row.getUUID(DocumentRepositoryImpl.Columns.ID));
    ByteBuffer b = row.getBytes(DocumentRepositoryImpl.Columns.OBJECT);
    if (b != null && b.hasArray())
    {
        byte[] result = new byte[b.remaining()];
        b.get(result);
        BSONObject o = BSON.decode(result);
        d.setObject(o);
    }
    d.setCreatedAt(row.getDate(DocumentRepositoryImpl.Columns.CREATED_AT));
    d.setUpdatedAt(row.getDate(DocumentRepositoryImpl.Columns.UPDATED_AT));
    return d;
}
 
開發者ID:PearsonEducation,項目名稱:Docussandra,代碼行數:27,代碼來源:DocumentPersistanceUtils.java

示例2: getObject

import org.bson.BSONObject; //導入依賴的package包/類
@Override
public Object getObject(String columnLabel) throws SQLException {
	
	if (isSum) {
	   if (isGroupBy){
		  Object ob=dblist.get(_row-1);
		  if (ob instanceof BSONObject) {
			  return ((BSONObject)ob).get(columnLabel);
		  }
		  else {
			  return "0";  
		  }
	   }
	   else{
		   return  this._sum;
	   }
	}
	else {
		return this._cur.get(columnLabel);
	}
}
 
開發者ID:huang-up,項目名稱:mycat-src-1.6.1-RELEASE,代碼行數:22,代碼來源:SequoiaResultSet.java

示例3: InsertData

import org.bson.BSONObject; //導入依賴的package包/類
private int InsertData(SQLInsertStatement state) {
	if (state.getValues().getValues().size() ==0 ){
		throw new RuntimeException("number of  columns error");
	}		
	if (state.getValues().getValues().size() != state.getColumns().size()){
		throw new RuntimeException("number of values and columns have to match");
	}
	SQLTableSource table=state.getTableSource();
	BSONObject o = new BasicBSONObject();
	int i=0;
	for(SQLExpr col : state.getColumns()) {
		o.put(getFieldName2(col), getExpValue(state.getValues().getValues().get(i)));
		i++;
	}		
	DBCollection coll =this._db.getCollection(table.toString());
	//coll.insert(new DBObject[] { o });
	coll.insert(o);
	return 1;
}
 
開發者ID:huang-up,項目名稱:mycat-src-1.6.1-RELEASE,代碼行數:20,代碼來源:SequoiaSQLParser.java

示例4: UpData

import org.bson.BSONObject; //導入依賴的package包/類
private int UpData(SQLUpdateStatement state) {
	SQLTableSource table=state.getTableSource();
	DBCollection coll =this._db.getCollection(table.toString());
	
	SQLExpr expr=state.getWhere();
	BSONObject query = parserWhere(expr);
	
	BasicBSONObject set = new BasicBSONObject();
	for(SQLUpdateSetItem col : state.getItems()){
		set.put(getFieldName2(col.getColumn()), getExpValue(col.getValue()));	
	}
	BSONObject mod = new BasicBSONObject("$set", set);
	//coll.updateMulti(query, mod);
	coll.update(query, mod, null);
	//System.out.println("changs count:"+coll.getStats().size());
	return 1;		
}
 
開發者ID:huang-up,項目名稱:mycat-src-1.6.1-RELEASE,代碼行數:18,代碼來源:SequoiaSQLParser.java

示例5: checkElements

import org.bson.BSONObject; //導入依賴的package包/類
public boolean checkElements(BSONObject index, BSONObject feature) {

        if (srcIpMask == 0 && dstIpMask == 0) {
            //marking according to featureConstraint
            return featureDatabaseMgmtManager.isSatisfyOnlineEvent(
                    (Document) index,
                    (Document) feature,
                    featureConstraint);
        }

        if (srcIpMask != 0 && index.get(AthenaIndexField.MATCH_IPV4_SRC) != null ) {
            int ipsrc = (Integer) index.get(AthenaIndexField.MATCH_IPV4_SRC);
            if ((ipsrc & this.srcIpMask) == srcComparator) {
                return true;
            }
        }

        if (dstIpMask != 0 && index.get(AthenaIndexField.MATCH_IPV4_DST) != null) {
            int ipdst = (Integer) index.get(AthenaIndexField.MATCH_IPV4_DST);
            if ((ipdst & this.dstIpMask) == dstComparator) {
                return true;
            }
        }
        return false;
    }
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:Marking.java

示例6: checkClassificationMarkingElements

import org.bson.BSONObject; //導入依賴的package包/類
public int checkClassificationMarkingElements(BSONObject index, BSONObject feature) {
    ClassificationMarkingElement classificationMarkingElement;
    boolean check = false;
    for (int i = 1 ; i < listofClassificationMarkingElement.size() ; i++){
        classificationMarkingElement = listofClassificationMarkingElement.get(i);
        check = checkElements(index,feature,
                classificationMarkingElement.featureConstraint,
                classificationMarkingElement.getSrcIpMask(),
                classificationMarkingElement.getSrcComparator(),
                classificationMarkingElement.getDstIpMask(),
                classificationMarkingElement.getDstComparator());

        if(check){
            return classificationMarkingElement.getLabel();
        }
    }
    return 0;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:19,代碼來源:Marking.java

示例7: generateDecisionTreeWithPreprocessing

import org.bson.BSONObject; //導入依賴的package包/類
public LogisticRegressionModel generateDecisionTreeWithPreprocessing(JavaPairRDD<Object, BSONObject> mongoRDD,
                                                               AthenaMLFeatureConfiguration athenaMLFeatureConfiguration,
                                                               LogisticRegressionDetectionAlgorithm logisticRegressionDetectionAlgorithm,
                                                               Marking marking,
                                                               LogisticRegressionModelSummary logisticRegressionModelSummary) {

    return generateKMeansModel(
            rddPreProcessing(mongoRDD, athenaMLFeatureConfiguration, logisticRegressionModelSummary,
                    marking),
            logisticRegressionDetectionAlgorithm, logisticRegressionModelSummary
    );
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:LogisticRegressionDistJob.java

示例8: queryAll

import org.bson.BSONObject; //導入依賴的package包/類
/**
 * 
 * @param dbcollection
 * @return
 */
public List<BSONObject> queryAll() {
	List<BSONObject> list = new ArrayList<BSONObject>();
	DBCursor cursor = null;
	Sequoiadb sdb = DbConnectionPool.getConnection();
	try {
		cursor = getDbCollection(sdb).query();
		while (cursor.hasNext()) {
			BSONObject record = cursor.getNext();
			list.add(record);
		}
	} catch (BaseException e) {

		e.printStackTrace();
	} finally {
		DbConnectionPool.free(sdb);
	}
	return list;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:24,代碼來源:SequoiaDataAccess.java

示例9: query

import org.bson.BSONObject; //導入依賴的package包/類
/**
 * 
 * 查詢多少條數據
 * 
 * @param matcher
 * @param selector
 * @param order
 * @param skipRows
 * @param returnRows
 * @return
 */
public List<BSONObject> query(BSONObject matcher, BSONObject selector, BSONObject order, long skipRows,
		long returnRows) {
	Sequoiadb sdb = DbConnectionPool.getConnection();
	List<BSONObject> list = new ArrayList<BSONObject>();
	DBCursor cursor = null;
	try {
		cursor = getDbCollection(sdb).query(matcher, selector, order, null, skipRows, returnRows);
		while (cursor.hasNext()) {
			BSONObject record = cursor.getNext();
			list.add(record);
		}
	} catch (BaseException e) {

		e.printStackTrace();
	} finally {
		DbConnectionPool.free(sdb);
	}
	return list;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:31,代碼來源:SequoiaDataAccess.java

示例10: findAll

import org.bson.BSONObject; //導入依賴的package包/類
public List<T> findAll(BSONObject matcher, BSONObject orderBy) {
	List<T> result1 = new ArrayList<T>();
	if (matcher == null || matcher.toMap().size() == 0) {
		return result1;
	}
	try {
		List<BSONObject> result = query(matcher, null, orderBy);

		for (BSONObject bsonObject : result) {
			result1.add(bsonObject.as(entityClass));
		}
		return result1;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return result1;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:18,代碼來源:GenericDao.java

示例11: generateId

import org.bson.BSONObject; //導入依賴的package包/類
public synchronized void generateId(T obj) {
	String id = null;
	while (true) {
		BSONObject matcher = new BasicBSONObject();
		id = CommEncode.generateId();
		matcher.put(this.primaryKey, id);
		BSONObject bson = queryOne(matcher, null, null);
		if (bson == null) {
			break;
		}
	}
	try {
		Class cls = obj.getClass();
		Method method = cls.getMethod(this.getGenerateIdKeySetMethodName(), String.class);
		method.invoke(obj, id);
	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:21,代碼來源:GenericDao.java

示例12: search

import org.bson.BSONObject; //導入依賴的package包/類
public List<T> search(String key, String value, BSONObject order) {
	BSONObject arg = new BasicBSONObject();
	BSONObject regex = new BasicBSONObject();
	regex.put(MatchConst._REGEX, value);
	arg.put(key, regex);
	List<BSONObject> record = query(arg, null, null);
	List<T> result1 = new ArrayList<T>();
	for (BSONObject bsonObject : record) {
		try {
			result1.add(bsonObject.as(entityClass));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return result1;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:17,代碼來源:GenericDao.java

示例13: pushAllByPk

import org.bson.BSONObject; //導入依賴的package包/類
/**
 * 更新一個數組的字段
 *
 * @param primaryKeyValue
 * @param field
 * @param value
 * @return
 */
public <T> boolean pushAllByPk(String primaryKeyValue, String field, List<T> value) {
	BSONObject query = new BasicBSONObject();
	query.put(this.primaryKey, primaryKeyValue);
	BSONObject update = new BasicBSONObject();
	update.put(field, value);
	update.put(field, value);
	BSONObject modifier = new BasicBSONObject();
	modifier.put("$push_all", update);
	try {
		super.updateWithUserDefine(query, modifier);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
	}
	return false;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:25,代碼來源:GenericDao.java

示例14: findListByPkArray

import org.bson.BSONObject; //導入依賴的package包/類
/**
 * 取出來的值要按照主鍵ID的順序
 *
 * @param primaryKeyValues
 * @param cls
 * @return
 */
public List<T> findListByPkArray(List<String> primaryKeyValues) {
	BSONObject selector = null;
	BSONObject query = new BasicBSONObject();
	BSONObject matcher = new BasicBSONObject();
	matcher.put(MatchConst._IN, primaryKeyValues);
	query.put(this.primaryKey, matcher);
	try {
		List<BSONObject> result = query(query, selector, null);
		if (result != null && result.size() > 0) {
			return this.caseBsonsToList(result, entityClass);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return new ArrayList<>();
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:24,代碼來源:GenericDao.java

示例15: findAttributeByPk

import org.bson.BSONObject; //導入依賴的package包/類
public <V> V findAttributeByPk(String primaryKeyValue, Class<V> clazz) {
	BSONObject query = new BasicBSONObject();
	query.put(this.primaryKey, primaryKeyValue);
	BSONObject selector;
	try {
		selector = BasicBSONObject.typeToBson(clazz.newInstance());
		BSONObject bsonObejct = queryOne(query, selector, null);
		if (bsonObejct != null) {
			return bsonObejct.as(clazz);
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	return null;
}
 
開發者ID:slowlizard,項目名稱:SequoiaDB-ORM,代碼行數:18,代碼來源:GenericDao.java


注:本文中的org.bson.BSONObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。