Skip to content

Commit

Permalink
Fix all warnings, javadocs and compiling issue
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Dec 9, 2024
1 parent 05af2bc commit 97c8ce0
Show file tree
Hide file tree
Showing 36 changed files with 811 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -584,6 +585,7 @@ public CollectionInsertManyResult insertMany(List<? extends T> documents, Collec
try {
for (Future<CollectionInsertManyResult> future : futures) {
CollectionInsertManyResult res = future.get();
System.out.println("res = " + res.getInsertedIds());
finalResult.getInsertedIds().addAll(res.getInsertedIds());
finalResult.getDocumentResponses().addAll(res.getDocumentResponses());
}
Expand Down Expand Up @@ -1343,7 +1345,6 @@ public CollectionDeleteResult deleteMany(Filter filter, CollectionDeleteManyOpti
Command deleteMany = Command
.create("deleteMany")
.withFilter(filter);

DataAPIResponse apiResponse = runCommand(deleteMany, options);
DataAPIStatus status = apiResponse.getStatus();
if (status != null) {
Expand All @@ -1365,7 +1366,8 @@ public CollectionDeleteResult deleteMany(Filter filter, CollectionDeleteManyOpti
* the result of the remove many operation
*/
public CollectionDeleteResult deleteMany(Filter filter) {
return deleteMany(filter, new CollectionDeleteManyOptions());
return deleteMany(filter, new CollectionDeleteManyOptions()
.timeout(Duration.ofSeconds(30)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -29,13 +29,14 @@
/**
* Options to delete many documents.
*/
@Getter @Setter
@Getter
@Setter
@Accessors(fluent = true, chain = true)
public class CollectionDeleteManyOptions extends BaseOptions<CollectionDeleteManyOptions> {

/**
* Default constructor.
*/
public CollectionDeleteManyOptions() {
}
/**
* Default constructor.
*/
public CollectionDeleteManyOptions() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@

/**
* Options for the updateOne operation
*/
@Getter @Setter
@NoArgsConstructor
@Accessors(fluent = true, chain = true)
public class UpdateOneOptions extends BaseOptions<UpdateOneOptions> {

Expand All @@ -46,6 +44,11 @@ public class UpdateOneOptions extends BaseOptions<UpdateOneOptions> {
*/
private Sort[] sort;

/**
* Default constructor.
*/
public UpdateOneOptions() {}

/**
* Adding this on top of sort(Sort[] s) to allow for a more fluent API.
* @param s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class CollectionInsertManyResult {
* Default constructor.
*/
public CollectionInsertManyResult() {
this.insertedIds = new ArrayList<>();
this.documentResponses = new ArrayList<>();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ public List<Caller> getCallers() {
*/
Duration retryDelay = Duration.ofMillis(DEFAULT_RETRY_DELAY_MILLIS);

/**
* Set the number of retries and the delay between each retry.
*
* @param i
* number of retries
* @param duration
* delay between each retry
* @return
* this
*/
public HttpClientOptions httpRetries(int i, Duration duration) {
this.retryCount = i;
this.retryDelay = duration;
Expand Down Expand Up @@ -171,6 +181,7 @@ public HttpClientOptions() {
callers.add(DEFAULT_CALLER);
}

/** {@inheritDoc} */
@Override
public HttpClientOptions clone() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
* Subclass to represent an http proxy.
*/
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(fluent = true, chain = true)
public class HttpProxy implements Cloneable {

Expand All @@ -41,6 +39,25 @@ public class HttpProxy implements Cloneable {
/** port of the proxy. */
int port;

/**
* Default constructor.
*/
public HttpProxy() {}

/**
* Constructor with hostname and port.
*
* @param hostname
* hostname of the proxy
* @param port
* port for the proxy
*/
public HttpProxy(String hostname, int port) {
this.hostname = hostname;
this.port = port;
}

/** {@inheritDoc} */
@Override
public HttpProxy clone() {
return new HttpProxy(this.hostname, this.port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* limitations under the License.
* #L%
*/

/**
* Options for serialization and deserialization.
*/
@Setter
@Accessors(fluent = true, chain = true)
public class SerdesOptions implements Cloneable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ public Filter() {
super();
}

/**
* Create a filter from a map.
*
* @param conditions
* conditions
*/
public Filter(Map<String, Object> conditions) {
super();
if (conditions != null) {
documentMap.putAll(conditions);
}
}

/**
* Create a filter from a where clause.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Subclass representing the vector options.
*/
@Setter
@NoArgsConstructor
@Accessors(fluent = true, chain = true)
public class VectorOptions {

Expand All @@ -50,6 +49,11 @@ public class VectorOptions {
*/
private VectorServiceOptions service;

/**
* Default constructor.
*/
public VectorOptions() {}

/**
* Get metric as an enum.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
* .parameters(Map.of("temperature", 0.7));
* }</pre>
*/
@Getter
@Setter
@Getter @Setter
public class VectorServiceOptions {

/**
Expand All @@ -69,6 +68,11 @@ public class VectorServiceOptions {
*/
private Map<String, Object> parameters;

/**
* Default constructor for serialization purposes.
*/
public VectorServiceOptions() {}

/**
* Adds a single authentication key-value pair to the {@code authentication} map.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Wrapper to get information about the findEmbeddingProviders.
*/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class FindEmbeddingProvidersResult {

Expand All @@ -40,4 +39,9 @@ public class FindEmbeddingProvidersResult {
*/
Map<String, EmbeddingProvider> embeddingProviders;

/**
* Default constructor.
*/
public FindEmbeddingProvidersResult() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,26 @@
*/
public class DataAPIHttpException extends DataAPIException {

/**
* Constructors providing all arguments and a parent exception.
*
* @param code
* error code
* @param errorMessage
* error message
*/
public DataAPIHttpException(ClientErrorCodes code, String errorMessage) {
super(code, errorMessage);
}

/**
* Constructors providing all arguments and a parent exception.
*
* @param errorMessage
* error message
*/
public DataAPIHttpException(String errorMessage) {
super(ClientErrorCodes.HTTP, errorMessage);
this(ClientErrorCodes.HTTP, errorMessage);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.datastax.astra.client.exceptions;

/*-
* #%L
* Data API Java Client
* --
* Copyright (C) 2024 DataStax
* --
* Licensed under the Apache License, Version 2.0
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

/**
* A request to the Data API resulted in an HTTP 4xx or 5xx response.
* In most cases this comes with additional information: the purpose
* of this class is to present such information in a structured way,
* asking to what happens for the DataAPIResponseException, while
* still raising`.
*/
public class DataAPITimeoutException extends DataAPIHttpException {

/**
* Constructors providing all arguments and a parent exception.
*
* @param errorMessage
* error message
*/
public DataAPITimeoutException(String errorMessage) {
super(ClientErrorCodes.TIMEOUT, errorMessage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@
import static com.datastax.astra.client.exceptions.ClientErrorCodes.CONFIG_MISSING;
import static com.datastax.astra.client.exceptions.ClientErrorCodes.MISSING_ANNOTATION;

/**
* Exception thrown when the configuration is invalid.
*/
public class InvalidConfigurationException extends DataAPIException {

/**
* Constructor with code and message
* @param code
* error code
* @param message
* error message
*/
public InvalidConfigurationException(ClientErrorCodes code, String message) {
super(code, message);
}
Expand All @@ -42,6 +52,16 @@ public static void throwErrorMissingConfiguration(String operation, String confi
String.format(CONFIG_MISSING.getMessage(), configParameter, operation));
}

/**
* Format error message.
*
* @param annotation
* annotation
* @param bean
* bean
* @param operation
* operation
*/
public static void throwErrorMissingAnnotation(String annotation, String bean, String operation) {
throw new InvalidConfigurationException(MISSING_ANNOTATION,
String.format(MISSING_ANNOTATION.getMessage(), annotation, bean, operation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
*/
public class InvalidEnvironmentException extends DataAPIException {

/**
* Constructor with code and message
* @param code
* error code
* @param message
* error message
*/
public InvalidEnvironmentException(ClientErrorCodes code, String message) {
super(code, message);
}
Expand Down
Loading

0 comments on commit 97c8ce0

Please sign in to comment.