当前位置: 首页>>代码示例>>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;未经允许,请勿转载。