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
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLongArray;
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -202,10 +201,10 @@ public Queue<Node> newQueryPlanRegular(@Nullable Request request, @Nullable Sess
Object[] currentNodes = getLiveNodes().dc(getLocalDatacenter()).toArray();
int replicaCount = 0; // in currentNodes
if (!replicas.isEmpty()) {
Pair<Integer, Integer> counts = moveReplicasToFront(currentNodes, replicas);
replicaCount = counts.getLeft();
int[] counts = moveReplicasToFront(currentNodes, replicas);
replicaCount = counts[0];

int localRackReplicaCount = counts.getRight(); // in currentNodes
int localRackReplicaCount = counts[1]; // in currentNodes

if (replicaCount > 1) {
shuffleLocalRackReplicasAndReplicas(currentNodes, replicaCount, localRackReplicaCount);
Expand Down Expand Up @@ -249,8 +248,7 @@ private static Object[] moveNonLocalReplicasToTheEnd(List<Node> replicas, String
return orderedReplicas;
}

private Pair<Integer, Integer> moveReplicasToFront(
Object[] currentNodes, List<Node> allReplicas) {
private int[] moveReplicasToFront(Object[] currentNodes, List<Node> allReplicas) {
int replicaCount = 0, localRackReplicaCount = 0;
for (int i = 0; i < currentNodes.length; i++) {
Node node = (Node) currentNodes[i];
Expand All @@ -265,7 +263,7 @@ private Pair<Integer, Integer> moveReplicasToFront(
replicaCount++;
}
}
return Pair.of(replicaCount, localRackReplicaCount);
return new int[] {replicaCount, localRackReplicaCount};
}

private void shuffleLocalRackReplicasAndReplicas(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.nio.ByteBuffer;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.HashMap;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down Expand Up @@ -128,7 +128,10 @@ public void should_throw_on_encode_with_too_few_elements(TestDataContainer testD
@Test
@UseDataProvider("dataProvider")
public void should_throw_on_encode_with_too_many_elements(TestDataContainer testData) {
Object[] doubled = ArrayUtils.addAll(testData.getValues(), testData.getValues());
Object[] first = testData.getValues();
Object[] second = testData.getValues();
Object[] doubled = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, doubled, first.length, second.length);
TypeCodec<CqlVector<Object>> codec = getCodec(testData.getDataType());
assertThatThrownBy(() -> codec.encode(CqlVector.newInstance(doubled), ProtocolVersion.DEFAULT))
.isInstanceOf(IllegalArgumentException.class);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<skipUnitTests>${skipTests}</skipUnitTests>
<release.autopublish>false</release.autopublish>
<pushChanges>false</pushChanges>
<mockitoopens.argline />
<mockitoopens.argline/>
</properties>
<dependencyManagement>
<dependencies>
Expand Down
Loading