From 25757e030182af75ef28896d0ab0e52a5e3b02f5 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Fri, 2 Feb 2024 11:45:34 -0500 Subject: [PATCH] CLIENT-2775 Do not use batch repeat flag on batch writes when sendKey policy is true. --- client/src/com/aerospike/client/BatchDelete.java | 4 ++-- client/src/com/aerospike/client/BatchUDF.java | 4 ++-- client/src/com/aerospike/client/command/Command.java | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/com/aerospike/client/BatchDelete.java b/client/src/com/aerospike/client/BatchDelete.java index 0d3e11adf..f5213e917 100644 --- a/client/src/com/aerospike/client/BatchDelete.java +++ b/client/src/com/aerospike/client/BatchDelete.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -63,7 +63,7 @@ public boolean equals(BatchRecord obj) { return false; BatchDelete other = (BatchDelete)obj; - return policy == other.policy; + return policy == other.policy && (policy == null || !policy.sendKey); } /** diff --git a/client/src/com/aerospike/client/BatchUDF.java b/client/src/com/aerospike/client/BatchUDF.java index bd57f8bbf..96c46a80e 100644 --- a/client/src/com/aerospike/client/BatchUDF.java +++ b/client/src/com/aerospike/client/BatchUDF.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -93,7 +93,7 @@ public boolean equals(BatchRecord obj) { BatchUDF other = (BatchUDF)obj; return functionName == other.functionName && functionArgs == other.functionArgs && - packageName == other.packageName && policy == other.policy; + packageName == other.packageName && policy == other.policy && (policy == null || !policy.sendKey); } /** diff --git a/client/src/com/aerospike/client/command/Command.java b/client/src/com/aerospike/client/command/Command.java index 93fc9272f..cb2a5b1d5 100644 --- a/client/src/com/aerospike/client/command/Command.java +++ b/client/src/com/aerospike/client/command/Command.java @@ -767,7 +767,7 @@ public final void setBatchOperate(BatchPolicy policy, KeyIter iter) // Use reference equality only in hope that common namespaces/bin names are set from // fixed variables. It's fine if equality not determined correctly because it just // results in more space used. The batch will still be correct. - if (prev != null && prev.key.namespace == key.namespace && prev.key.setName == key.setName && + if (!policy.sendKey && prev != null && prev.key.namespace == key.namespace && prev.key.setName == key.setName && record.equals(prev)) { // Can set repeat previous namespace/bin names to save space. dataOffset++; @@ -813,7 +813,7 @@ public final void setBatchOperate(BatchPolicy policy, KeyIter iter) // Use reference equality only in hope that common namespaces/bin names are set from // fixed variables. It's fine if equality not determined correctly because it just // results in more space used. The batch will still be correct. - if (prev != null && prev.key.namespace == key.namespace && prev.key.setName == key.setName && + if (!policy.sendKey && prev != null && prev.key.namespace == key.namespace && prev.key.setName == key.setName && record.equals(prev)) { // Can set repeat previous namespace/bin names to save space. dataBuffer[dataOffset++] = BATCH_MSG_REPEAT; @@ -936,7 +936,7 @@ public final void setBatchOperate( dataOffset += key.digest.length + 4; // Try reference equality in hope that namespace/set for all keys is set from fixed variables. - if (prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { + if (!attr.sendKey && prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { // Can set repeat previous namespace/bin names to save space. dataOffset++; } @@ -999,7 +999,7 @@ else if ((attr.writeAttr & Command.INFO2_DELETE) != 0) { dataOffset += digest.length; // Try reference equality in hope that namespace/set for all keys is set from fixed variables. - if (prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { + if (!attr.sendKey && prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { // Can set repeat previous namespace/bin names to save space. dataBuffer[dataOffset++] = BATCH_MSG_REPEAT; } @@ -1067,7 +1067,7 @@ public final void setBatchUDF( dataOffset += key.digest.length + 4; // Try reference equality in hope that namespace/set for all keys is set from fixed variables. - if (prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { + if (!attr.sendKey && prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { // Can set repeat previous namespace/bin names to save space. dataOffset++; } @@ -1112,7 +1112,7 @@ public final void setBatchUDF( dataOffset += digest.length; // Try reference equality in hope that namespace/set for all keys is set from fixed variables. - if (prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { + if (!attr.sendKey && prev != null && prev.namespace == key.namespace && prev.setName == key.setName) { // Can set repeat previous namespace/bin names to save space. dataBuffer[dataOffset++] = BATCH_MSG_REPEAT; }