Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Licensed under the MIT License.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.microsoft.azure</groupId>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos-parent</artifactId>
<version>3.3.0</version>
<version>4.0.0-preview.4</version>
</parent>

<groupId>com.microsoft.azure</groupId>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos-benchmark</artifactId>
<version>3.3.0</version>
<version>4.0.0-preview.4</version>
<name>Microsoft Azure SDK for SQL API of Azure Cosmos DB Service - Benchmarking tool</name>
<description>This package contains Benchmarking tool for Microsoft Azure SDK for SQL API of Azure Cosmos DB Service</description>
<url>https://github.com/Azure/azure-sdk-for-java</url>
Expand All @@ -31,9 +31,9 @@ Licensed under the MIT License.

<dependencies>
<dependency>
<groupId>com.microsoft.azure</groupId>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
<version>3.3.0</version>
<version>4.0.0-preview.4</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ abstract class AsyncBenchmark<T> {
logger = LoggerFactory.getLogger(this.getClass());

Database database = DocDBUtils.getDatabase(client, cfg.getDatabaseId());
collection = DocDBUtils.getCollection(client, database.selfLink(), cfg.getCollectionId());
nameCollectionLink = String.format("dbs/%s/colls/%s", database.id(), collection.id());
partitionKey = collection.getPartitionKey().paths().iterator().next().split("/")[1];
collection = DocDBUtils.getCollection(client, database.getSelfLink(), cfg.getCollectionId());
nameCollectionLink = String.format("dbs/%s/colls/%s", database.getId(), collection.getId());
partitionKey = collection.getPartitionKey().getPaths().iterator().next().split("/")[1];
concurrencyControlSemaphore = new Semaphore(cfg.getConcurrency());
configuration = cfg;

Expand All @@ -81,14 +81,14 @@ abstract class AsyncBenchmark<T> {
for (int i = 0; i < cfg.getNumberOfPreCreatedDocuments(); i++) {
String uuid = UUID.randomUUID().toString();
Document newDoc = new Document();
newDoc.id(uuid);
newDoc.setId(uuid);
BridgeInternal.setProperty(newDoc, partitionKey, uuid);
BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField3", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField4", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField5", dataFieldValue);
Flux<Document> obs = client.createDocument(collection.selfLink(), newDoc, null, false)
Flux<Document> obs = client.createDocument(collection.getSelfLink(), newDoc, null, false)
.map(ResourceResponse::getResource);
createDocumentObservables.add(obs);
}
Expand Down Expand Up @@ -146,15 +146,15 @@ protected String getCollectionLink() {
if (configuration.isUseNameLink()) {
return this.nameCollectionLink;
} else {
return collection.selfLink();
return collection.getSelfLink();
}
}

protected String getDocumentLink(Document doc) {
if (configuration.isUseNameLink()) {
return this.nameCollectionLink + "/docs/" + doc.id();
return this.nameCollectionLink + "/docs/" + doc.getId();
} else {
return doc.selfLink();
return doc.getSelfLink();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void performWorkload(BaseSubscriber<Document> documentBaseSubscriber,

String idString = uuid + i;
Document newDoc = new Document();
newDoc.id(idString);
newDoc.setId(idString);
BridgeInternal.setProperty(newDoc, partitionKey, idString);
BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue);
Expand All @@ -50,17 +50,17 @@ protected void performWorkload(BaseSubscriber<Document> documentBaseSubscriber,

FeedOptions options = new FeedOptions();
options.maxItemCount(10);
options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);

String sqlQuery = "Select top 100 * from c order by c._ts";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options)
.map(frp -> frp.results().get(0));
.map(frp -> frp.getResults().get(0));
} else {

int index = r.nextInt(1000);

RequestOptions options = new RequestOptions();
options.setPartitionKey(new PartitionKey(docsToRead.get(index).id()));
options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId()));

obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options).map(ResourceResponse::getResource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscr
if (configuration.getOperationType() == Configuration.Operation.QueryCross) {

int index = r.nextInt(1000);
options.enableCrossPartitionQuery(true);
String sqlQuery = "Select * from c where c._rid = \"" + docsToRead.get(index).resourceId() + "\"";
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select * from c where c._rid = \"" + docsToRead.get(index).getResourceId() + "\"";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else if (configuration.getOperationType() == Configuration.Operation.QuerySingle) {

Expand All @@ -55,29 +55,29 @@ protected void performWorkload(BaseSubscriber<FeedResponse<Document>> baseSubscr
} else if (configuration.getOperationType() == Configuration.Operation.QueryParallel) {

options.maxItemCount(10);
options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select * from c";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else if (configuration.getOperationType() == Configuration.Operation.QueryOrderby) {

options.maxItemCount(10);
options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select * from c order by c._ts";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else if (configuration.getOperationType() == Configuration.Operation.QueryAggregate) {

options.maxItemCount(10);
options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select value max(c._ts) from c";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else if (configuration.getOperationType() == Configuration.Operation.QueryAggregateTopOrderby) {

options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select top 1 value count(c) from c order by c._ts";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else if (configuration.getOperationType() == Configuration.Operation.QueryTopOrderby) {

options.enableCrossPartitionQuery(true);
options.setEnableCrossPartitionQuery(true);
String sqlQuery = "Select top 1000 * from c order by c._ts";
obs = client.queryDocuments(getCollectionLink(), sqlQuery, options);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void hookOnError(Throwable throwable) {
protected void performWorkload(BaseSubscriber<ResourceResponse<Document>> baseSubscriber, long i) throws InterruptedException {
int index = (int) (i % docsToRead.size());
RequestOptions options = new RequestOptions();
options.setPartitionKey(new PartitionKey(docsToRead.get(index).id()));
options.setPartitionKey(new PartitionKey(docsToRead.get(index).getId()));

Flux<ResourceResponse<Document>> obs = client.readDocument(getDocumentLink(docsToRead.get(index)), options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected void performWorkload(BaseSubscriber<ResourceResponse<Document>> baseSu

String idString = uuid + i;
Document newDoc = new Document();
newDoc.id(idString);
newDoc.setId(idString);
BridgeInternal.setProperty(newDoc, partitionKey, idString);
BridgeInternal.setProperty(newDoc, "dataField1", dataFieldValue);
BridgeInternal.setProperty(newDoc, "dataField2", dataFieldValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ int getDocumentDataFieldSize() {

ConnectionPolicy getConnectionPolicy() {
ConnectionPolicy policy = new ConnectionPolicy();
policy.connectionMode(connectionMode);
policy.maxPoolSize(maxConnectionPoolSize);
policy.setConnectionMode(connectionMode);
policy.setMaxPoolSize(maxConnectionPoolSize);
return policy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ static Database getDatabase(AsyncDocumentClient client, String databaseId) {
new SqlParameterList(new SqlParameter("@id", databaseId))), null)
.single().block();

if (feedResponsePages.results().isEmpty()) {
if (feedResponsePages.getResults().isEmpty()) {
throw new RuntimeException("cannot find datatbase " + databaseId);
}
return feedResponsePages.results().get(0);
return feedResponsePages.getResults().get(0);
}

static DocumentCollection getCollection(AsyncDocumentClient client, String databaseLink,
Expand All @@ -37,9 +37,9 @@ static DocumentCollection getCollection(AsyncDocumentClient client, String datab
null)
.single().block();

if (feedResponsePages.results().isEmpty()) {
if (feedResponsePages.getResults().isEmpty()) {
throw new RuntimeException("cannot find collection " + collectionId);
}
return feedResponsePages.results().get(0);
return feedResponsePages.getResults().get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private Flux<Document> writeDocument(Integer i) {
String idString = Utils.randomUUID().toString();
String randomVal = Utils.randomUUID().toString();
Document document = new Document();
document.id(idString);
document.setId(idString);
BridgeInternal.setProperty(document, partitionKey, idString);
BridgeInternal.setProperty(document, QUERY_FIELD_NAME, randomVal);
BridgeInternal.setProperty(document, "dataField1", randomVal);
Expand Down Expand Up @@ -217,11 +217,11 @@ private SqlQuerySpec generateRandomQuery() {
*/
private Flux<Document> xPartitionQuery(SqlQuerySpec query) {
FeedOptions options = new FeedOptions();
options.maxDegreeOfParallelism(-1);
options.enableCrossPartitionQuery(true);
options.setMaxDegreeOfParallelism(-1);
options.setEnableCrossPartitionQuery(true);

return client.queryDocuments(getCollectionLink(), query, options)
.flatMap(p -> Flux.fromIterable(p.results()));
.flatMap(p -> Flux.fromIterable(p.getResults()));
}

/**
Expand All @@ -239,7 +239,7 @@ private Flux<Document> singlePartitionQuery(Document d) {
QUERY_FIELD_NAME,
d.getString(QUERY_FIELD_NAME)));
return client.queryDocuments(getCollectionLink(), sqlQuerySpec, options)
.flatMap(p -> Flux.fromIterable(p.results()));
.flatMap(p -> Flux.fromIterable(p.getResults()));
}

/**
Expand Down Expand Up @@ -348,7 +348,7 @@ static InWhereClause asInWhereClause(String fieldName, List<Document> documentLi
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(fieldName);
stringBuilder.append(" IN (");
List<String> params = parameters.stream().map(SqlParameter::name).collect(Collectors.toList());
List<String> params = parameters.stream().map(SqlParameter::getName).collect(Collectors.toList());
stringBuilder.append(String.join(", ", params));
stringBuilder.append(")");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ public class QueryBuilderTest {
@Test(groups = {"unit"})
public void basic() {
ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
assertThat(queryBuilder.toSqlQuerySpec().queryText())
assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
.isEqualTo("SELECT * FROM root");
}

@Test(groups = {"unit"})
public void top() {
ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
queryBuilder.top(50);
assertThat(queryBuilder.toSqlQuerySpec().queryText())
assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
.isEqualTo("SELECT TOP 50 * FROM root");
}

@Test(groups = {"unit"})
public void orderBy() {
ReadMyWriteWorkflow.QueryBuilder queryBuilder = new ReadMyWriteWorkflow.QueryBuilder();
queryBuilder.orderBy("prop");
assertThat(queryBuilder.toSqlQuerySpec().queryText())
assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
.isEqualTo("SELECT * FROM root ORDER BY root.prop");
}

Expand All @@ -42,9 +42,9 @@ public void whereInClause() {
new SqlParameter("@param2", 2));
queryBuilder.whereClause(new ReadMyWriteWorkflow.QueryBuilder.WhereClause.InWhereClause("colName",
parameters));
assertThat(queryBuilder.toSqlQuerySpec().queryText())
assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
.isEqualTo("SELECT * FROM root WHERE root.colName IN (@param1, @param2)");
assertThat(queryBuilder.toSqlQuerySpec().parameters()).containsExactlyElementsOf(parameters);
assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters);
}

@Test(groups = {"unit"})
Expand All @@ -57,8 +57,8 @@ public void topOrderByWhereClause() {
new SqlParameter("@param2", 2));
queryBuilder.whereClause(new ReadMyWriteWorkflow.QueryBuilder.WhereClause.InWhereClause("colName",
parameters));
assertThat(queryBuilder.toSqlQuerySpec().queryText())
assertThat(queryBuilder.toSqlQuerySpec().getQueryText())
.isEqualTo("SELECT TOP 5 * FROM root WHERE root.colName IN (@param1, @param2) ORDER BY root.prop");
assertThat(queryBuilder.toSqlQuerySpec().parameters()).containsExactlyElementsOf(parameters);
assertThat(queryBuilder.toSqlQuerySpec().getParameters()).containsExactlyElementsOf(parameters);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.azure.data.cosmos.internal.DocumentCollection;
import com.azure.data.cosmos.internal.RequestOptions;
import com.azure.data.cosmos.internal.TestConfigurations;
import com.azure.data.cosmos.internal.directconnectivity.Protocol;
import com.beust.jcommander.JCommander;
import com.google.common.base.CaseFormat;
import com.google.common.base.Strings;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void beforeClass() {
options.setOfferThroughput(initialCollectionThroughput);
AsyncDocumentClient housekeepingClient = Utils.housekeepingClient();
database = Utils.createDatabaseForTest(housekeepingClient);
collection = housekeepingClient.createCollection("dbs/" + database.id(),
collection = housekeepingClient.createCollection("dbs/" + database.getId(),
getCollectionDefinitionWithRangeRangeIndex(),
options).single().block().getResource();
housekeepingClient.close();
Expand Down Expand Up @@ -117,8 +116,8 @@ public void readMyWrites(boolean useNameLink) throws Exception {
String cmd = Strings.lenientFormat(cmdFormat,
TestConfigurations.HOST,
TestConfigurations.MASTER_KEY,
database.id(),
collection.id(),
database.getId(),
collection.getId(),
CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, desiredConsistency),
concurrency,
numberOfOperationsAsString,
Expand Down Expand Up @@ -163,26 +162,26 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
ArrayList<String> paths = new ArrayList<>();
paths.add("/mypk");
partitionKeyDef.paths(paths);
partitionKeyDef.setPaths(paths);
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath();
includedPath.path("/*");
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<>();
Index stringIndex = Index.Range(DataType.STRING);
BridgeInternal.setProperty(stringIndex, "precision", -1);
indexes.add(stringIndex);

Index numberIndex = Index.Range(DataType.NUMBER);
BridgeInternal.setProperty(numberIndex, "precision", -1);
BridgeInternal.setProperty(numberIndex, "getPrecision", -1);
indexes.add(numberIndex);
includedPath.indexes(indexes);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);

DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setIndexingPolicy(indexingPolicy);
collectionDefinition.id(UUID.randomUUID().toString());
collectionDefinition.setId(UUID.randomUUID().toString());
collectionDefinition.setPartitionKey(partitionKeyDef);

return collectionDefinition;
Expand All @@ -196,8 +195,8 @@ private void scheduleScaleUp(int delayStartInSeconds, int newThroughput) {
// for bulk insert and later queries.
return housekeepingClient.queryOffers(
String.format("SELECT * FROM r WHERE r.offerResourceId = '%s'",
collection.resourceId())
, null).flatMap(page -> Flux.fromIterable(page.results()))
collection.getResourceId())
, null).flatMap(page -> Flux.fromIterable(page.getResults()))
.take(1).flatMap(offer -> {
logger.info("going to scale up collection, newThroughput {}", newThroughput);
offer.setThroughput(newThroughput);
Expand Down
Loading