当前位置: 首页>>代码示例>>Java>>正文


Java BsonTypeClassMap类代码示例

本文整理汇总了Java中org.bson.codecs.BsonTypeClassMap的典型用法代码示例。如果您正苦于以下问题:Java BsonTypeClassMap类的具体用法?Java BsonTypeClassMap怎么用?Java BsonTypeClassMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BsonTypeClassMap类属于org.bson.codecs包,在下文中一共展示了BsonTypeClassMap类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScanStats

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
@Override
public ScanStats getScanStats() {
  try{
    MongoClient client = storagePlugin.getClient();
    MongoDatabase db = client.getDatabase(scanSpec.getDbName());
    MongoCollection<Document> collection = db.getCollection(scanSpec.getCollectionName());
    long numDocs = collection.count();
    float approxDiskCost = 0;
    if (numDocs != 0) {
      //toJson should use client's codec, otherwise toJson could fail on
      // some types not known to DocumentCodec, e.g. DBRef.
      final DocumentCodec codec =
          new DocumentCodec(client.getMongoClientOptions().getCodecRegistry(), new BsonTypeClassMap());
      String json = collection.find().first().toJson(codec);
      approxDiskCost = json.getBytes().length * numDocs;
    }
    return new ScanStats(GroupScanProperty.EXACT_ROW_COUNT, numDocs, 1, approxDiskCost);
  } catch (Exception e) {
    throw new DrillRuntimeException(e.getMessage(), e);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:MongoGroupScan.java

示例2: addEncodeStatements

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
@Override
public void addEncodeStatements(TypeMirror type, CodeGeneratorContext ctx) {
	ctx.builder()
			.addStatement("Codec codec = this.registry.get($L.getClass())",
					ctx.getter())
			.addStatement("encoderContext.encodeWithChildContext(codec, writer, $L)",
					ctx.getter());

	// ctx.builder()
	// .addAnnotation(AnnotationSpec.builder(SuppressWarnings.class)
	// .addMember("value", "$S", "unchecked")
	// .addMember("value", "$S", "rawtypes").build());

	ctx.instanceFields().add(ImmutableInstanceField.builder()
			.type(ClassName.get(CodecRegistry.class)).name("registry").build());

	ctx.instanceFields()
			.add(ImmutableInstanceField.builder()
					.type(ClassName.get(BsonTypeClassMap.class))
					.name("bsonTypeClassMap").build());

}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:23,代码来源:UnknownCodecDelegate.java

示例3: getEncoder

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
/**
 * Customizations for the document.toJson output.
 * <p>
 * http://mongodb.github.io/mongo-java-driver/3.0/bson/codecs/
 *
 * @return the toJson encoder.
 */
private Encoder<Document> getEncoder() {
    ArrayList<Codec<?>> codecs = new ArrayList<>();

    if (config.getElastic().getDateFormat() != null) {
        // Replace default DateCodec class to use the custom date formatter.
        codecs.add(new CustomDateCodec(config.getElastic().getDateFormat()));
    }

    if (config.getElastic().getLongToString()) {
        // Replace default LongCodec class
        codecs.add(new CustomLongCodec());
    }

    if (codecs.size() > 0) {
        BsonTypeClassMap bsonTypeClassMap = new BsonTypeClassMap();

        CodecRegistry codecRegistry = CodecRegistries.fromRegistries(
                CodecRegistries.fromCodecs(codecs),
                MongoClient.getDefaultCodecRegistry());

        return new DocumentCodec(codecRegistry, bsonTypeClassMap);
    } else {
        return new DocumentCodec();
    }
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:33,代码来源:ElasticBulkService.java

示例4: get

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
synchronized public static DefaultReader get(CodecRegistry registry) {
	synchronized (lock) {
		if (instance == null) {
			instance = new DefaultReader(registry, new BsonTypeClassMap());
		} else {
			instance.registry.set(registry);
		}
	}
	return instance;
}
 
开发者ID:guicamest,项目名称:bsoneer,代码行数:11,代码来源:DefaultReader.java

示例5: registerCustomizedBsonTypeClassMap

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
public static void registerCustomizedBsonTypeClassMap(BsonTypeClassMap bsonTypeClassMap) {
    Utils.checkNotNull(bsonTypeClassMap, "bsonTypeClassMap should not be null!");
    BSON_TYPE_CLASS_MAP = bsonTypeClassMap;
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:5,代码来源:BsonValueConverterRepertory.java

示例6: DefaultReader

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
private DefaultReader(CodecRegistry registry) {
	this(registry, new BsonTypeClassMap());
}
 
开发者ID:guicamest,项目名称:bsoneer,代码行数:4,代码来源:DefaultReader.java

示例7: ArrayCodec

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
public ArrayCodec( CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap )
{
    listCodec = new ListCodec( registry, bsonTypeClassMap );
}
 
开发者ID:cherimojava,项目名称:cherimodata,代码行数:5,代码来源:ArrayCodec.java

示例8: ListCodec

import org.bson.codecs.BsonTypeClassMap; //导入依赖的package包/类
/**
 * Creates a new {@code ListCodec}, which will use the given {@code CodecRegistry} and {@code BsonTypeClassMap} for
 * encoding and decoding the values in the List.
 *
 * @param registry contains the codecs required to encode and decode {@code List} values
 * @param bsonTypeClassMap will be used for decoding BSON values into the List.
 */
public ListCodec( final CodecRegistry registry, final BsonTypeClassMap bsonTypeClassMap )
{
    this.registry = registry;
    this.bsonTypeClassMap = bsonTypeClassMap;
}
 
开发者ID:cherimojava,项目名称:cherimodata,代码行数:13,代码来源:ListCodec.java


注:本文中的org.bson.codecs.BsonTypeClassMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。