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


Java Bson.toBsonDocument方法代碼示例

本文整理匯總了Java中org.bson.conversions.Bson.toBsonDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java Bson.toBsonDocument方法的具體用法?Java Bson.toBsonDocument怎麽用?Java Bson.toBsonDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bson.conversions.Bson的用法示例。


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

示例1: parse

import org.bson.conversions.Bson; //導入方法依賴的package包/類
private BsonDocument parse(String where) {
  Bson bson = sqlParser.get(Bson.class, where);

  return bson.toBsonDocument(
      BsonDocument.class,
      CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:8,代碼來源:MongoWhereClauseListenerTest.java

示例2: toBsonDocument

import org.bson.conversions.Bson; //導入方法依賴的package包/類
private BsonDocument toBsonDocument(Bson bson) {
  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:5,代碼來源:SelectClauseParserTest.java

示例3: toBsonDocument

import org.bson.conversions.Bson; //導入方法依賴的package包/類
private BsonDocument toBsonDocument(Bson bson) {
  return bson.toBsonDocument(
      BsonDocument.class,
      CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:6,代碼來源:WhereClauseParserTest.java

示例4: parse

import org.bson.conversions.Bson; //導入方法依賴的package包/類
private BsonDocument parse(String select) {
  Bson bson = sqlParser.get(Bson.class, select);

  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:7,代碼來源:MongoSelectClauseListenerTest.java

示例5: parse

import org.bson.conversions.Bson; //導入方法依賴的package包/類
private BsonDocument parse(String orderBy) {
  Bson bson = sqlParser.get(Bson.class, orderBy);

  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
開發者ID:glytching,項目名稱:dragoman,代碼行數:7,代碼來源:MongoOrderByClauseListenerTest.java

示例6: getqueryFromRequestOperatorComparison

import org.bson.conversions.Bson; //導入方法依賴的package包/類
public String getqueryFromRequestOperatorComparison(FeatureConstraint featureConstraint) {

        FeatureConstraintType featureConstraintType =
                featureConstraint.getFeatureConstraintType();
        FeatureConstraintOperator featureConstraintOperator = featureConstraint.getFeatureConstraintOperator();
        AthenaField name = featureConstraint.getFeatureName();
        List<TargetAthenaValue> value = featureConstraint.getDataRequestObjectValueList();

        Bson obj = null;

        String target = null;
        if (featureConstraintType == FeatureConstraintType.FEATURE) {
            target = AthenaFeatureField.FEATURE + "." + name.getValue();
        } else if (featureConstraintType == FeatureConstraintType.INDEX) {
            target = name.getValue();

        } else {
            log.warn("not supported type :{}", featureConstraintType.toString());
            return null;
        }


        if (!(value.size() > 0)) {
            log.warn("list size is not bigger than 0 :{}", value.size());
            return null;
        }

        for (int i = 0; i < value.size(); i++) {
            switch (featureConstraintOperator.getValue()) {
                case FeatureConstraintOperator.COMPARISON_EQ:
                    obj = eq(target, value.get(i).getTargetAthenaValue());
                    break;
                case FeatureConstraintOperator.COMPARISON_GT:
                    obj = gt(target, value.get(i).getTargetAthenaValue());
                    break;
                case FeatureConstraintOperator.COMPARISON_GTE:
                    obj = gte(target, value.get(i).getTargetAthenaValue());
                    break;
                case FeatureConstraintOperator.COMPARISON_LT:
                    obj = lt(target, value.get(i).getTargetAthenaValue());
                    break;
                case FeatureConstraintOperator.COMPARISON_LTE:
                    obj = lte(target, value.get(i).getTargetAthenaValue());
                    break;
                case FeatureConstraintOperator.COMPARISON_NE:
                    obj = ne(target, value.get(i).getTargetAthenaValue());
                    break;
                default:
                    log.warn("not supported comparsion type");
                    return null;
            }
        }

        BsonDocument matchQueryDocument =
                obj.toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry());

        String modifiedQuery = matchQueryDocument.toString();

        if (Objects.equals(featureConstraintOperator.getValue(), FeatureConstraintOperator.COMPARISON_EQ)) {
            String[] splited = modifiedQuery.split(":");
            modifiedQuery = splited[0] + ": { \"$eq\" :" + splited[1] + ":" + splited[2] + " }";
        }


        return modifiedQuery;
    }
 
開發者ID:shlee89,項目名稱:athena,代碼行數:67,代碼來源:MachineLearningManagerImpl.java


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