Skip to content

Commit 356fa56

Browse files
author
Ryan CrawCour
committed
Merge pull request #42 from shellygms/master
DocumentDB JavaSDK version 1.6.0 Release
2 parents c96bc5e + fd4326f commit 356fa56

29 files changed

+3262
-1736
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class SampleApp {
6868
// Define an id for your database and collection
6969
private static final String DATABASE_ID = "TestDB";
7070
private static final String COLLECTION_ID = "TestCollection";
71+
private static final String COLLECTION_ID_PARTITIONED = "TestCollection_Partitioned";
7172

7273
// We'll use Gson for POJO <=> JSON serialization for this sample.
7374
// Codehaus' Jackson is another great POJO <=> JSON serializer.
@@ -108,7 +109,38 @@ public class SampleApp {
108109
// Create a new document.
109110
myDocument = documentClient.createDocument(myCollection.getSelfLink(),
110111
myDocument, null, false).getResource();
111-
112+
113+
// The following code Illustrates how to create a partitioned collection and
114+
// use the partition key to access documents.
115+
116+
// Create a partition key definition that specifies the path to the property
117+
// within a document that is used as the partition key.
118+
PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition();
119+
ArrayList<String> paths = new ArrayList<String>();
120+
paths.add("/id");
121+
partitionKeyDef.setPaths(paths);
122+
123+
// Create a collection with the partition key definition and set the offer throughput
124+
// to 10100 RU per second.
125+
DocumentCollection myPartitionedCollection = new DocumentCollection();
126+
myPartitionedCollection.setId(COLLECTION_ID_PARTITIONED);
127+
myPartitionedCollection.setPartitionKey(partitionKeyDef);
128+
129+
RequestOptions options = new RequestOptions();
130+
options.setOfferThroughput(10100);
131+
myPartitionedCollection = documentClient.createCollection(
132+
myDatabase.getSelfLink(), myCollection, options).getResource();
133+
134+
// Insert a document into the created collection.
135+
String document = "{ 'id': 'document1', 'description': 'this is a test document.' }";
136+
Document newDocument = new Document(document);
137+
newDocument = documentClient.createDocument(myPartitionedCollection.getSelfLink(),
138+
newDocument, null, false).getResource();
139+
140+
// Read the created document, specifying the required partition key in RequestOptions.
141+
options = new RequestOptions();
142+
options.setPartitionKey(new PartitionKey("document1"));
143+
newDocument = documentClient.readDocument(newDocument.getSelfLink(), options).getResource();
112144
}
113145
}
114146
```
@@ -117,7 +149,7 @@ Additional samples are provided in the unit tests.
117149

118150
##Need Help?
119151

120-
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.
152+
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.
121153

122154
##Contribute Code or Provide Feedback
123155

@@ -130,4 +162,4 @@ If you encounter any bugs with the library please file an issue in the [Issues](
130162
* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/java/)
131163
* [Azure DocumentDB Service](http://azure.microsoft.com/en-us/documentation/services/documentdb/)
132164
* [Azure DocumentDB Team Blog](http://blogs.msdn.com/b/documentdb/)
133-
* [JavaDocs](http://azure.github.io/azure-documentdb-java/)
165+
* [JavaDocs](http://dl.windowsazure.com/documentdb/javadoc)

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Changes in 1.6.0 : ##
2+
3+
- Added support to set offer throughput for collections created with variable pricing structure.
4+
- Added support to create collections with multiple partitions by specifying a partition key definition.
5+
- Added support to send partition key in RequestOptions and FeedOptions to specify the scope of the request or the query.
6+
- Added support to specify a partition key in the Permission object to scope the permission to a partition.
7+
18
## Changes in 1.5.1 : ##
29

310
- Fixed a bug in HashPartitionResolver to generate hash values in little-endian order to be consistent with other SDKs.

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.microsoft.azure</groupId>
55
<artifactId>azure-documentdb</artifactId>
6-
<version>1.5.1</version>
6+
<version>1.6.0</version>
77
<name>${project.groupId}:${project.artifactId}</name>
88
<description>Java SDK for Microsoft Azure DocumentDB</description>
99
<url>http://azure.microsoft.com/en-us/services/documentdb/</url>
@@ -17,6 +17,12 @@
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919
<developers>
20+
<developer>
21+
<name>Shelly Guo</name>
22+
<email>[email protected]</email>
23+
<organization>Microsoft</organization>
24+
<organizationUrl>http://www.microsoft.com/</organizationUrl>
25+
</developer>
2026
<developer>
2127
<name>Rajesh Nagpal</name>
2228
<email>[email protected]</email>

src/com/microsoft/azure/documentdb/Constants.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ static class Properties {
105105

106106
//Offer resource
107107
static final String OFFER_TYPE = "offerType";
108+
static final String OFFER_VERSION = "offerVersion";
109+
static final String OFFER_CONTENT = "content";
110+
static final String OFFER_THROUGHPUT = "offerThroughput";
111+
static final String OFFER_VERSION_V1 = "V1";
112+
static final String OFFER_VERSION_V2 = "V2";
113+
static final String OFFER_RESOURCE_ID = "offerResourceId";
114+
115+
//PartitionKey
116+
static final String PARTITION_KEY = "partitionKey";
117+
static final String PARTITION_KEY_PATHS = "paths";
118+
static final String PARTITION_KIND = "kind";
119+
static final String RESOURCE_PARTITION_KEY = "resourcePartitionKey";
108120
}
109121

110122
static class ResourceKeys {

0 commit comments

Comments
 (0)