Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking the emptiness of binNames field before setting into command #321

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 10 additions & 2 deletions client/src/com/aerospike/client/BatchRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public final class BatchRead extends BatchRecord {
public BatchRead(Key key, String[] binNames) {
super(key, false);
this.policy = null;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = null;
this.readAllBins = false;
}
Expand Down Expand Up @@ -90,7 +94,11 @@ public BatchRead(Key key, Operation[] ops) {
public BatchRead(BatchReadPolicy policy, Key key, String[] binNames) {
super(key, false);
this.policy = policy;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = null;
this.readAllBins = false;
}
Expand Down
15 changes: 11 additions & 4 deletions client/src/com/aerospike/client/async/AsyncBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package com.aerospike.client.async;

import java.util.ArrayList;
import java.util.List;

import com.aerospike.client.AerospikeClient;
Expand Down Expand Up @@ -175,7 +174,11 @@ public GetArrayCommand(
) {
super(parent, batch, batchPolicy, isOperation);
this.keys = keys;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = ops;
this.records = records;
this.readAttr = readAttr;
Expand Down Expand Up @@ -236,7 +239,11 @@ public GetSequenceCommand(
) {
super(parent, batch, batchPolicy, isOperation);
this.keys = keys;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = ops;
this.listener = listener;
this.readAttr = readAttr;
Expand Down Expand Up @@ -963,7 +970,7 @@ protected boolean retryBatch(Runnable other, long deadline) {
// This can cause an exponential number of commands.
List<BatchNode> batchNodes = generateBatchNodes();

if (batchNodes.size() == 0 || (batchNodes.size() == 1 && batchNodes.get(0).node == batch.node)) {
if (batchNodes.isEmpty() || (batchNodes.size() == 1 && batchNodes.getFirst().node == batch.node)) {
// Go through normal retry.
return false;
}
Expand Down
14 changes: 11 additions & 3 deletions client/src/com/aerospike/client/async/AsyncBatchSingle.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ReadGetSequence(
}

@Override
protected final boolean parseResult() {
protected boolean parseResult() {
super.parseResult();

try {
Expand Down Expand Up @@ -181,7 +181,11 @@ public Get(
boolean isOperation
) {
super(executor, cluster, policy, key, node, false);
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.records = records;
this.index = index;
this.isOperation = isOperation;
Expand Down Expand Up @@ -242,7 +246,11 @@ public GetSequence(
) {
super(executor, cluster, policy, key, node, false);
this.listener = listener;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.isOperation = isOperation;
}

Expand Down
8 changes: 6 additions & 2 deletions client/src/com/aerospike/client/async/AsyncRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public AsyncRead(Cluster cluster, RecordListener listener, Policy policy, Key ke
super(policy, true);
this.listener = listener;
this.key = key;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.isOperation = false;
this.partition = Partition.read(cluster, policy, key);
cluster.addTran();
Expand Down Expand Up @@ -126,7 +130,7 @@ protected void handleNotFound(int resultCode) {
// Do nothing in default case. Record will be null.
}

private final void handleUdfError(int resultCode) {
private void handleUdfError(int resultCode) {
String ret = (String)record.bins.get("FAILURE");

if (ret == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public AsyncScanPartition(
this.listener = listener;
this.namespace = namespace;
this.setName = setName;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.taskId = taskId;
this.tracker = tracker;
this.nodePartitions = nodePartitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public AsyncScanPartitionExecutor(
this.listener = listener;
this.namespace = namespace;
this.setName = setName;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.tracker = tracker;
this.random = new RandomShift();

Expand Down
10 changes: 7 additions & 3 deletions client/src/com/aerospike/client/command/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ public GetArrayCommand(
) {
super(cluster, batch, policy, status, isOperation);
this.keys = keys;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = ops;
this.records = records;
this.readAttr = readAttr;
Expand Down Expand Up @@ -554,15 +558,15 @@ protected boolean retryBatch(
// This is both recursive and exponential.
List<BatchNode> batchNodes = generateBatchNodes();

if (batchNodes.size() == 1 && batchNodes.get(0).node == batch.node) {
if (batchNodes.size() == 1 && batchNodes.getFirst().node == batch.node) {
// Batch node is the same. Go through normal retry.
return false;
}

splitRetry = true;

// Run batch retries in parallel using virtual threads.
try (ExecutorService es = Executors.newThreadPerTaskExecutor(cluster.threadFactory);) {
try (ExecutorService es = Executors.newThreadPerTaskExecutor(cluster.threadFactory)) {
for (BatchNode batchNode : batchNodes) {
BatchCommand command = createCommand(batchNode);
command.sequenceAP = sequenceAP;
Expand Down
6 changes: 5 additions & 1 deletion client/src/com/aerospike/client/command/BatchSingle.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public Read(
) {
super(cluster, policy, status, key, node, false);
this.key = key;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.records = records;
this.index = index;
this.isOperation = isOperation;
Expand Down
6 changes: 5 additions & 1 deletion client/src/com/aerospike/client/command/ReadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public ReadCommand(Cluster cluster, Policy policy, Key key) {
public ReadCommand(Cluster cluster, Policy policy, Key key, String[] binNames) {
super(cluster, policy);
this.key = key;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.partition = Partition.read(cluster, policy, key);
this.isOperation = false;
cluster.addTran();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public ScanPartitionCommand(
super(cluster, scanPolicy, nodePartitions.node, namespace, tracker.socketTimeout, tracker.totalTimeout);
this.scanPolicy = scanPolicy;
this.setName = setName;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.callback = callback;
this.taskId = taskId;
this.tracker = tracker;
Expand Down
6 changes: 5 additions & 1 deletion client/src/com/aerospike/client/query/Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ public String getIndexName() {
* Set query bin names.
*/
public void setBinNames(String... binNames) {
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
}

/**
Expand Down
16 changes: 12 additions & 4 deletions proxy/src/com/aerospike/client/proxy/BatchProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class BatchProxy {
//-------------------------------------------------------

public interface BatchListListenerSync {
public void onSuccess(List<BatchRead> records, boolean status);
public void onFailure(AerospikeException ae);
void onSuccess(List<BatchRead> records, boolean status);
void onFailure(AerospikeException ae);
}

public static final class ReadListCommandSync extends BaseCommand {
Expand Down Expand Up @@ -217,7 +217,11 @@ public GetArrayCommand(
super(executor, batchPolicy, isOperation, keys.length);
this.listener = listener;
this.keys = keys;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = ops;
this.readAttr = readAttr;
this.records = new Record[keys.length];
Expand Down Expand Up @@ -276,7 +280,11 @@ public GetSequenceCommand(
super(executor, batchPolicy, isOperation, keys.length);
this.listener = listener;
this.keys = keys;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.ops = ops;
this.readAttr = readAttr;
}
Expand Down
6 changes: 5 additions & 1 deletion proxy/src/com/aerospike/client/proxy/ReadCommandProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public ReadCommandProxy(
super(KVSGrpc.getReadStreamingMethod(), executor, policy);
this.listener = listener;
this.key = key;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.isOperation = false;
}

Expand Down
6 changes: 5 additions & 1 deletion proxy/src/com/aerospike/client/proxy/ScanCommandProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public ScanCommandProxy(
listener, partitionTracker);
this.namespace = namespace;
this.setName = setName;
this.binNames = binNames;
if (binNames == null || binNames.length == 0) {
this.binNames = null;
} else {
this.binNames = binNames;
}
this.partitionFilter = partitionFilter;
}

Expand Down
Loading