本文整理汇总了Java中org.bson.Document.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getLong方法的具体用法?Java Document.getLong怎么用?Java Document.getLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.getLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServiceCountByOperatorId
import org.bson.Document; //导入方法依赖的package包/类
/**
* 根据Operator订购的服务类型来查询可用数量(未过期的)
*
* @param serviceType service type
* @param operatorId operator ID
* @return number of service
*/
public long getServiceCountByOperatorId(Integer serviceType, ObjectId operatorId) {
long count = 0;
Document query = new Document();
query.append("user_id", operatorId);
query.append("serviceType", serviceType);
query.append("expired_at", new Document("$gte", new Date()));
FindIterable<Document> ds = this.database.getCollection("user_services").find(query);
if (ds != null) {
for (Document d : ds) {
if (d.getLong("used") != null) {
count += d.getLong("count") - d.getLong("used");
} else {
count += d.getLong("count");
}
}
}
return count;
}
示例2: getFeatreFromRowInternal
import org.bson.Document; //导入方法依赖的package包/类
public Object getFeatreFromRowInternal(Document row, String feature, String type) {
if (type.startsWith(athenaFeatureField.varintType)) {
return row.getInteger(feature);
} else if (type.startsWith(athenaFeatureField.bigintType)) {
Long l = row.getLong(feature);
return l;
} else if (type.startsWith(athenaFeatureField.doubleType)) {
Double d = row.getDouble(feature);
return d;
} else if (type.startsWith(athenaFeatureField.timestampType)) {
return row.getDate(feature);
} else {
log.warn("[getFeatreFromRowInternal] Not supported type :{}", type);
return null;
}
}