private RequestOptions getRequestOptions(PartitionKey key, Integer requestUnit) { if (key == null && requestUnit == null) { return null; } final RequestOptions requestOptions = new RequestOptions(); if (key != null) { requestOptions.setPartitionKey(key); } if (requestUnit != null) { requestOptions.setOfferThroughput(requestUnit); } return requestOptions; }
private RequestOptions getRequestOptions(PartitionKey key, Integer requestUnit) { if (key == null && requestUnit == null) { return null; } final RequestOptions requestOptions = new RequestOptions(); if (key != null) { requestOptions.setPartitionKey(key); } if (requestUnit != null) { requestOptions.setOfferThroughput(requestUnit); } return requestOptions; }
private DocumentCollection createCollectionIfNotExists(String dbName, String collectionName) { if (this.databaseCache == null) { this.databaseCache = createDatabaseIfNotExists(dbName); } final List<DocumentCollection> collectionList = documentDbFactory.getDocumentClient() .queryCollections(getDatabaseLink(dbName), new SqlQuerySpec("SELECT * FROM root r WHERE r.id=@id", new SqlParameterCollection(new SqlParameter("@id", collectionName))), null) .getQueryIterable().toList(); if (!collectionList.isEmpty()) { return collectionList.get(0); } else { final RequestOptions requestOptions = new RequestOptions(); requestOptions.setOfferThroughput(1000); return createCollection(dbName, collectionName, requestOptions); } }