/** * Gets the collection's partition key definition. * * @return the partition key definition. */ public PartitionKeyDefinition getPartitionKey() { if (super.has(Constants.Properties.PARTITION_KEY)) { return super.getObject(Constants.Properties.PARTITION_KEY, PartitionKeyDefinition.class); } this.setPartitionKey(new PartitionKeyDefinition()); return this.getPartitionKey(); }
void addPartitionKeyInformation(AbstractDocumentServiceRequest request, Document document, RequestOptions options) { PartitionKeyInternal partitionKeyInternal; if (options != null && options.getPartitionKey() != null) { partitionKeyInternal = options.getPartitionKey().getInternalPartitionKey(); } else { // Resolve collection only when it's needed DocumentCollection collection = this.collectionCache.resolveCollection(request); PartitionKeyDefinition partitionKeyDefinition = collection.getPartitionKey(); if (partitionKeyDefinition == null || partitionKeyDefinition.getPaths().size() == 0) { // For backward compatibility, if collection doesn't have partition key defined, we assume all documents // have empty value for it and user doesn't need to specify it explicitly. partitionKeyInternal = PartitionKeyInternal.getEmpty(); } else if (document != null) { partitionKeyInternal = extractPartitionKeyValueFromDocument(document, partitionKeyDefinition); } else { throw new UnsupportedOperationException("PartitionKey value must be supplied for this operation."); } } request.getHeaders().put(HttpConstants.HttpHeaders.PARTITION_KEY, escapeNonAscii(partitionKeyInternal.toJson())); }
queryPartitionProvider.getPartitionQueryExcecutionInfo(new SqlQuerySpec(query), collection.getPartitionKey()); Collection<PartitionKeyRange> partitionKeyRanges = RoutingMapProviderHelper.getOverlappingRanges( this.getPartitionKeyRangeCache(),