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


Java MapReduceCommand.setFinalize方法代码示例

本文整理汇总了Java中com.mongodb.MapReduceCommand.setFinalize方法的典型用法代码示例。如果您正苦于以下问题:Java MapReduceCommand.setFinalize方法的具体用法?Java MapReduceCommand.setFinalize怎么用?Java MapReduceCommand.setFinalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.MapReduceCommand的用法示例。


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

示例1: mapReduce

import com.mongodb.MapReduceCommand; //导入方法依赖的package包/类
/**
 * runs a map-reduce-job on the collection. The functions are read from the classpath in the folder mongodb. The systems reads them from
 * files called <name>.map.js, <name>.reduce.js and optionally <name>.finalize.js. After this the result is converted
 * using the given {@link MapReduceResultHandler}
 * 
 * @param <R> the type of the result class
 * @param name the name of the map-reduce functions
 * @param query the query to filter the elements used for the map-reduce
 * @param sort sort query to sort elements before running map-reduce
 * @param scope the global scope for the JavaScript run
 * @param conv the converter to convert the result
 * @return an {@link Iterable} with the result entries
 * @throws RuntimeException if resources cannot be read
 */
protected final <R> Iterable<R> mapReduce(String name, DBObject query, DBObject sort, Map<String, Object> scope, final MapReduceResultHandler<R> conv) {
	String map = this.getMRFunction(name, "map");
	String reduce = this.getMRFunction(name, "reduce");
	
	MapReduceCommand mrc = new MapReduceCommand(this.collection.getDBCollection(), map, reduce, null, OutputType.INLINE, query);
	String finalizeFunction = this.getMRFunction(name, "finalize");
	if (finalizeFunction != null) {
		mrc.setFinalize(finalizeFunction);
	}
	if (sort != null) {
		mrc.setSort(sort);
	}
	if (scope != null) {
		mrc.setScope(scope);
	}
	MapReduceOutput mr = this.collection.getDBCollection().mapReduce(mrc);
	return new ConverterIterable<R>(mr.results().iterator(), conv);
}
 
开发者ID:taimos,项目名称:spring-dao-mongo,代码行数:33,代码来源:AbstractMongoDAO.java

示例2: toCommand

import com.mongodb.MapReduceCommand; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
MapReduceCommand toCommand(final Mapper mapper) {
    if (query.getOffset() != 0 || query.getFieldsObject() != null) {
        throw new QueryException("mapReduce does not allow the offset/retrievedFields query ");
    }

    final DBCollection dbColl = inputCollection != null ? getQuery().getCollection().getDB().getCollection(inputCollection)
                                                        : query.getCollection();
    final String target = outputCollection != null ? outputCollection : mapper.getMappedClass(resultType).getCollectionName();

    final MapReduceCommand command = new MapReduceCommand(dbColl, map, reduce, target, outputType, query.getQueryObject());
    command.setBypassDocumentValidation(bypassDocumentValidation);
    command.setCollation(collation);
    command.setFinalize(finalize);
    command.setJsMode(jsMode);
    command.setLimit(limit);
    command.setMaxTime(maxTimeMS, TimeUnit.MILLISECONDS);
    command.setOutputDB(outputDB);
    command.setReadPreference(readPreference);
    command.setScope(scope);
    command.setSort(query.getSortObject());
    command.setVerbose(verbose);

    return command;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:26,代码来源:MapReduceOptions.java

示例3: mapReduce

import com.mongodb.MapReduceCommand; //导入方法依赖的package包/类
@Override
@Deprecated
public <T> MapreduceResults<T> mapReduce(final MapreduceType type, final Query query, final String map, final String reduce,
                                         final String finalize, final Map<String, Object> scopeFields, final Class<T> outputType) {

    final DBCollection dbColl = query.getCollection();

    final String outColl = mapper.getCollectionName(outputType);

    final MapReduceCommand cmd = new MapReduceCommand(dbColl, map, reduce, outColl, type.toOutputType(), query.getQueryObject());

    if (query.getLimit() > 0) {
        cmd.setLimit(query.getLimit());
    }
    if (query.getSortObject() != null) {
        cmd.setSort(query.getSortObject());
    }

    if (finalize != null && finalize.length() != 0) {
        cmd.setFinalize(finalize);
    }

    if (scopeFields != null && !scopeFields.isEmpty()) {
        cmd.setScope(scopeFields);
    }

    return mapReduce(type, query, outputType, cmd);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:29,代码来源:DatastoreImpl.java


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