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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.models.DataType;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.TestConfigurations;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.beust.jcommander.JCommander;
import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -29,7 +25,6 @@

import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -167,10 +162,6 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath("/*");
List<Index> indexes = new ArrayList<>();
indexes.add(Index.range(DataType.STRING, -1));
indexes.add(Index.range(DataType.NUMBER, -1));
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.models.DataType;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.TestConfigurations;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.beust.jcommander.JCommander;
import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.AfterClass;
Expand All @@ -23,7 +19,6 @@
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -307,10 +302,6 @@ DocumentCollection getCollectionDefinitionWithRangeRangeIndex() {
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath("/*");
List<Index> indexes = new ArrayList<>();
indexes.add(Index.range(DataType.STRING, -1));
indexes.add(Index.range(DataType.NUMBER, -1));
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
// Licensed under the MIT License.
package com.azure.cosmos.rx.examples;

import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.implementation.ConnectionPolicy;
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.models.DataType;
import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.models.FeedResponse;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.implementation.ConnectionPolicy;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.ResourceResponse;
import com.azure.cosmos.implementation.TestConfigurations;
import com.azure.cosmos.models.FeedResponse;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.PartitionKeyDefinition;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -377,10 +375,6 @@ private DocumentCollection getMultiPartitionCollectionDefinition() {
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath("/*");
List<Index> indexes = new ArrayList<>();
indexes.add(Index.range(DataType.STRING, -1));
indexes.add(Index.range(DataType.NUMBER, -1));
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,24 @@

package com.azure.cosmos.rx.examples;

import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.ConnectionMode;
import com.azure.cosmos.implementation.ConnectionPolicy;
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.models.DataType;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.implementation.Offer;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.TestConfigurations;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.PartitionKeyDefinition;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -142,10 +136,6 @@ private DocumentCollection getMultiPartitionCollectionDefinition() {
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<>();
IncludedPath includedPath = new IncludedPath("/*");
List<Index> indexes = new ArrayList<>();
indexes.add(Index.range(DataType.STRING, -1));
indexes.add(Index.range(DataType.NUMBER, -1));
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@

package com.azure.cosmos.rx.examples;

import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.DirectConnectionConfig;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.implementation.AsyncDocumentClient;
import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.ConnectionMode;
import com.azure.cosmos.implementation.ConnectionPolicy;
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.models.DataType;
import com.azure.cosmos.implementation.Database;
import com.azure.cosmos.DocumentClientTest;
import com.azure.cosmos.implementation.DocumentCollection;
import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.StoredProcedure;
import com.azure.cosmos.implementation.TestConfigurations;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKey;
import com.azure.cosmos.models.PartitionKeyDefinition;
import com.azure.cosmos.implementation.RequestOptions;
import com.azure.cosmos.implementation.StoredProcedure;
import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.TestConfigurations;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -234,10 +229,6 @@ private static DocumentCollection getMultiPartitionCollectionDefinition() {
IndexingPolicy indexingPolicy = new IndexingPolicy();
List<IncludedPath> includedPaths = new ArrayList<IncludedPath>();
IncludedPath includedPath = new IncludedPath("/*");
List<Index> indexes = new ArrayList<Index>();
indexes.add(Index.range(DataType.STRING, -1));
indexes.add(Index.range(DataType.NUMBER, -1));
includedPath.setIndexes(indexes);
includedPaths.add(includedPath);
indexingPolicy.setIncludedPaths(includedPaths);
collectionDefinition.setIndexingPolicy(indexingPolicy);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.models;
package com.azure.cosmos.implementation;

/**
* Data types in the Azure Cosmos DB database service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.models;
package com.azure.cosmos.implementation;

import com.azure.cosmos.implementation.Constants;
import com.azure.cosmos.implementation.apachecommons.lang.StringUtils;
import com.azure.cosmos.implementation.IndexKind;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
Expand Down Expand Up @@ -47,7 +45,7 @@ public final class HashIndex extends Index {
*
* @param jsonString the json string that represents the index.
*/
HashIndex(String jsonString) {
public HashIndex(String jsonString) {
super(jsonString, IndexKind.HASH);
if (this.getDataType() == null) {
throw new IllegalArgumentException("The jsonString doesn't contain a valid 'dataType'.");
Expand All @@ -74,11 +72,10 @@ public final class HashIndex extends Index {
public DataType getDataType() {
DataType result = null;
try {
result = DataType.valueOf(StringUtils.upperCase(this.jsonSerializable.getString(Constants.Properties.DATA_TYPE)));
result = DataType.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.DATA_TYPE)));
} catch (IllegalArgumentException e) {
// Ignore exception and let the caller handle null value.
this.jsonSerializable.getLogger().warn("INVALID index dataType value {}.",
this.jsonSerializable.getString(Constants.Properties.DATA_TYPE));
super.getLogger().warn("INVALID index dataType value {}.", super.getString(Constants.Properties.DATA_TYPE));
}
return result;
}
Expand All @@ -90,7 +87,7 @@ public DataType getDataType() {
* @return the Hash Index.
*/
public HashIndex setDataType(DataType dataType) {
this.jsonSerializable.set(Constants.Properties.DATA_TYPE, dataType.toString());
super.set(Constants.Properties.DATA_TYPE, dataType.toString());
return this;
}

Expand All @@ -100,7 +97,7 @@ public HashIndex setDataType(DataType dataType) {
* @return the precision.
*/
public int getPrecision() {
return this.jsonSerializable.getInt(Constants.Properties.PRECISION);
return super.getInt(Constants.Properties.PRECISION);
}

/**
Expand All @@ -110,11 +107,11 @@ public int getPrecision() {
* @return the Hash Index.
*/
public HashIndex setPrecision(int precision) {
this.jsonSerializable.set(Constants.Properties.PRECISION, precision);
super.set(Constants.Properties.PRECISION, precision);
return this;
}

boolean hasPrecision() {
return this.jsonSerializable.has(Constants.Properties.PRECISION);
return super.has(Constants.Properties.PRECISION);
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.models;
package com.azure.cosmos.implementation;

import com.azure.cosmos.implementation.Constants;
import com.azure.cosmos.implementation.JsonSerializable;
import com.azure.cosmos.implementation.apachecommons.lang.StringUtils;
import com.azure.cosmos.implementation.IndexKind;
import com.fasterxml.jackson.databind.node.ObjectNode;

/**
* Represents the index of a container in the Azure Cosmos DB database service.
*/
public abstract class Index {
JsonSerializable jsonSerializable;
public abstract class Index extends JsonSerializable {

/**
* Constructor.
*
* @param indexKind the kind of the index
*/
Index(IndexKind indexKind) {
this.jsonSerializable = new JsonSerializable();
super();
this.setKind(indexKind);
}

Expand All @@ -32,7 +28,7 @@ public abstract class Index {
* @param indexKind the kind of the index
*/
Index(String jsonString, IndexKind indexKind) {
this.jsonSerializable = new JsonSerializable(jsonString);
super(jsonString);
this.setKind(indexKind);
}

Expand All @@ -43,7 +39,7 @@ public abstract class Index {
* @param indexKind the kind of the index
*/
Index(ObjectNode objectNode, IndexKind indexKind) {
this.jsonSerializable = new JsonSerializable(objectNode);
super(objectNode);
this.setKind(indexKind);
}

Expand Down Expand Up @@ -125,9 +121,9 @@ public static SpatialIndex spatial(DataType dataType) {
IndexKind getKind() {
IndexKind result = null;
try {
result = IndexKind.valueOf(StringUtils.upperCase(this.jsonSerializable.getString(Constants.Properties.INDEX_KIND)));
result = IndexKind.valueOf(StringUtils.upperCase(super.getString(Constants.Properties.INDEX_KIND)));
} catch (IllegalArgumentException e) {
this.jsonSerializable.getLogger().warn("INVALID index kind value %s.", this.jsonSerializable.getString(Constants.Properties.INDEX_KIND));
super.getLogger().warn("INVALID index kind value %s.", super.getString(Constants.Properties.INDEX_KIND));
}

return result;
Expand All @@ -139,13 +135,7 @@ IndexKind getKind() {
* @param indexKind the index kind.
*/
private Index setKind(IndexKind indexKind) {
this.jsonSerializable.set(Constants.Properties.INDEX_KIND, indexKind.toString());
super.set(Constants.Properties.INDEX_KIND, indexKind.toString());
return this;
}

void populatePropertyBag() {
this.jsonSerializable.populatePropertyBag();
}

JsonSerializable getJsonSerializable() { return this.jsonSerializable; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.azure.cosmos.models.ConflictResolutionPolicy;
import com.azure.cosmos.models.ExcludedPath;
import com.azure.cosmos.models.IncludedPath;
import com.azure.cosmos.models.Index;
import com.azure.cosmos.models.IndexingPolicy;
import com.azure.cosmos.models.ModelBridgeInternal;
import com.azure.cosmos.models.PartitionKeyDefinition;
Expand Down Expand Up @@ -692,7 +691,6 @@ <T> boolean containsJsonSerializable(Class<T> c) {
|| SqlParameter.class.equals(c)
|| SqlQuerySpec.class.equals(c)
|| UniqueKey.class.equals(c)
|| UniqueKeyPolicy.class.equals(c)
|| Index.class.isAssignableFrom(c);
|| UniqueKeyPolicy.class.equals(c);
}
}
Loading