BasicDBObject dbo = new BasicDBObject(); dbo.put("name", "first"); collection.insert(dbo); dbo.put("_id", null); dbo.put("name", "second"); dbo.put("otherInfo", new BasicDBObject("text", "sometext")); collection.insert(dbo); DBObject query = new BasicDBObject("otherInfo.text", new BasicDBObject("$exists", true)); DBCursor result = collection.find(query); System.out.println(result.size()); System.out.println(result.iterator().next());
@Override public int getResultCount() { return resultSet.size(); } });
@Override public int size() { return cursor.size(); }
@Override public int size() { return cursor.size(); }
/** * Runs underlying query to count the number of matching records. * This does not take query limit/skip into consideration * * @see DBCursor#size() */ @Override public int size() { return iterator.dbCursor.size(); }
/** * Save the reference to the cursor that holds the actual results. * * @param cursor * {@link DBCursor} obtained from a query execution and that holds * the actual results */ public void setCursor(DBCursor cursor) { this.cursor = cursor; this.size = cursor.size(); }
public String getLemma(String word) { criteria.set(0, word); DBObject lemmaObj = QueryBuilder.start("declensions").in(criteria).get(); DBCursor cursor = declColl.find(lemmaObj); if(cursor == null) return null; if(cursor.size() > 1) return null; if(cursor.size() == 0) return null; return (String) cursor.next().get("lemma"); }
/** * Counts the number of objects matching the query * this does take limit/skip into consideration * * @return the number of objects * @throws MongoException * @see #count() */ public int size() { executed(); return cursor.size(); }
/** * Counts the number of objects matching the query * this does take limit/skip into consideration * * @return the number of objects * @throws MongoException * @see #count() */ public int size() { executed(); return cursor.size(); }
/** * Counts the number of objects matching the query this does take limit/skip * into consideration * * @return the number of objects * @throws MongoException * @see #count() */ public int size() { executed(); return cursor.size(); }
@Override public Map<String, Long> streamRuleCountByStream() { final DBCursor streamIds = collection(StreamImpl.class).find(new BasicDBObject(), new BasicDBObject("_id", 1)); final Map<String, Long> streamRules = new HashMap<>(streamIds.size()); for (DBObject keys : streamIds) { final ObjectId streamId = (ObjectId) keys.get("_id"); streamRules.put(streamId.toHexString(), streamRuleCount(streamId)); } return streamRules; }
private boolean resultNotEmpty(final DBObject query, final String indexName) { try { DBCursor cursor = getCollection().find(query).limit(1); if(ensureIndex && !isEmpty(indexName)) cursor.hint(indexName); return cursor.size() > 0; } catch (MongoException mongoException) { LOG.error("Got error {} with query: {} using hint: {}", mongoException.getMessage(), query, indexName); throw mongoException; } }
public int count(DBObject query) throws CompatibilityDataException { MongoClient client = null; try { client = getService().createClient(); return client.getDB(database).getCollection(collection).find(query).sort(new BasicDBObject("registrationDate", 1)).size(); } catch (Exception ex) { throw new CompatibilityDataException(String.format("(Unknown Host) Failed to fetch object with query %s", query ), ex); } finally { if(client != null) client.close(); } }
LOGGER.debug("Result set sorted"); int size = cursor.size(); long ret = size; LOGGER.debug("Applying limits: {} - {}", from, to);
log.info("Loading {} virtual networks from database", cursor.size()); while (cursor.hasNext()) { OVXNetworkManager mngr = null;
new BasicDBObject(TableColumns.JOBNAME, jobName), keys); if (cursor.size() == 0) { throw BatchMessages.MESSAGES.noSuchJobException(jobName);
List<T> result = new ArrayList<T>(resultSet.size()); while (resultSet.hasNext()) { result.add((T) helper.toResult(field, resultSet.next()));
@Override public void removeBuildfailurecause(Run build) { BasicDBObject searchObj = new BasicDBObject(); searchObj.put("projectName", build.getParent().getFullName()); searchObj.put("buildNumber", build.getNumber()); searchObj.put("master", BfaUtils.getMasterName()); com.mongodb.DBCursor dbcursor = getStatisticsCollection().find(searchObj); if (dbcursor.size() > 0) { while (dbcursor.hasNext()) { getStatisticsCollection().remove(dbcursor.next()); logger.log(Level.INFO, build.getDisplayName() + " build failure cause removed"); } } else { logger.log(Level.INFO, build.getDisplayName() + " build failure cause " + "value is null or initial scanning "); } }
@Override public boolean deleteDocumentFile(DatabaseDocument<MongoType> d, String fileName) { MongoDocument md = (MongoDocument) d; DBObject query = QueryBuilder.start(DOCUMENT_KEY).is(md.getID().getID()).and(FILENAME_KEY).is(fileName).get(); if (documentfs.getFileList(query).size() != 1) { return false; } documentfs.remove(query); return true; }
private void awaitUntilMessageIsPersisted(DBObject query) throws Exception { await().atMost(ONE_SECOND).until(() -> { DBCursor cursor = database.getCollection(COLLECTION_PUBLISHED_NAME).find(query); return cursor.size() == 1; }); }