From 9c8cf1f2ec2d97a90f64ebac3f17c1d9d7ee08fa Mon Sep 17 00:00:00 2001 From: Madhavan Sridharan Date: Wed, 14 Aug 2024 23:05:37 -0400 Subject: [PATCH] Convert logs to message supplier pattern --- .../adapter/azureaisearch/AzureAISearchSpace.java | 8 ++++---- .../adapter/azureaisearch/ops/AzureAISearchBaseOp.java | 2 +- .../azureaisearch/ops/AzureAISearchListIndexesOp.java | 9 ++++----- .../ops/AzureAISearchUploadDocumentsOp.java | 6 +++--- .../AzureAISearchCreateOrUpdateIndexOpDispenser.java | 3 --- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/AzureAISearchSpace.java b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/AzureAISearchSpace.java index 7fdf5204c..c818d2e0a 100644 --- a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/AzureAISearchSpace.java +++ b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/AzureAISearchSpace.java @@ -90,8 +90,8 @@ public class AzureAISearchSpace implements AutoCloseable { }).orElseGet(() -> cfg.getOptional("token").orElseThrow(() -> new RuntimeException( "You must provide either a 'token_file' or a 'token' to configure a Azure AI Search client"))); - logger.info("{}: Creating new Azure AI Search Client with (masked) token/key [{}], uri/endpoint [{}]", - this.name, AzureAISearchAdapterUtils.maskDigits(requiredToken), uri); + logger.info(() -> "Creating new Azure AI Search Client with (masked) token/key [" + + AzureAISearchAdapterUtils.maskDigits(requiredToken) + "], uri/endpoint [" + uri + "]"); var searchIndexClientBuilder = new SearchIndexClientBuilder().endpoint(uri); if (!requiredToken.isBlank()) { @@ -103,8 +103,8 @@ public class AzureAISearchSpace implements AutoCloseable { // Should we leave these below to leverage the SearchServiceVersion.getLatest()? String apiVersion = cfg.getOptional("api_version").orElse(SearchServiceVersion.V2024_07_01.name()); logger.warn( - "Latest search service version supported by this client is '{}', but we're using '{}' version. Ignore this warning if both are same.", - SearchServiceVersion.getLatest(), apiVersion); + () -> "Latest search service version supported by this client is '" + SearchServiceVersion.getLatest() + + "', but we're using '" + apiVersion + "' version. Ignore this warning if both are same."); return searchIndexClientBuilder.serviceVersion(SearchServiceVersion.valueOf(apiVersion)).buildClient(); } diff --git a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchBaseOp.java b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchBaseOp.java index 79166cbcc..259501591 100644 --- a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchBaseOp.java +++ b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchBaseOp.java @@ -48,7 +48,7 @@ public abstract class AzureAISearchBaseOp implements CycleOp { @Override public final Object apply(long value) { - logger.trace("applying op: " + this); + logger.trace(() -> "applying op: " + this); try { Object result = applyOp(value); diff --git a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchListIndexesOp.java b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchListIndexesOp.java index 85676fead..93f1449ed 100644 --- a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchListIndexesOp.java +++ b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchListIndexesOp.java @@ -30,12 +30,11 @@ public class AzureAISearchListIndexesOp extends AzureAISearchBaseOp { try { PagedIterable response = searchIndexClient.listIndexes(); response.forEach((index) -> { - logger.info("Indexes available are: Name: {}, ETag: {}", index.getName(), index.getETag()); + logger.info(() -> "Indexes available are: Name: " + index.getName() + ", ETag: " + index.getETag()); index.getFields().forEach(field -> { - logger.info( - "Field Name: {}, Field isKey?: {}, Field Dimension: {}, Field Vector Search Profile: {}", - field.getName(), field.isKey(), field.getVectorSearchDimensions(), - field.getVectorSearchProfileName()); + logger.info(() -> "Field Name: " + field.getName() + ", Field isKey?: " + field.isKey() + + ", Field Dimension: " + field.getVectorSearchDimensions() + + ", Field Vector Search Profile: " + field.getVectorSearchProfileName()); }); }); } catch (RuntimeException rte) { diff --git a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchUploadDocumentsOp.java b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchUploadDocumentsOp.java index b2ad1fa1e..61bd3df70 100644 --- a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchUploadDocumentsOp.java +++ b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/ops/AzureAISearchUploadDocumentsOp.java @@ -36,9 +36,9 @@ public class AzureAISearchUploadDocumentsOp extends AzureAISearchClientBaseOp { - logger.debug( - "Successfully created the collection with return status code: {}, key: {}, succeeded?: {}, error message: {}", - r.getStatusCode(), r.getKey(), r.isSucceeded(), r.getErrorMessage()); + logger.debug(() -> "Successfully created the collection with return status code: " + + r.getStatusCode() + ", key: " + r.getKey() + ", succeeded?: " + r.isSucceeded() + + ", error message: " + r.getErrorMessage()); }); } } catch (RuntimeException rte) { diff --git a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/opsdispenser/AzureAISearchCreateOrUpdateIndexOpDispenser.java b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/opsdispenser/AzureAISearchCreateOrUpdateIndexOpDispenser.java index 26e8a9d4a..54b88a8e2 100644 --- a/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/opsdispenser/AzureAISearchCreateOrUpdateIndexOpDispenser.java +++ b/nb-adapters/adapter-azure-aisearch/src/main/java/io/nosqlbench/adapter/azureaisearch/opsdispenser/AzureAISearchCreateOrUpdateIndexOpDispenser.java @@ -129,9 +129,6 @@ public class AzureAISearchCreateOrUpdateIndexOpDispenser extends AzureAISearchBa BinaryQuantizationCompression bqComp = new BinaryQuantizationCompression(innerKey); ((Map) innerValue).forEach((compressKey, compressValue) -> { - logger.debug( - ">>>>>>>>>>>>AzureAISearchCreateOrUpdateIndexOpDispenser>>>>>>>>>>>>VectorSearch>>>>buildVectorSearchStruct>>>>kind:{} compressKey:{} compressValue:{}", - kind, compressKey, compressValue); if (compressKey.equals("kind")) { bqComp.getKind().fromString((String) compressValue); }