Skip to content

Commit

Permalink
Merge pull request #42 from shellygms/master
Browse files Browse the repository at this point in the history
DocumentDB JavaSDK version 1.6.0 Release
  • Loading branch information
Ryan CrawCour committed Mar 28, 2016
2 parents c96bc5e + fd4326f commit 356fa56
Show file tree
Hide file tree
Showing 29 changed files with 3,262 additions and 1,736 deletions.
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class SampleApp {
// Define an id for your database and collection
private static final String DATABASE_ID = "TestDB";
private static final String COLLECTION_ID = "TestCollection";
private static final String COLLECTION_ID_PARTITIONED = "TestCollection_Partitioned";

// We'll use Gson for POJO <=> JSON serialization for this sample.
// Codehaus' Jackson is another great POJO <=> JSON serializer.
Expand Down Expand Up @@ -108,7 +109,38 @@ public class SampleApp {
// Create a new document.
myDocument = documentClient.createDocument(myCollection.getSelfLink(),
myDocument, null, false).getResource();


// The following code Illustrates how to create a partitioned collection and
// use the partition key to access documents.

// Create a partition key definition that specifies the path to the property
// within a document that is used as the partition key.
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
ArrayList<String> paths = new ArrayList<String>();
paths.add("/id");
partitionKeyDef.setPaths(paths);

// Create a collection with the partition key definition and set the offer throughput
// to 10100 RU per second.
DocumentCollection myPartitionedCollection = new DocumentCollection();
myPartitionedCollection.setId(COLLECTION_ID_PARTITIONED);
myPartitionedCollection.setPartitionKey(partitionKeyDef);

RequestOptions options = new RequestOptions();
options.setOfferThroughput(10100);
myPartitionedCollection = documentClient.createCollection(
myDatabase.getSelfLink(), myCollection, options).getResource();

// Insert a document into the created collection.
String document = "{ 'id': 'document1', 'description': 'this is a test document.' }";
Document newDocument = new Document(document);
newDocument = documentClient.createDocument(myPartitionedCollection.getSelfLink(),
newDocument, null, false).getResource();

// Read the created document, specifying the required partition key in RequestOptions.
options = new RequestOptions();
options.setPartitionKey(new PartitionKey("document1"));
newDocument = documentClient.readDocument(newDocument.getSelfLink(), options).getResource();
}
}
```
Expand All @@ -117,7 +149,7 @@ Additional samples are provided in the unit tests.

##Need Help?

Be sure to check out the [Developer Forums on Stack Overflow](http://stackoverflow.com/questions/tagged/azure-documentdb) if you have trouble with the provided code.
Be sure to check out the Microsoft Azure [Developer Forums on MSDN](https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=AzureDocumentDB) or the [Developer Forums on Stack Overflow](http://stackoverflow.com/questions/tagged/azure-documentdb) if you have trouble with the provided code.

##Contribute Code or Provide Feedback

Expand All @@ -130,4 +162,4 @@ If you encounter any bugs with the library please file an issue in the [Issues](
* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/java/)
* [Azure DocumentDB Service](http://azure.microsoft.com/en-us/documentation/services/documentdb/)
* [Azure DocumentDB Team Blog](http://blogs.msdn.com/b/documentdb/)
* [JavaDocs](http://azure.github.io/azure-documentdb-java/)
* [JavaDocs](http://dl.windowsazure.com/documentdb/javadoc)
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Changes in 1.6.0 : ##

- Added support to set offer throughput for collections created with variable pricing structure.
- Added support to create collections with multiple partitions by specifying a partition key definition.
- Added support to send partition key in RequestOptions and FeedOptions to specify the scope of the request or the query.
- Added support to specify a partition key in the Permission object to scope the permission to a partition.
## Changes in 1.5.1 : ##

- Fixed a bug in HashPartitionResolver to generate hash values in little-endian order to be consistent with other SDKs.
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>1.5.1</version>
<version>1.6.0</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java SDK for Microsoft Azure DocumentDB</description>
<url>http://azure.microsoft.com/en-us/services/documentdb/</url>
Expand All @@ -17,6 +17,12 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<developers>
<developer>
<name>Shelly Guo</name>
<email>[email protected]</email>
<organization>Microsoft</organization>
<organizationUrl>http://www.microsoft.com/</organizationUrl>
</developer>
<developer>
<name>Rajesh Nagpal</name>
<email>[email protected]</email>
Expand Down
12 changes: 12 additions & 0 deletions src/com/microsoft/azure/documentdb/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ static class Properties {

//Offer resource
static final String OFFER_TYPE = "offerType";
static final String OFFER_VERSION = "offerVersion";
static final String OFFER_CONTENT = "content";
static final String OFFER_THROUGHPUT = "offerThroughput";
static final String OFFER_VERSION_V1 = "V1";
static final String OFFER_VERSION_V2 = "V2";
static final String OFFER_RESOURCE_ID = "offerResourceId";

//PartitionKey
static final String PARTITION_KEY = "partitionKey";
static final String PARTITION_KEY_PATHS = "paths";
static final String PARTITION_KIND = "kind";
static final String RESOURCE_PARTITION_KEY = "resourcePartitionKey";
}

static class ResourceKeys {
Expand Down
Loading

0 comments on commit 356fa56

Please sign in to comment.