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
2 changes: 1 addition & 1 deletion v3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<artifactId>skyflow-java</artifactId>
<version>2.0.0-beta.4-dev.d3257dc</version>
<version>3.0.0-beta.4</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>Skyflow V3 SDK for the Java programming language</description>
Expand Down
6 changes: 3 additions & 3 deletions v3/src/main/java/com/skyflow/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

public final class Constants extends BaseConstants {
public static final String SDK_NAME = "Skyflow Java SDK ";
public static final String SDK_VERSION = "3.0.0-beta.3";
public static final String SDK_VERSION = "3.0.0-beta.4";
public static final String VAULT_DOMAIN = ".skyvault.";
public static final String SDK_PREFIX = SDK_NAME + SDK_VERSION;
public static final Integer INSERT_BATCH_SIZE = 50;
public static final Integer MAX_INSERT_BATCH_SIZE = 1000;
public static final Integer INSERT_CONCURRENCY_LIMIT = 10;
public static final Integer INSERT_CONCURRENCY_LIMIT = 1;
public static final Integer MAX_INSERT_CONCURRENCY_LIMIT = 10;

public static final Integer DETOKENIZE_BATCH_SIZE = 50;
public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 10;
public static final Integer DETOKENIZE_CONCURRENCY_LIMIT = 1;
public static final Integer MAX_DETOKENIZE_BATCH_SIZE = 1000;
public static final Integer MAX_DETOKENIZE_CONCURRENCY_LIMIT = 10;

Expand Down
44 changes: 23 additions & 21 deletions v3/src/main/java/com/skyflow/utils/validations/Validations.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,39 @@ public static void validateDetokenizeRequest(DetokenizeRequest request) throws S
if (tokens == null || tokens.isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage());
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage());
}
for (String token : tokens) {
for (int index = 0; index < tokens.size(); index++) {
String token = tokens.get(index);
if (token == null || token.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(), InterfaceName.DETOKENIZE.getName()
));
ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(),
InterfaceName.DETOKENIZE.getName(),
String.valueOf(index)));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDetokenizeData.getMessage());
}
}

List<TokenGroupRedactions> groupRedactions = request.getTokenGroupRedactions();
if (groupRedactions != null && !groupRedactions.isEmpty()) {
for (TokenGroupRedactions group : groupRedactions) {
if (group == null) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_REDACTION_GROUP_OBJECT.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupRedactions.getMessage());
}
String groupName = group.getTokenGroupName();
String redaction = group.getRedaction();
if (groupName == null || groupName.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_GROUP_NAME_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupNameInTokenGroup.getMessage());
}
if (redaction == null || redaction.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.EMPTY_OR_NULL_REDACTION_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullRedactionInTokenGroup.getMessage());
}
for (TokenGroupRedactions group : groupRedactions) {
if (group == null) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_REDACTION_GROUP_OBJECT.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupRedactions.getMessage());
}
String groupName = group.getTokenGroupName();
String redaction = group.getRedaction();
if (groupName == null || groupName.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.NULL_TOKEN_GROUP_NAME_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullTokenGroupNameInTokenGroup.getMessage());
}
if (redaction == null || redaction.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(ErrorLogs.EMPTY_OR_NULL_REDACTION_IN_TOKEN_GROUP.getLog(), InterfaceName.DETOKENIZE.getName()));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.NullRedactionInTokenGroup.getMessage());
}
}

}
}

public static void validateVaultConfiguration(VaultConfig vaultConfig) throws SkyflowException {
Expand Down
39 changes: 33 additions & 6 deletions v3/src/main/java/com/skyflow/vault/controller/VaultController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.skyflow.utils.validations.Validations;
import com.skyflow.vault.data.*;
import io.github.cdimascio.dotenv.Dotenv;
import io.github.cdimascio.dotenv.DotenvException;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -309,9 +310,22 @@ private InsertResponse insertBatch(List<InsertRecordData> batch, String tableNam

private void configureInsertConcurrencyAndBatchSize(int totalRequests) {
try {
Dotenv dotenv = Dotenv.load();
String userProvidedBatchSize = dotenv.get("INSERT_BATCH_SIZE");
String userProvidedConcurrencyLimit = dotenv.get("INSERT_CONCURRENCY_LIMIT");
String userProvidedBatchSize = System.getenv("INSERT_BATCH_SIZE");
String userProvidedConcurrencyLimit = System.getenv("INSERT_CONCURRENCY_LIMIT");

Dotenv dotenv = null;
try {
dotenv = Dotenv.load();
} catch (DotenvException ignored) {
// ignore the case if .env file is not found
}

if (userProvidedBatchSize == null && dotenv != null) {
userProvidedBatchSize = dotenv.get("INSERT_BATCH_SIZE");
}
if (userProvidedConcurrencyLimit == null && dotenv != null) {
userProvidedConcurrencyLimit = dotenv.get("INSERT_CONCURRENCY_LIMIT");
}

if (userProvidedBatchSize != null) {
try {
Expand Down Expand Up @@ -365,9 +379,22 @@ private void configureInsertConcurrencyAndBatchSize(int totalRequests) {

private void configureDetokenizeConcurrencyAndBatchSize(int totalRequests) {
try {
Dotenv dotenv = Dotenv.load();
String userProvidedBatchSize = dotenv.get("DETOKENIZE_BATCH_SIZE");
String userProvidedConcurrencyLimit = dotenv.get("DETOKENIZE_CONCURRENCY_LIMIT");
String userProvidedBatchSize = System.getenv("DETOKENIZE_BATCH_SIZE");
String userProvidedConcurrencyLimit = System.getenv("DETOKENIZE_BATCH_SIZE");

Dotenv dotenv = null;
try {
dotenv = Dotenv.load();
} catch (DotenvException ignored) {
// ignore the case if .env file is not found
}

if (userProvidedBatchSize == null && dotenv != null) {
userProvidedBatchSize = dotenv.get("DETOKENIZE_BATCH_SIZE");
}
if (userProvidedConcurrencyLimit == null && dotenv != null) {
userProvidedConcurrencyLimit = dotenv.get("DETOKENIZE_BATCH_SIZE");
}

if (userProvidedBatchSize != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void testFractionalLastBatch() throws Exception {

// Last batch should have 50 records, concurrency should be 101
assertEquals(100, getPrivateInt(controller, "insertBatchSize"));
assertEquals(10, getPrivateInt(controller, "insertConcurrencyLimit"));
assertEquals(Constants.INSERT_CONCURRENCY_LIMIT.intValue(), getPrivateInt(controller, "insertConcurrencyLimit"));
}

private int getPrivateInt(Object obj, String field) throws Exception {
Expand Down
Loading