Skip to content

Commit

Permalink
CLIENT-2775 Do not use batch repeat flag on batch writes when sendKey…
Browse files Browse the repository at this point in the history
… policy is true.
  • Loading branch information
BrianNichols committed Feb 2, 2024
1 parent 36b4ca2 commit 25757e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/src/com/aerospike/client/BatchDelete.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions client/src/com/aerospike/client/BatchUDF.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions client/src/com/aerospike/client/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public final void setBatchOperate(BatchPolicy policy, KeyIter<BatchRecord> 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++;
Expand Down Expand Up @@ -813,7 +813,7 @@ public final void setBatchOperate(BatchPolicy policy, KeyIter<BatchRecord> 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;
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 25757e0

Please sign in to comment.