本文整理匯總了Java中com.microsoft.azure.documentdb.IndexingPolicy類的典型用法代碼示例。如果您正苦於以下問題:Java IndexingPolicy類的具體用法?Java IndexingPolicy怎麽用?Java IndexingPolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IndexingPolicy類屬於com.microsoft.azure.documentdb包,在下文中一共展示了IndexingPolicy類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replaceCollection
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void replaceCollection() throws Exception {
// create a collection
DocumentCollection collectionDefinition = getCollectionDefinition();
Observable<ResourceResponse<DocumentCollection>> createObservable = client.createCollection(database.getSelfLink(), collectionDefinition, null);
DocumentCollection collection = createObservable.toBlocking().single().getResource();
// sanity check
assertThat(collection.getIndexingPolicy().getIndexingMode()).isEqualTo(IndexingMode.Consistent);
// replace indexing mode
IndexingPolicy indexingMode = new IndexingPolicy();
indexingMode.setIndexingMode(IndexingMode.Lazy);
collection.setIndexingPolicy(indexingMode);
Observable<ResourceResponse<DocumentCollection>> readObservable = client.replaceCollection(collection, null);
// validate
ResourceResponseValidator<DocumentCollection> validator = new ResourceResponseValidator.Builder<DocumentCollection>()
.indexingMode(IndexingMode.Lazy).build();
validateSuccess(readObservable, validator);
}
示例2: getOutputIndexingPolicy
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
private static IndexingPolicy getOutputIndexingPolicy(int outputStringPrecision) {
// Setup indexing policy.
IndexingPolicy policy = new IndexingPolicy();
ArrayList<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
// All paths.
IncludedPath path = new IncludedPath();
RangeIndex stringIndex = new RangeIndex(DataType.String);
stringIndex.setPrecision(outputStringPrecision);
path.getIndexes().add(stringIndex);
RangeIndex numberIndex = new RangeIndex(DataType.Number);
numberIndex.setPrecision(-1); // Maximum precision
path.getIndexes().add(numberIndex);
path.setPath("/*");
includedPaths.add(path);
policy.setIncludedPaths(includedPaths);
return policy;
}
示例3: createMultiPartitionCollection
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
private void createMultiPartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// set the throughput to be 10,200
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10200);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
client.createCollection(databaseLink, collectionDefinition, options);
}
示例4: createMultiPartitionCollection
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
private void createMultiPartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// set the throughput to be 10,200
RequestOptions options = new RequestOptions();
options.setOfferThroughput(10200);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
this.collection = client.createCollection(databaseLink, collectionDefinition, options).getResource();
}
示例5: createCustomMultiPartitionCollection
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
@Test
public void createCustomMultiPartitionCollection() throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
String collectionId = "testCollection";
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add("/city");
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// set the throughput to be 20,000
RequestOptions options = new RequestOptions();
options.setOfferThroughput(20000);
// set ttl to 100 seconds
collectionDefinition.setDefaultTimeToLive(100);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
client.createCollection(databaseLink, collectionDefinition, options);
// create a document in the collection
String collectionLink = String.format("/dbs/%s/colls/%s", databaseId, collectionId);
Document documentDefinition = new Document(
"{" +
" \"id\": \"test-document\"," +
" \"city\" : \"Seattle\"" +
"} ") ;
client.createDocument(collectionLink, documentDefinition, options, false);
}
示例6: createSinglePartitionCollection
import com.microsoft.azure.documentdb.IndexingPolicy; //導入依賴的package包/類
private void createSinglePartitionCollection(String partitionKeyPath) throws DocumentClientException {
String databaseLink = String.format("/dbs/%s", databaseId);
DocumentCollection collectionDefinition = new DocumentCollection();
collectionDefinition.setId(collectionId);
// set /city as the partition key path
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
Collection<String> paths = new ArrayList<String>();
paths.add(partitionKeyPath);
partitionKeyDefinition.setPaths(paths);
collectionDefinition.setPartitionKey(partitionKeyDefinition);
// if you want a single partition collection with 10,000 throughput
// the only way to do so is to create a single partition collection with lower throughput (400)
// and then increase the throughput to 10,000
RequestOptions options = new RequestOptions();
options.setOfferThroughput(400);
// set indexing policy to be range range for string and number
IndexingPolicy indexingPolicy = new IndexingPolicy();
Collection<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath();
includedPath.setPath("/*");
Collection<Index> indexes = new ArrayList<Index>();
Index stringIndex = Index.Range(DataType.String);
stringIndex.set("precision", -1);
indexes.add(stringIndex);
Index numberIndex = Index.Range(DataType.Number);
numberIndex.set("precision", -1);
indexes.add(numberIndex);
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
// create a collection
DocumentCollection createdDollection =
client.createCollection(databaseLink, collectionDefinition, options).getResource();
// increase throughput from 400 to 10,000
replaceOffer(createdDollection, 10000);
}
開發者ID:Azure,項目名稱:azure-documentdb-java,代碼行數:45,代碼來源:SinglePartitionCollectionDocumentCrudSample.java