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


Java FindIterable.batchSize方法代碼示例

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


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

示例1: collectVectors

import com.mongodb.client.FindIterable; //導入方法依賴的package包/類
@Override
protected void collectVectors(Collection<String> terms, int limit) {
    Set<String> toFetch = terms.stream()
            .filter(t -> !this.vectorsCache.containsKey(t))
            .collect(Collectors.toSet());

    logger.debug("Cache has {} vectors, need to fetch more {}",
            terms.size() - toFetch.size(), toFetch.size());

    if (!toFetch.isEmpty()) {
        logger.info("Collecting {} term vectors from {}", toFetch.size(), dbName);
        FindIterable<Document> docs = getTermsColl().find(Filters.in(TERM_FIELD_NAME, toFetch));
        if (docs != null) {
            docs.batchSize(toFetch.size());
            for (Document doc : docs) {
                this.vectorsCache.put(doc.getString(TERM_FIELD_NAME), unmarshall(doc, limit));
            }
        }
    }
}
 
開發者ID:Lambda-3,項目名稱:Indra,代碼行數:21,代碼來源:MongoVectorSpace.java

示例2: processData

import com.mongodb.client.FindIterable; //導入方法依賴的package包/類
public void processData() {
    MongoCollection<Document> collection = this.database.getCollection("channels");
    logger.info("There are " + String.valueOf(collection.count()) + " channels!");

    FindIterable<Document> iterable = collection.find();
    iterable.batchSize(this.opts.getBatchSize());

    MongoCursor<Document> cursor = iterable.iterator();

    this.processor.run(cursor);
    cursor.close();
}
 
開發者ID:korobi,項目名稱:ElasticMangos,代碼行數:13,代碼來源:MongoChannelRetriever.java

示例3: runnerUpdate

import com.mongodb.client.FindIterable; //導入方法依賴的package包/類
private void runnerUpdate(FindIterable<Document> iterable)
		throws SearchLibException, ClassNotFoundException, InstantiationException, IllegalAccessException,
		IOException, ParseException, SyntaxError, URISyntaxException, InterruptedException {
	final int limit = databaseCrawl.getBufferSize();
	iterable.batchSize(limit);
	final RestFieldMap fieldMap = (RestFieldMap) databaseCrawl.getFieldMap();
	List<IndexDocument> indexDocumentList = new ArrayList<IndexDocument>(0);
	LanguageEnum lang = databaseCrawl.getLang();
	FieldMapContext fieldMapContext = new FieldMapContext(client, lang);
	String uniqueField = client.getSchema().getUniqueField();
	MongoCursor<Document> cursor = iterable.iterator();
	while (cursor.hasNext() && !isAborted()) {

		String json = JSON.serialize(cursor.next());
		Object document = Configuration.defaultConfiguration().jsonProvider().parse(json);
		IndexDocument indexDocument = new IndexDocument(lang);
		fieldMap.mapJson(fieldMapContext, document, indexDocument);
		if (uniqueField != null && !indexDocument.hasContent(uniqueField)) {
			rwl.w.lock();
			try {
				ignoredDocumentCount++;
			} finally {
				rwl.w.unlock();
			}
			continue;
		}
		indexDocumentList.add(indexDocument);
		rwl.w.lock();
		try {
			pendingIndexDocumentCount++;
		} finally {
			rwl.w.unlock();
		}
		if (index(indexDocumentList, limit))
			setStatus(CrawlStatus.CRAWL);

	}
	index(indexDocumentList, 0);
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:40,代碼來源:DatabaseCrawlMongoDbThread.java

示例4: createDoFindAll

import com.mongodb.client.FindIterable; //導入方法依賴的package包/類
private Function<Exchange, Object> createDoFindAll() {
    return exchange1 -> {
        Iterable<BasicDBObject> result;
        MongoCollection<BasicDBObject> dbCol = calculateCollection(exchange1);
        // do not use getMandatoryBody, because if the body is empty we want to retrieve all objects in the collection
        BasicDBObject query = null;
        // do not run around looking for a type converter unless there is a need for it
        if (exchange1.getIn().getBody() != null) {
            query = exchange1.getIn().getBody(BasicDBObject.class);
        }
        BasicDBObject fieldFilter = exchange1.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, BasicDBObject.class);

        // get the batch size and number to skip
        Integer batchSize = exchange1.getIn().getHeader(MongoDbConstants.BATCH_SIZE, Integer.class);
        Integer numToSkip = exchange1.getIn().getHeader(MongoDbConstants.NUM_TO_SKIP, Integer.class);
        Integer limit = exchange1.getIn().getHeader(MongoDbConstants.LIMIT, Integer.class);
        BasicDBObject sortBy = exchange1.getIn().getHeader(MongoDbConstants.SORT_BY, BasicDBObject.class);
        FindIterable<BasicDBObject> ret;
        if (query == null && fieldFilter == null) {
            ret = dbCol.find(new BasicDBObject());
        } else if (fieldFilter == null) {
            ret = dbCol.find(query);
        } else {
            ret = dbCol.find(new BasicDBObject()).projection(fieldFilter);
        }

        if (sortBy != null) {
            ret.sort(sortBy);
        }

        if (batchSize != null) {
            ret.batchSize(batchSize);
        }

        if (numToSkip != null) {
            ret.skip(numToSkip);
        }

        if (limit != null) {
            ret.limit(limit);
        }

        if (!MongoDbOutputType.DBCursor.equals(endpoint.getOutputType())) {
            try {
                result = new ArrayList<>();
                ret.iterator().forEachRemaining(((List<BasicDBObject>) result)::add);
                exchange1.getOut().setHeader(MongoDbConstants.RESULT_PAGE_SIZE, ((List<BasicDBObject>) result).size());
            } finally {
                ret.iterator().close();
            }
        } else {
            result = ret;
        }
        return result;
    };
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:57,代碼來源:MongoDbProducer.java


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