You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2019/11/26 14:05:11 UTC
[kudu] 01/02: [java] Fix kudu-client checkstyle warnings
This is an automated email from the ASF dual-hosted git repository.
granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
commit d98f4c83b8119ecca3c1f2107184d5c603c479f7
Author: Grant Henke <gr...@apache.org>
AuthorDate: Mon Nov 25 08:50:08 2019 -0600
[java] Fix kudu-client checkstyle warnings
This patch fixes all of the checkstlyle warnings reported by:
./gradlew :kudu-client:checkstyle
I also included some trivial style changes and suppression annotations.
A follow on patch will enforce confoming to checkstyle rules in the
pre-commit build.
Change-Id: I153b7bf11b505871703da729720c988dd7c212f9
Reviewed-on: http://gerrit.cloudera.org:8080/14775
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
java/config/checkstyle/checkstyle.xml | 6 +
.../main/java/org/apache/kudu/ColumnSchema.java | 19 +-
.../src/main/java/org/apache/kudu/Schema.java | 4 +-
.../src/main/java/org/apache/kudu/Type.java | 4 +-
.../kudu/client/AbstractKuduScannerBuilder.java | 20 ++
.../org/apache/kudu/client/AlterTableRequest.java | 2 +-
.../org/apache/kudu/client/AsyncKuduClient.java | 141 +++++++-------
.../org/apache/kudu/client/AsyncKuduScanner.java | 11 +-
.../org/apache/kudu/client/AsyncKuduSession.java | 15 +-
.../apache/kudu/client/AuthnTokenReacquirer.java | 6 +-
.../org/apache/kudu/client/AuthzTokenCache.java | 7 +-
.../main/java/org/apache/kudu/client/Batch.java | 4 +-
.../main/java/org/apache/kudu/client/Bytes.java | 11 +-
.../org/apache/kudu/client/ConnectToCluster.java | 5 +-
.../kudu/client/ExternalConsistencyMode.java | 2 +-
.../apache/kudu/client/GetTableSchemaRequest.java | 2 +-
.../java/org/apache/kudu/client/HostAndPort.java | 9 +-
.../java/org/apache/kudu/client/KeyEncoder.java | 12 +-
.../main/java/org/apache/kudu/client/KeyRange.java | 8 +-
.../java/org/apache/kudu/client/KuduClient.java | 3 +-
.../org/apache/kudu/client/KuduPartitioner.java | 12 +-
.../java/org/apache/kudu/client/KuduPredicate.java | 18 +-
.../main/java/org/apache/kudu/client/KuduRpc.java | 11 +-
.../java/org/apache/kudu/client/KuduScanToken.java | 17 +-
.../apache/kudu/client/KuduScannerIterator.java | 6 +-
.../java/org/apache/kudu/client/KuduTable.java | 4 +-
.../org/apache/kudu/client/ListTablesResponse.java | 8 +-
.../kudu/client/ListTabletServersRequest.java | 2 +-
.../org/apache/kudu/client/ListTabletsRequest.java | 5 +-
.../java/org/apache/kudu/client/Negotiator.java | 10 +-
.../java/org/apache/kudu/client/Operation.java | 3 +-
.../java/org/apache/kudu/client/PartialRow.java | 144 +++++++++------
.../java/org/apache/kudu/client/Partition.java | 6 +-
.../org/apache/kudu/client/PartitionPruner.java | 4 +-
.../org/apache/kudu/client/ProtobufHelper.java | 6 +-
.../java/org/apache/kudu/client/RemoteTablet.java | 6 +-
.../org/apache/kudu/client/RequestTracker.java | 2 +-
.../org/apache/kudu/client/ResourceMetrics.java | 11 +-
.../java/org/apache/kudu/client/RowResult.java | 4 +-
.../org/apache/kudu/client/RowResultIterator.java | 3 +-
.../main/java/org/apache/kudu/client/RpcProxy.java | 21 +--
.../java/org/apache/kudu/client/RpcTraceFrame.java | 5 +-
.../org/apache/kudu/client/SecurityContext.java | 3 +-
.../apache/kudu/client/SplitKeyRangeRequest.java | 8 +-
.../java/org/apache/kudu/util/BloomFilter.java | 73 ++++----
.../main/java/org/apache/kudu/util/CharUtil.java | 3 +-
.../java/org/apache/kudu/util/DataGenerator.java | 37 ++--
.../java/org/apache/kudu/util/DecimalUtil.java | 3 +-
.../java/org/apache/kudu/util/SchemaGenerator.java | 4 +-
.../src/main/java/org/apache/kudu/util/Slices.java | 7 +-
.../main/java/org/apache/kudu/util/StringUtil.java | 3 +-
.../java/org/apache/kudu/TestColumnSchema.java | 11 +-
.../src/test/java/org/apache/kudu/TestType.java | 2 +-
.../test/java/org/apache/kudu/client/ITClient.java | 3 +-
.../org/apache/kudu/client/ITClientStress.java | 7 +-
.../kudu/client/ITNonFaultTolerantScanner.java | 6 +-
.../apache/kudu/client/ITScannerMultiTablet.java | 3 +-
.../org/apache/kudu/client/TestAlterTable.java | 22 ++-
.../apache/kudu/client/TestAsyncKuduClient.java | 15 +-
.../apache/kudu/client/TestAsyncKuduSession.java | 3 +-
.../apache/kudu/client/TestAuthTokenReacquire.java | 28 +--
.../kudu/client/TestAuthnTokenReacquireOpen.java | 28 +--
.../apache/kudu/client/TestAuthzTokenCache.java | 4 +-
.../java/org/apache/kudu/client/TestBitSet.java | 1 +
.../org/apache/kudu/client/TestBloomFilter.java | 113 ++++++------
.../java/org/apache/kudu/client/TestBytes.java | 34 ++--
.../kudu/client/TestClientFailoverSupport.java | 27 +--
.../kudu/client/TestColumnRangePredicate.java | 22 ++-
.../apache/kudu/client/TestConnectToCluster.java | 14 +-
.../apache/kudu/client/TestConnectionCache.java | 1 +
.../org/apache/kudu/client/TestErrorCollector.java | 1 +
.../kudu/client/TestFlexiblePartitioning.java | 86 +++++----
.../org/apache/kudu/client/TestHandleTooBusy.java | 11 +-
.../org/apache/kudu/client/TestHybridTime.java | 12 +-
.../org/apache/kudu/client/TestKeyEncoding.java | 15 +-
.../org/apache/kudu/client/TestKuduClient.java | 142 +++++++-------
.../apache/kudu/client/TestKuduPartitioner.java | 18 +-
.../org/apache/kudu/client/TestKuduPredicate.java | 204 ++++++++++++---------
.../org/apache/kudu/client/TestKuduScanner.java | 12 +-
.../org/apache/kudu/client/TestKuduSession.java | 8 +-
.../java/org/apache/kudu/client/TestKuduTable.java | 102 +++++++----
.../org/apache/kudu/client/TestLeaderFailover.java | 1 +
.../org/apache/kudu/client/TestMasterFailover.java | 8 +-
.../kudu/client/TestMultipleLeaderFailover.java | 6 +-
.../org/apache/kudu/client/TestNegotiation.java | 4 +-
.../org/apache/kudu/client/TestNegotiator.java | 2 +-
.../java/org/apache/kudu/client/TestOperation.java | 13 +-
.../org/apache/kudu/client/TestPartialRow.java | 123 +++++++++----
.../apache/kudu/client/TestPartitionPruner.java | 49 +++--
.../org/apache/kudu/client/TestRemoteTablet.java | 1 +
.../org/apache/kudu/client/TestRequestTracker.java | 2 +
.../java/org/apache/kudu/client/TestRowErrors.java | 3 +-
.../java/org/apache/kudu/client/TestRowResult.java | 21 ++-
.../java/org/apache/kudu/client/TestRpcTraces.java | 1 +
.../org/apache/kudu/client/TestScanPredicate.java | 22 +--
.../java/org/apache/kudu/client/TestScanToken.java | 12 +-
.../apache/kudu/client/TestScannerMultiTablet.java | 13 +-
.../java/org/apache/kudu/client/TestSecurity.java | 26 +--
.../kudu/client/TestSecurityContextRealUser.java | 5 +-
.../org/apache/kudu/client/TestServerInfo.java | 1 +
.../org/apache/kudu/client/TestSplitKeyRange.java | 17 +-
.../org/apache/kudu/client/TestStatistics.java | 5 +-
.../java/org/apache/kudu/client/TestStatus.java | 1 +
.../kudu/client/TestTableLocationsCache.java | 4 +
.../org/apache/kudu/client/TestTimeoutTracker.java | 1 +
.../java/org/apache/kudu/client/TestTimeouts.java | 1 +
.../java/org/apache/kudu/util/TestAsyncUtil.java | 11 +-
.../java/org/apache/kudu/util/TestByteVec.java | 5 +-
.../java/org/apache/kudu/util/TestMurmurHash.java | 8 +-
.../java/org/apache/kudu/util/TestNetUtil.java | 17 +-
.../java/org/apache/kudu/util/TestStringUtil.java | 1 +
.../org/apache/kudu/util/TestTimestampUtil.java | 1 +
112 files changed, 1209 insertions(+), 871 deletions(-)
diff --git a/java/config/checkstyle/checkstyle.xml b/java/config/checkstyle/checkstyle.xml
index 633ea40..b0ef88f 100644
--- a/java/config/checkstyle/checkstyle.xml
+++ b/java/config/checkstyle/checkstyle.xml
@@ -64,6 +64,12 @@
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="TreeWalker">
+ <!-- Excludes checks between //CHECKSTYLE:OFF and //CHECKSTYLE:ON comments -->
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\:OFF"/>
+ <property name="onCommentFormat" value="CHECKSTYLE\:ON"/>
+ </module>
+
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java b/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
index 81a352c..933aa66 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/ColumnSchema.java
@@ -17,17 +17,16 @@
package org.apache.kudu;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
-import org.apache.kudu.util.CharUtil;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
import org.apache.kudu.Common.EncodingType;
import org.apache.kudu.Compression.CompressionType;
+import org.apache.kudu.util.CharUtil;
/**
* Represents a Kudu Table column. Use {@link ColumnSchema.ColumnSchemaBuilder} in order to
@@ -220,8 +219,12 @@ public class ColumnSchema {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ColumnSchema)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ColumnSchema)) {
+ return false;
+ }
ColumnSchema that = (ColumnSchema) o;
return Objects.equals(name, that.name) &&
Objects.equals(type, that.type) &&
@@ -421,9 +424,9 @@ public class ColumnSchema {
this.wireType = type.getDataType(typeAttributes);
}
if (type == Type.VARCHAR) {
- if (typeAttributes == null || !typeAttributes.hasLength()
- || typeAttributes.getLength() < CharUtil.MIN_VARCHAR_LENGTH
- || typeAttributes.getLength() > CharUtil.MAX_VARCHAR_LENGTH) {
+ if (typeAttributes == null || !typeAttributes.hasLength() ||
+ typeAttributes.getLength() < CharUtil.MIN_VARCHAR_LENGTH ||
+ typeAttributes.getLength() > CharUtil.MAX_VARCHAR_LENGTH) {
throw new IllegalArgumentException(
String.format("VARCHAR's length must be set and between %d and %d",
CharUtil.MIN_VARCHAR_LENGTH, CharUtil.MAX_VARCHAR_LENGTH));
@@ -433,6 +436,6 @@ public class ColumnSchema {
key, nullable, defaultValue,
desiredBlockSize, encoding, compressionAlgorithm,
typeAttributes, wireType, comment);
- }
+ }
}
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/Schema.java b/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
index 3251550..3ba1b85 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/Schema.java
@@ -109,8 +109,8 @@ public class Schema {
int varLenCnt = 0;
this.columnOffsets = new int[columns.size()];
this.columnsByName = new HashMap<>(columns.size());
- this.columnsById = hasColumnIds ? new HashMap<Integer, Integer>(columnIds.size()) : null;
- this.columnIdByName = hasColumnIds ? new HashMap<String, Integer>(columnIds.size()) : null;
+ this.columnsById = hasColumnIds ? new HashMap<>(columnIds.size()) : null;
+ this.columnIdByName = hasColumnIds ? new HashMap<>(columnIds.size()) : null;
int offset = 0;
boolean hasNulls = false;
int isDeletedIndex = NO_IS_DELETED_INDEX;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/Type.java b/java/kudu-client/src/main/java/org/apache/kudu/Type.java
index 16b7726..8cd243c 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/Type.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/Type.java
@@ -60,13 +60,13 @@ public enum Type {
* @param dataType DataType from the common's pb
* @param name string representation of the type
*/
- private Type(DataType dataType, String name) {
+ Type(DataType dataType, String name) {
this.dataTypes = ImmutableList.of(dataType);
this.name = name;
this.size = getTypeSize(dataType);
}
- private Type(List<DataType> dataTypes, String name) {
+ Type(List<DataType> dataTypes, String name) {
this.dataTypes = ImmutableList.copyOf(dataTypes);
this.name = name;
this.size = -1;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AbstractKuduScannerBuilder.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AbstractKuduScannerBuilder.java
index 5865876..0e6b2d7 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AbstractKuduScannerBuilder.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AbstractKuduScannerBuilder.java
@@ -70,6 +70,7 @@ public abstract class AbstractKuduScannerBuilder
* @param readMode a read mode for the scanner
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S readMode(AsyncKuduScanner.ReadMode readMode) {
this.readMode = readMode;
return (S) this;
@@ -91,6 +92,7 @@ public abstract class AbstractKuduScannerBuilder
* @param isFaultTolerant a boolean that indicates if scan is fault-tolerant
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S setFaultTolerant(boolean isFaultTolerant) {
this.isFaultTolerant = isFaultTolerant;
if (isFaultTolerant) {
@@ -119,6 +121,7 @@ public abstract class AbstractKuduScannerBuilder
* @deprecated use {@link #addPredicate}
*/
@Deprecated
+ @SuppressWarnings("unchecked")
public S addColumnRangePredicatesRaw(byte[] predicateBytes) {
for (Tserver.ColumnRangePredicatePB pb : ColumnRangePredicate.fromByteArray(predicateBytes)) {
addPredicate(ColumnRangePredicate.fromPb(pb).toKuduPredicate());
@@ -131,6 +134,7 @@ public abstract class AbstractKuduScannerBuilder
* @param predicate predicate to add
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S addPredicate(KuduPredicate predicate) {
String columnName = predicate.getColumn().getName();
KuduPredicate existing = predicates.get(columnName);
@@ -155,6 +159,7 @@ public abstract class AbstractKuduScannerBuilder
* @param columnNames the names of columns to read, or 'null' to read all columns
* (the default)
*/
+ @SuppressWarnings("unchecked")
public S setProjectedColumnNames(List<String> columnNames) {
projectedColumnIndexes = null;
if (columnNames != null) {
@@ -172,6 +177,7 @@ public abstract class AbstractKuduScannerBuilder
* @param columnIndexes the indexes of columns to read, or 'null' to read all columns
* (the default)
*/
+ @SuppressWarnings("unchecked")
public S setProjectedColumnIndexes(List<Integer> columnIndexes) {
projectedColumnNames = null;
if (columnIndexes != null) {
@@ -190,6 +196,7 @@ public abstract class AbstractKuduScannerBuilder
* @param batchSizeBytes a strictly positive number of bytes
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S batchSizeBytes(int batchSizeBytes) {
this.batchSizeBytes = batchSizeBytes;
return (S) this;
@@ -202,6 +209,7 @@ public abstract class AbstractKuduScannerBuilder
* @param limit a positive long
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S limit(long limit) {
this.limit = limit;
return (S) this;
@@ -215,6 +223,7 @@ public abstract class AbstractKuduScannerBuilder
* @param prefetching a boolean that indicates if the scanner should prefetch rows
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S prefetching(boolean prefetching) {
this.prefetching = prefetching;
return (S) this;
@@ -226,6 +235,7 @@ public abstract class AbstractKuduScannerBuilder
* @param cacheBlocks a boolean that indicates if data blocks should be cached or not
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S cacheBlocks(boolean cacheBlocks) {
this.cacheBlocks = cacheBlocks;
return (S) this;
@@ -241,6 +251,7 @@ public abstract class AbstractKuduScannerBuilder
* read mode was not set to READ_AT_SNAPSHOT
*/
@InterfaceAudience.Private
+ @SuppressWarnings("unchecked")
public S snapshotTimestampRaw(long htTimestamp) {
this.htTimestamp = htTimestamp;
return (S) this;
@@ -255,6 +266,7 @@ public abstract class AbstractKuduScannerBuilder
* @throws IllegalArgumentException on build(), if the timestamp is less than 0 or if the
* read mode was not set to READ_AT_SNAPSHOT
*/
+ @SuppressWarnings("unchecked")
public S snapshotTimestampMicros(long timestamp) {
this.htTimestamp = HybridTimeUtil.physicalAndLogicalToHTTimestamp(timestamp, 0);
return (S) this;
@@ -271,6 +283,7 @@ public abstract class AbstractKuduScannerBuilder
* @return this instance
*/
@InterfaceAudience.Private
+ @SuppressWarnings("unchecked")
public S diffScan(long startTimestamp, long endTimestamp) {
this.startTimestamp = startTimestamp;
this.htTimestamp = endTimestamp;
@@ -285,6 +298,7 @@ public abstract class AbstractKuduScannerBuilder
* @param scanRequestTimeout a long representing time in milliseconds
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S scanRequestTimeout(long scanRequestTimeout) {
this.scanRequestTimeout = scanRequestTimeout;
return (S) this;
@@ -308,6 +322,7 @@ public abstract class AbstractKuduScannerBuilder
* @deprecated use {@link #lowerBound(PartialRow)}
*/
@Deprecated
+ @SuppressWarnings("unchecked")
public S lowerBoundRaw(byte[] startPrimaryKey) {
if (lowerBoundPrimaryKey.length == 0 ||
Bytes.memcmp(startPrimaryKey, lowerBoundPrimaryKey) > 0) {
@@ -334,6 +349,7 @@ public abstract class AbstractKuduScannerBuilder
* @deprecated use {@link #exclusiveUpperBound(PartialRow)}
*/
@Deprecated
+ @SuppressWarnings("unchecked")
public S exclusiveUpperBoundRaw(byte[] endPrimaryKey) {
if (upperBoundPrimaryKey.length == 0 ||
Bytes.memcmp(endPrimaryKey, upperBoundPrimaryKey) < 0) {
@@ -348,6 +364,7 @@ public abstract class AbstractKuduScannerBuilder
* @param replicaSelection replication selection mechanism to use
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S replicaSelection(ReplicaSelection replicaSelection) {
this.replicaSelection = replicaSelection;
return (S) this;
@@ -359,6 +376,7 @@ public abstract class AbstractKuduScannerBuilder
* @param partitionKey the encoded partition key
* @return this instance
*/
+ @SuppressWarnings("unchecked")
S lowerBoundPartitionKeyRaw(byte[] partitionKey) {
if (Bytes.memcmp(partitionKey, lowerBoundPartitionKey) > 0) {
this.lowerBoundPartitionKey = partitionKey;
@@ -372,6 +390,7 @@ public abstract class AbstractKuduScannerBuilder
* @param partitionKey the encoded partition key
* @return this instance
*/
+ @SuppressWarnings("unchecked")
S exclusiveUpperBoundPartitionKeyRaw(byte[] partitionKey) {
if (upperBoundPartitionKey.length == 0 ||
Bytes.memcmp(partitionKey, upperBoundPartitionKey) < 0) {
@@ -387,6 +406,7 @@ public abstract class AbstractKuduScannerBuilder
* @param keepAlivePeriodMs the keep alive period in milliseconds
* @return this instance
*/
+ @SuppressWarnings("unchecked")
public S keepAlivePeriodMs(long keepAlivePeriodMs) {
this.keepAlivePeriodMs = keepAlivePeriodMs;
return (S) this;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AlterTableRequest.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AlterTableRequest.java
index 5734c67..0ebb6ba 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AlterTableRequest.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AlterTableRequest.java
@@ -54,7 +54,7 @@ class AlterTableRequest extends KuduRpc<AlterTableResponse> {
this.builder = ato.getProtobuf();
this.requiredFeatures = ato.hasAddDropRangePartitions() ?
ImmutableList.of(MasterFeatures.RANGE_PARTITION_BOUNDS_VALUE) :
- ImmutableList.<Integer>of();
+ ImmutableList.of();
}
@Override
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
index 8f5050b..a286116 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
@@ -692,10 +692,10 @@ public class AsyncKuduClient implements AutoCloseable {
// If requested, add a callback that waits until all of the table's tablets
// have been altered.
return responseD.addCallbackDeferring(resp -> {
- TableIdentifierPB.Builder table = TableIdentifierPB.newBuilder()
- .setTableId(ByteString.copyFromUtf8(resp.getTableId()));
- return getDelayedIsAlterTableDoneDeferred(table, alter, resp);
- });
+ TableIdentifierPB.Builder table = TableIdentifierPB.newBuilder()
+ .setTableId(ByteString.copyFromUtf8(resp.getTableId()));
+ return getDelayedIsAlterTableDoneDeferred(table, alter, resp);
+ });
}
/**
@@ -835,7 +835,7 @@ public class AsyncKuduClient implements AutoCloseable {
return AsyncUtil.addCallbacksDeferring(
getTableSchema(name, null, null),
- _table -> Deferred.fromResult(true),
+ table -> Deferred.fromResult(true),
(Callback<Deferred<Boolean>, Exception>) e -> {
if (e instanceof NonRecoverableException) {
Status status = ((NonRecoverableException) e).getStatus();
@@ -914,7 +914,7 @@ public class AsyncKuduClient implements AutoCloseable {
return null;
})
.addErrback(new RetryTaskErrback<>(
- fakeRpc, _ignored -> doExportAuthenticationCredentials(fakeRpc)));
+ fakeRpc, ignored -> doExportAuthenticationCredentials(fakeRpc)));
}
@InterfaceAudience.LimitedPrivate("Test")
@@ -1203,8 +1203,8 @@ public class AsyncKuduClient implements AutoCloseable {
}
final KuduRpc<Void> keepAliveRequest = scanner.getKeepAliveRequest();
- final ServerInfo info = tablet.getReplicaSelectedServerInfo(keepAliveRequest.getReplicaSelection(),
- location);
+ final ServerInfo info =
+ tablet.getReplicaSelectedServerInfo(keepAliveRequest.getReplicaSelection(), location);
if (info == null) {
return Deferred.fromResult(null);
}
@@ -1506,10 +1506,11 @@ public class AsyncKuduClient implements AutoCloseable {
* @param alterResp response from an earlier AlterTable RPC, if any
* @return callback that will eventually return 'alterResp'
*/
- private Callback<Deferred<AlterTableResponse>, IsAlterTableDoneResponse> getDelayedIsAlterTableDoneCB(
- @Nonnull final KuduRpc<AlterTableResponse> rpc,
- @Nonnull final TableIdentifierPB.Builder table,
- @Nullable final AlterTableResponse alterResp) {
+ private Callback<Deferred<AlterTableResponse>, IsAlterTableDoneResponse>
+ getDelayedIsAlterTableDoneCB(
+ @Nonnull final KuduRpc<AlterTableResponse> rpc,
+ @Nonnull final TableIdentifierPB.Builder table,
+ @Nullable final AlterTableResponse alterResp) {
return resp -> {
// Store the Deferred locally; callback() below will reset it and we'd
// return a different, non-triggered Deferred.
@@ -1756,41 +1757,40 @@ public class AsyncKuduClient implements AutoCloseable {
// TODO(todd): stop using this 'masterTable' hack.
return ConnectToCluster.run(masterTable, masterAddresses, parentRpc,
defaultAdminOperationTimeoutMs, Connection.CredentialsPolicy.ANY_CREDENTIALS).addCallback(
- resp -> {
- if (resp.getConnectResponse().hasAuthnToken()) {
- // If the response has security info, adopt it.
- securityContext.setAuthenticationToken(resp.getConnectResponse().getAuthnToken());
- }
- List<ByteString> caCerts = resp.getConnectResponse().getCaCertDerList();
- if (!caCerts.isEmpty()) {
- try {
- securityContext.trustCertificates(caCerts);
- } catch (CertificateException e) {
- LOG.warn("Ignoring invalid CA cert from leader {}: {}",
- resp.getLeaderHostAndPort(),
- e.getMessage());
- }
- }
-
- HiveMetastoreConfig hiveMetastoreConfig = null;
- Master.ConnectToMasterResponsePB respPb = resp.getConnectResponse();
- if (respPb.hasHmsConfig()) {
- Master.HiveMetastoreConfig metastoreConf = respPb.getHmsConfig();
- hiveMetastoreConfig = new HiveMetastoreConfig(metastoreConf.getHmsUris(),
- metastoreConf.getHmsSaslEnabled(),
- metastoreConf.getHmsUuid());
- }
- synchronized (AsyncKuduClient.this) {
- AsyncKuduClient.this.hiveMetastoreConfig = hiveMetastoreConfig;
- location = respPb.getClientLocation();
- }
-
- hasConnectedToMaster = true;
-
- // Translate the located master into a TableLocations
- // since the rest of our locations caching code expects this type.
- return resp.getAsTableLocations();
- });
+ resp -> {
+ if (resp.getConnectResponse().hasAuthnToken()) {
+ // If the response has security info, adopt it.
+ securityContext.setAuthenticationToken(resp.getConnectResponse().getAuthnToken());
+ }
+ List<ByteString> caCerts = resp.getConnectResponse().getCaCertDerList();
+ if (!caCerts.isEmpty()) {
+ try {
+ securityContext.trustCertificates(caCerts);
+ } catch (CertificateException e) {
+ LOG.warn("Ignoring invalid CA cert from leader {}: {}",
+ resp.getLeaderHostAndPort(), e.getMessage());
+ }
+ }
+
+ HiveMetastoreConfig hiveMetastoreConfig = null;
+ Master.ConnectToMasterResponsePB respPb = resp.getConnectResponse();
+ if (respPb.hasHmsConfig()) {
+ Master.HiveMetastoreConfig metastoreConf = respPb.getHmsConfig();
+ hiveMetastoreConfig = new HiveMetastoreConfig(metastoreConf.getHmsUris(),
+ metastoreConf.getHmsSaslEnabled(),
+ metastoreConf.getHmsUuid());
+ }
+ synchronized (AsyncKuduClient.this) {
+ AsyncKuduClient.this.hiveMetastoreConfig = hiveMetastoreConfig;
+ location = respPb.getClientLocation();
+ }
+
+ hasConnectedToMaster = true;
+
+ // Translate the located master into a TableLocations
+ // since the rest of our locations caching code expects this type.
+ return resp.getAsTableLocations();
+ });
}
/**
@@ -2004,28 +2004,28 @@ public class AsyncKuduClient implements AutoCloseable {
tablet.getPartition().getPartitionKeyStart(),
splitSizeBytes,
fakeRpc)
- .addCallbackDeferring(resp -> {
- final List<KeyRange> ranges = Lists.newArrayList();
- LOG.debug("Key ranges for {}", table.getName());
- for (Common.KeyRangePB pb : resp.getKeyRanges()) {
- KeyRange newRange = new KeyRange(tablet,
- pb.getStartPrimaryKey().toByteArray(),
- pb.getStopPrimaryKey().toByteArray(),
- pb.getSizeBytesEstimates());
- ranges.add(newRange);
- LOG.debug(newRange.toString());
- }
- return Deferred.fromResult(ranges);
- }));
+ .addCallbackDeferring(resp -> {
+ final List<KeyRange> ranges = Lists.newArrayList();
+ LOG.debug("Key ranges for {}", table.getName());
+ for (Common.KeyRangePB pb : resp.getKeyRanges()) {
+ KeyRange newRange = new KeyRange(tablet,
+ pb.getStartPrimaryKey().toByteArray(),
+ pb.getStopPrimaryKey().toByteArray(),
+ pb.getSizeBytesEstimates());
+ ranges.add(newRange);
+ LOG.debug(newRange.toString());
+ }
+ return Deferred.fromResult(ranges);
+ }));
}
// Must preserve the order.
return Deferred.groupInOrder(deferreds).addCallbackDeferring(rangeLists -> {
- final List<KeyRange> ret = Lists.newArrayList();
- for (List<KeyRange> ranges : rangeLists) {
- ret.addAll(ranges);
- }
- return Deferred.fromResult(ret);
- });
+ final List<KeyRange> ret = Lists.newArrayList();
+ for (List<KeyRange> ranges : rangeLists) {
+ ret.addAll(ranges);
+ }
+ return Deferred.fromResult(ret);
+ });
};
final List<LocatedTablet> tablets = Lists.newArrayList();
@@ -2142,7 +2142,7 @@ public class AsyncKuduClient implements AutoCloseable {
// in parallel. Asynchbase does some hacking with a "probe" RPC while putting the other ones
// on hold but we won't be doing this for the moment. Regions in HBase can move a lot,
// we're not expecting this in Kudu.
- newTimeout(timer, _timeout -> sendRpcToTablet(rpc), sleepTime);
+ newTimeout(timer, timeout -> sendRpcToTablet(rpc), sleepTime);
return rpc.getDeferred();
}
@@ -2316,8 +2316,8 @@ public class AsyncKuduClient implements AutoCloseable {
int tsInfoIdx = replica.getTsInfoIdx();
if (tsInfoIdx >= numTsInfos) {
lookupExceptions.add(new NonRecoverableException(Status.Corruption(
- String.format("invalid response from master: referenced tablet idx %d but only %d present",
- tsInfoIdx, numTsInfos))));
+ String.format("invalid response from master: referenced tablet idx %d but only %d " +
+ "present", tsInfoIdx, numTsInfos))));
continue;
}
TSInfoPB tsInfo = tsInfosList.get(tsInfoIdx);
@@ -2435,8 +2435,7 @@ public class AsyncKuduClient implements AutoCloseable {
"Table location expired before it could be processed")));
}
if (entry.isNonCoveredRange()) {
- if (lookupType == LookupType.POINT
- || entry.getUpperBoundPartitionKey().length == 0) {
+ if (lookupType == LookupType.POINT || entry.getUpperBoundPartitionKey().length == 0) {
return Deferred.fromError(
new NonCoveredRangeException(entry.getLowerBoundPartitionKey(),
entry.getUpperBoundPartitionKey()));
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
index e194bf0..7fca149 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
@@ -311,7 +311,7 @@ public final class AsyncKuduScanner {
// Map the column names to actual columns in the table schema.
// If the user set this to 'null', we scan all columns.
- List<ColumnSchema> columns = new ArrayList<ColumnSchema>();
+ List<ColumnSchema> columns = new ArrayList<>();
if (projectedNames != null) {
for (String columnName : projectedNames) {
ColumnSchema originalColumn = table.getSchema().getColumn(columnName);
@@ -974,7 +974,7 @@ public final class AsyncKuduScanner {
readProtobuf(callResponse.getPBMessage(), builder);
ScannerKeepAliveResponsePB resp = builder.build();
TabletServerErrorPB error = resp.hasError() ? resp.getError() : null;
- return new Pair<Void, Object>(null, error);
+ return new Pair<>(null, error);
}
}
@@ -1123,7 +1123,7 @@ public final class AsyncKuduScanner {
case TABLET_NOT_RUNNING:
if (state == State.OPENING || (state == State.NEXT && isFaultTolerant)) {
// Doing this will trigger finding the new location.
- return new Pair<Response, Object>(null, error);
+ return new Pair<>(null, error);
} else {
Status statusIncomplete = Status.Incomplete("Cannot continue scanning, " +
"the tablet has moved and this isn't a fault tolerant scan");
@@ -1141,7 +1141,8 @@ public final class AsyncKuduScanner {
}
// TODO: Find a clean way to plumb in reuseRowResult.
RowResultIterator iterator = RowResultIterator.makeRowResultIterator(
- timeoutTracker.getElapsedMillis(), tsUUID, schema, resp.getData(), callResponse, reuseRowResult);
+ timeoutTracker.getElapsedMillis(), tsUUID, schema, resp.getData(), callResponse,
+ reuseRowResult);
boolean hasMore = resp.getHasMoreResults();
if (id.length != 0 && scannerId != null && !Bytes.equals(scannerId, id)) {
@@ -1161,7 +1162,7 @@ public final class AsyncKuduScanner {
if (LOG.isDebugEnabled()) {
LOG.debug("{} for scanner {}", response.toString(), AsyncKuduScanner.this);
}
- return new Pair<Response, Object>(response, error);
+ return new Pair<>(response, error);
}
@Override
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
index b4b2c37..b9da766 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
@@ -167,7 +167,7 @@ public class AsyncKuduSession implements SessionConfiguration {
* capacity may be available in the active buffer.
*/
private final AtomicReference<Deferred<Void>> flushNotification =
- new AtomicReference<>(new Deferred<Void>());
+ new AtomicReference<>(new Deferred<>());
/**
* Tracks whether the session has been closed.
@@ -231,7 +231,7 @@ public class AsyncKuduSession implements SessionConfiguration {
/**
* Lets us set a specific seed for tests
- * @param seed
+ * @param seed the seed to use
*/
@InterfaceAudience.LimitedPrivate("Test")
void setRandomSeed(long seed) {
@@ -309,7 +309,7 @@ public class AsyncKuduSession implements SessionConfiguration {
private void queueBuffer(Buffer buffer) {
inactiveBuffers.add(buffer);
buffer.callbackFlushNotification();
- Deferred<Void> localFlushNotification = flushNotification.getAndSet(new Deferred<Void>());
+ Deferred<Void> localFlushNotification = flushNotification.getAndSet(new Deferred<>());
localFlushNotification.callback(null);
}
@@ -430,7 +430,7 @@ public class AsyncKuduSession implements SessionConfiguration {
// flushing 'buffer'. This is less performant but has less surprising semantics than
// simultaneously flushing two buffers. Even though we don't promise those semantics,
// I'm going to leave it this way for now because it's never caused any trouble.
- return AsyncUtil.addBothDeferring(nonActiveBufferFlush, _unused -> doFlush(buffer));
+ return AsyncUtil.addBothDeferring(nonActiveBufferFlush, unused -> doFlush(buffer));
}
/**
@@ -618,13 +618,16 @@ public class AsyncKuduSession implements SessionConfiguration {
// 2. If it filled or overflowed the buffer, kick off a flush.
activeBuffer.getOperations().add(new BufferedOperation(tablet, operation));
if (activeBufferSize == 0) {
- AsyncKuduClient.newTimeout(client.getTimer(), activeBuffer.getFlusherTask(), flushIntervalMillis);
+ AsyncKuduClient.newTimeout(client.getTimer(), activeBuffer.getFlusherTask(),
+ flushIntervalMillis);
}
if (activeBufferSize + 1 >= mutationBufferMaxOps && inactiveBufferAvailable()) {
fullBuffer = retireActiveBufferUnlocked();
}
break;
}
+ default:
+ throw new IllegalArgumentException("Unexpected flushMode: " + flushMode);
}
}
} finally {
@@ -677,7 +680,7 @@ public class AsyncKuduSession implements SessionConfiguration {
final Deferred<Void> notificationB = bufferB.getFlushNotification();
if (activeBuffer == null) {
// Both buffers are either flushing or inactive.
- return AsyncUtil.addBothDeferring(notificationA, _unused -> notificationB);
+ return AsyncUtil.addBothDeferring(notificationA, unused -> notificationB);
} else if (activeBuffer == bufferA) {
return notificationB;
} else {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AuthnTokenReacquirer.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AuthnTokenReacquirer.java
index 515878e..04e8ff0 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AuthnTokenReacquirer.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AuthnTokenReacquirer.java
@@ -100,8 +100,8 @@ final class AuthnTokenReacquirer {
private void reacquireAuthnToken() {
- /**
- * An utility class providing callbacks for successful completion of authn token re-acqusition.
+ /*
+ An utility class providing callbacks for successful completion of authn token re-acqusition.
*/
final class NewAuthnTokenCB implements Callback<Void, Boolean> {
/**
@@ -131,7 +131,7 @@ final class AuthnTokenReacquirer {
}
}
- /**
+ /*
* Errback to retry authn token re-acquisition and notify the handle the affected RPCs if the
* re-acquisition failed after some number of retries (currently, it's 5 attempts).
*
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AuthzTokenCache.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AuthzTokenCache.java
index 5e72b11..c774edf 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AuthzTokenCache.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AuthzTokenCache.java
@@ -61,7 +61,8 @@ public class AuthzTokenCache {
private final AsyncKuduClient client;
// Map from a table ID to an authz token for that table.
- private final ConcurrentHashMap<String, Token.SignedTokenPB> authzTokens = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, Token.SignedTokenPB> authzTokens =
+ new ConcurrentHashMap<>();
// Map from a table ID that has an in-flight RPC to get a new authz token, to
// the list of RPCs waiting to be retried once that token is received and the
@@ -171,7 +172,7 @@ public class AuthzTokenCache {
* @param <R> the RPC type
*/
<R> void retrieveAuthzToken(@Nonnull final KuduRpc<R> rpc, @Nonnull final KuduException ex) {
- /**
+ /*
* Handles a response from getting an authz token.
*/
final class NewAuthzTokenCB implements Callback<Void, GetTableSchemaResponse> {
@@ -198,7 +199,7 @@ public class AuthzTokenCache {
}
}
- /**
+ /*
* Handles the case where there was an error getting the new authz token.
*/
final class NewAuthzTokenErrB implements Callback<Void, Exception> {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Batch.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Batch.java
index c2481e5..4d715af 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Batch.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Batch.java
@@ -190,10 +190,10 @@ class Batch extends KuduRpc<BatchResponse> {
Thread.currentThread().interrupt();
}
}
- return new Pair<BatchResponse, Object>(response, injectedError);
+ return new Pair<>(response, injectedError);
}
- return new Pair<BatchResponse, Object>(response,
+ return new Pair<>(response,
builder.hasError() ? builder.getError() : null);
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Bytes.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Bytes.java
index 11572b5..256f6a2 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Bytes.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Bytes.java
@@ -661,7 +661,7 @@ public final class Bytes {
*/
private static void reverseBytes(final byte[] b) {
// Swaps the items until the mid-point is reached.
- for(int i = 0; i < b.length / 2; i++) {
+ for (int i = 0; i < b.length / 2; i++) {
byte temp = b[i];
b[i] = b[b.length - i - 1];
b[b.length - i - 1] = temp;
@@ -803,7 +803,7 @@ public final class Bytes {
long longVal = getLong(b, offset);
return BigDecimal.valueOf(longVal, scale);
case DecimalUtil.DECIMAL128_SIZE:
- BigInteger int128Val = getBigInteger(b, offset);
+ BigInteger int128Val = getBigInteger(b, offset);
return new BigDecimal(int128Val, scale);
default:
throw new IllegalArgumentException("Unsupported decimal type size: " + size);
@@ -830,7 +830,8 @@ public final class Bytes {
* @param offset The offset in the array to start writing at.
* @throws IndexOutOfBoundsException if the byte array is too small.
*/
- public static void setBigDecimal(final byte[] b, final BigDecimal n, int precision, final int offset) {
+ public static void setBigDecimal(final byte[] b, final BigDecimal n, int precision,
+ final int offset) {
int size = DecimalUtil.precisionToSize(precision);
BigInteger bigInt = n.unscaledValue();
switch (size) {
@@ -998,9 +999,7 @@ public final class Bytes {
} catch (UnsupportedOperationException e) {
return "(failed to extract content of buffer of type " +
buf.getClass().getName() + ')';
- } catch (IllegalAccessException e) {
- throw new AssertionError("Should not happen: " + e);
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InvocationTargetException e) {
throw new AssertionError("Should not happen: " + e);
}
return pretty(array);
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
index 42a536e..4ab9ad2 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ConnectToCluster.java
@@ -62,7 +62,7 @@ final class ConnectToCluster {
// Exceptions received so far: kept for debugging purposes.
private final List<Exception> exceptionsReceived =
- Collections.synchronizedList(new ArrayList<Exception>());
+ Collections.synchronizedList(new ArrayList<>());
/**
* If we've received a response from a master which indicates the full
@@ -101,7 +101,8 @@ final class ConnectToCluster {
// basically reuse in some way the master permits.
long timeoutMillis = parentRpc == null ? defaultTimeoutMs :
parentRpc.timeoutTracker.getMillisBeforeTimeout();
- final ConnectToMasterRequest rpc = new ConnectToMasterRequest(masterTable, timer, timeoutMillis);
+ final ConnectToMasterRequest rpc =
+ new ConnectToMasterRequest(masterTable, timer, timeoutMillis);
rpc.setParentRpc(parentRpc);
Deferred<ConnectToMasterResponsePB> d = rpc.getDeferred();
rpc.attempt++;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ExternalConsistencyMode.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ExternalConsistencyMode.java
index 75dc197..22ccd95 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ExternalConsistencyMode.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ExternalConsistencyMode.java
@@ -34,7 +34,7 @@ public enum ExternalConsistencyMode {
COMMIT_WAIT(Common.ExternalConsistencyMode.COMMIT_WAIT);
private final Common.ExternalConsistencyMode pbVersion;
- private ExternalConsistencyMode(Common.ExternalConsistencyMode pbVersion) {
+ ExternalConsistencyMode(Common.ExternalConsistencyMode pbVersion) {
this.pbVersion = pbVersion;
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/GetTableSchemaRequest.java b/java/kudu-client/src/main/java/org/apache/kudu/client/GetTableSchemaRequest.java
index 3e4f04c..acd5744 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/GetTableSchemaRequest.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/GetTableSchemaRequest.java
@@ -57,7 +57,7 @@ public class GetTableSchemaRequest extends KuduRpc<GetTableSchemaResponse> {
this.name = name;
this.requiredFeatures = requiresAuthzTokenSupport ?
ImmutableList.of(Master.MasterFeatures.GENERATE_AUTHZ_TOKEN_VALUE) :
- ImmutableList.<Integer>of();
+ ImmutableList.of();
}
@Override
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/HostAndPort.java b/java/kudu-client/src/main/java/org/apache/kudu/client/HostAndPort.java
index 53917d8..bebffb7 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/HostAndPort.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/HostAndPort.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import java.net.InetSocketAddress;
@@ -56,8 +57,12 @@ public class HostAndPort {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof HostAndPort)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof HostAndPort)) {
+ return false;
+ }
HostAndPort that = (HostAndPort) o;
return Objects.equal(address, that.address);
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
index a2d06bf..a2cafaf 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyEncoder.java
@@ -98,7 +98,7 @@ class KeyEncoder {
}
}
- encodeColumns(row, partitionSchema.getRangeSchema().getColumns(), buf);
+ encodeColumns(row, partitionSchema.getRangeSchema().getColumnIds(), buf);
return buf.toArray();
}
@@ -112,7 +112,7 @@ class KeyEncoder {
public static byte[] encodeRangePartitionKey(PartialRow row,
PartitionSchema.RangeSchema rangeSchema) {
ByteVec buf = ByteVec.create();
- encodeColumns(row, rangeSchema.getColumns(), buf);
+ encodeColumns(row, rangeSchema.getColumnIds(), buf);
return buf.toArray();
}
@@ -293,7 +293,7 @@ class KeyEncoder {
PartitionSchema partitionSchema,
ByteBuffer buf) {
PartialRow row = schema.newPartialRow();
- Iterator<Integer> rangeIds = partitionSchema.getRangeSchema().getColumns().iterator();
+ Iterator<Integer> rangeIds = partitionSchema.getRangeSchema().getColumnIds().iterator();
while (rangeIds.hasNext()) {
int idx = schema.getColumnIndex(rangeIds.next());
if (buf.hasRemaining()) {
@@ -442,7 +442,7 @@ class KeyEncoder {
PartitionSchema partitionSchema,
byte[] lowerBound,
byte[] upperBound) {
- if (partitionSchema.getRangeSchema().getColumns().isEmpty() &&
+ if (partitionSchema.getRangeSchema().getColumnIds().isEmpty() &&
partitionSchema.getHashBucketSchemas().isEmpty()) {
assert lowerBound.length == 0 && upperBound.length == 0;
return "<no-partitioning>";
@@ -463,13 +463,13 @@ class KeyEncoder {
sb.append(hashBuckets);
}
- if (partitionSchema.getRangeSchema().getColumns().size() > 0) {
+ if (partitionSchema.getRangeSchema().getColumnIds().size() > 0) {
if (!hashBuckets.isEmpty()) {
sb.append(", ");
}
List<Integer> idxs = new ArrayList<>();
- for (int id : partitionSchema.getRangeSchema().getColumns()) {
+ for (int id : partitionSchema.getRangeSchema().getColumnIds()) {
idxs.add(schema.getColumnIndex(id));
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyRange.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyRange.java
index 3c7bdd1..f7ed56b 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KeyRange.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KeyRange.java
@@ -93,10 +93,10 @@ class KeyRange {
@Override
public String toString() {
return String.format("[%s, %s), %s, %s",
- primaryKeyStart == null || primaryKeyStart.length == 0
- ? "<start>" : Bytes.hex(primaryKeyStart),
- primaryKeyStart == null || primaryKeyEnd.length == 0
- ? "<end>" : Bytes.hex(primaryKeyEnd),
+ primaryKeyStart == null || primaryKeyStart.length == 0 ?
+ "<start>" : Bytes.hex(primaryKeyStart),
+ primaryKeyStart == null || primaryKeyEnd.length == 0 ?
+ "<end>" : Bytes.hex(primaryKeyEnd),
String.valueOf(dataSizeBytes),
tablet.toString());
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduClient.java
index 4e3a705..fc47700 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduClient.java
@@ -175,7 +175,8 @@ public class KuduClient implements AutoCloseable {
*/
public boolean isAlterTableDone(String name) throws KuduException {
TableIdentifierPB.Builder table = TableIdentifierPB.newBuilder().setTableName(name);
- Deferred<AlterTableResponse> d = asyncClient.getDelayedIsAlterTableDoneDeferred(table, null, null);
+ Deferred<AlterTableResponse> d =
+ asyncClient.getDelayedIsAlterTableDoneDeferred(table, null, null);
try {
joinAndHandleException(d);
} catch (KuduException e) {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPartitioner.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPartitioner.java
index ea66d46..5f2e20f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPartitioner.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPartitioner.java
@@ -162,8 +162,12 @@ public class KuduPartitioner {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof BytesKey)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof BytesKey)) {
+ return false;
+ }
BytesKey bytesKey = (BytesKey) o;
return compareTo(bytesKey) == 0;
}
@@ -231,7 +235,9 @@ public class KuduPartitioner {
String tabletId = new String(tablet.getTabletId(), UTF_8);
tabletIdToPartition.put(tabletId, tablet.getPartition());
byte[] keyEnd = tablet.getPartition().partitionKeyEnd;
- if (keyEnd.length == 0) break;
+ if (keyEnd.length == 0) {
+ break;
+ }
nextPartKey = keyEnd;
}
return new KuduPartitioner(table.getPartitionSchema(), tabletIdToPartition);
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
index a8c9e40..5c9f706 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduPredicate.java
@@ -593,11 +593,11 @@ public class KuduPredicate {
vals.add(Bytes.fromDouble((Double) value));
}
} else if (t instanceof BigDecimal) {
- checkColumn(column, Type.DECIMAL);
- for (T value : values) {
- vals.add(Bytes.fromBigDecimal((BigDecimal) value,
- column.getTypeAttributes().getPrecision()));
- }
+ checkColumn(column, Type.DECIMAL);
+ for (T value : values) {
+ vals.add(Bytes.fromBigDecimal((BigDecimal) value,
+ column.getTypeAttributes().getPrecision()));
+ }
} else if (t instanceof String) {
checkColumn(column, Type.STRING, Type.VARCHAR);
for (T value : values) {
@@ -1015,7 +1015,7 @@ public class KuduPredicate {
return m < n && m + 1 == n;
}
case INT32:
- case DECIMAL32:{
+ case DECIMAL32: {
int m = Bytes.getInt(a);
int n = Bytes.getInt(b);
return m < n && m + 1 == n;
@@ -1169,9 +1169,9 @@ public class KuduPredicate {
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:
- ColumnTypeAttributes typeAttributes = column.getTypeAttributes();
- return Bytes.getDecimal(value, typeAttributes.getPrecision(),
- typeAttributes.getScale()).toString();
+ ColumnTypeAttributes typeAttributes = column.getTypeAttributes();
+ return Bytes.getDecimal(value, typeAttributes.getPrecision(),
+ typeAttributes.getScale()).toString();
default:
throw new IllegalStateException(String.format("unknown column type %s", column.getType()));
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
index acf0c44..56a626a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
@@ -102,7 +102,7 @@ public abstract class KuduRpc<R> {
private static final Logger LOG = LoggerFactory.getLogger(KuduRpc.class);
private final List<RpcTraceFrame> traces =
- Collections.synchronizedList(new ArrayList<RpcTraceFrame>());
+ Collections.synchronizedList(new ArrayList<>());
private KuduRpc<?> parentRpc;
@@ -119,7 +119,8 @@ public abstract class KuduRpc<R> {
/**
* Binds the given authorization token to the request.
*/
- void bindAuthzToken(Token.SignedTokenPB token) {}
+ void bindAuthzToken(Token.SignedTokenPB token) {
+ }
/**
* Whether the request needs to be authorized via authz token.
@@ -304,8 +305,8 @@ public abstract class KuduRpc<R> {
* @param parentRpc RPC that will also receive traces from this RPC
*/
void setParentRpc(KuduRpc<?> parentRpc) {
- assert(this.parentRpc == null);
- assert(this != parentRpc);
+ assert (this.parentRpc == null);
+ assert (this != parentRpc);
this.parentRpc = parentRpc;
}
@@ -332,7 +333,7 @@ public abstract class KuduRpc<R> {
/** Package private way of accessing / creating the Deferred of this RPC. */
final Deferred<R> getDeferred() {
if (deferred == null) {
- deferred = new Deferred<R>();
+ deferred = new Deferred<>();
}
return deferred;
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScanToken.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScanToken.java
index 0b49e44..567e99a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScanToken.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScanToken.java
@@ -19,7 +19,6 @@ package org.apache.kudu.client;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.EnumSet;
import java.util.List;
import com.google.common.base.MoreObjects;
@@ -35,7 +34,6 @@ import org.apache.kudu.ColumnSchema;
import org.apache.kudu.Common;
import org.apache.kudu.Schema;
import org.apache.kudu.client.Client.ScanTokenPB;
-import org.apache.kudu.client.ProtobufHelper.SchemaPBConversionFlags;
import org.apache.kudu.util.Pair;
/**
@@ -170,10 +168,12 @@ public class KuduScanToken implements Comparable<KuduScanToken> {
schema.getColumnIndex(colSchemaFromPb.getId()) :
schema.getColumnIndex(colSchemaFromPb.getName());
ColumnSchema colSchema = schema.getColumnByIndex(colIdx);
- if (colSchemaFromPb.getType() != colSchema.getType().getDataType(colSchema.getTypeAttributes())) {
+ if (colSchemaFromPb.getType() !=
+ colSchema.getType().getDataType(colSchema.getTypeAttributes())) {
throw new IllegalStateException(String.format(
"invalid type %s for column '%s' in scan token, expected: %s",
- colSchemaFromPb.getType().name(), colSchemaFromPb.getName(), colSchema.getType().name()));
+ colSchemaFromPb.getType().name(), colSchemaFromPb.getName(),
+ colSchema.getType().name()));
}
if (colSchemaFromPb.getIsNullable() != colSchema.isNullable()) {
throw new IllegalStateException(String.format(
@@ -185,6 +185,7 @@ public class KuduScanToken implements Comparable<KuduScanToken> {
return columns;
}
+ @SuppressWarnings("deprecation")
private static KuduScanner pbIntoScanner(ScanTokenPB message,
KuduClient client) throws KuduException {
Preconditions.checkArgument(
@@ -303,8 +304,12 @@ public class KuduScanToken implements Comparable<KuduScanToken> {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof KuduScanToken)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof KuduScanToken)) {
+ return false;
+ }
KuduScanToken that = (KuduScanToken) o;
return compareTo(that) == 0;
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScannerIterator.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScannerIterator.java
index 0f588b0..5318cd8 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScannerIterator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduScannerIterator.java
@@ -47,7 +47,7 @@ public class KuduScannerIterator implements Iterator<RowResult> {
/**
* Calls the keepAlive API on the current scanner if the keepAlivePeriodMs has passed.
*/
- private void KeepKuduScannerAlive() throws KuduException {
+ private void keepKuduScannerAlive() throws KuduException {
long now = System.currentTimeMillis();
if (now >= lastKeepAliveTimeMs + keepAlivePeriodMs && !scanner.isClosed()) {
scanner.keepAlive();
@@ -71,7 +71,7 @@ public class KuduScannerIterator implements Iterator<RowResult> {
nextRowsCallback.call(currentIterator.getNumRows());
}
}
- KeepKuduScannerAlive();
+ keepKuduScannerAlive();
return currentIterator.hasNext();
} catch (KuduException ex) {
throw new RuntimeException(ex);
@@ -89,7 +89,7 @@ public class KuduScannerIterator implements Iterator<RowResult> {
}
@InterfaceAudience.LimitedPrivate("Spark")
- public static abstract class NextRowsCallback {
+ public abstract static class NextRowsCallback {
/**
* @param numRows The number of rows returned from the
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduTable.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduTable.java
index 29aa4a7..68dcb6f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduTable.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduTable.java
@@ -268,8 +268,8 @@ public class KuduTable {
// to avoid an extra call to get the range partitions.
List<Partition> rangePartitions = new ArrayList<>();
List<KuduScanToken> scanTokens = new KuduScanToken.KuduScanTokenBuilder(client, this)
- .setTimeout(timeout)
- .build();
+ .setTimeout(timeout)
+ .build();
for (KuduScanToken token : scanTokens) {
Partition partition = token.getTablet().getPartition();
// Filter duplicate range partitions by taking only the tablets whose hash
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTablesResponse.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTablesResponse.java
index f659a28..ef7fd27 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTablesResponse.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTablesResponse.java
@@ -83,8 +83,12 @@ public class ListTablesResponse extends KuduRpcResponse {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof TableInfo)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof TableInfo)) {
+ return false;
+ }
TableInfo tableInfo = (TableInfo) o;
return Objects.equal(tableId, tableInfo.tableId) &&
Objects.equal(tableName, tableInfo.tableName);
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletServersRequest.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletServersRequest.java
index 53d8277..92b1ebb 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletServersRequest.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletServersRequest.java
@@ -60,7 +60,7 @@ public class ListTabletServersRequest extends KuduRpc<ListTabletServersResponse>
ListTabletServersResponsePB.newBuilder();
readProtobuf(callResponse.getPBMessage(), respBuilder);
int serversCount = respBuilder.getServersCount();
- List<String> servers = new ArrayList<String>(serversCount);
+ List<String> servers = new ArrayList<>(serversCount);
for (ListTabletServersResponsePB.Entry entry : respBuilder.getServersList()) {
servers.add(entry.getRegistration().getRpcAddresses(0).getHost());
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletsRequest.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletsRequest.java
index 0645549..277837a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletsRequest.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ListTabletsRequest.java
@@ -56,7 +56,7 @@ class ListTabletsRequest extends KuduRpc<ListTabletsResponse> {
Tserver.ListTabletsResponsePB.newBuilder();
readProtobuf(callResponse.getPBMessage(), respBuilder);
int serversCount = respBuilder.getStatusAndSchemaCount();
- List<String> tablets = new ArrayList<String>(serversCount);
+ List<String> tablets = new ArrayList<>(serversCount);
for (Tserver.ListTabletsResponsePB.StatusAndSchemaPB info
: respBuilder.getStatusAndSchemaList()) {
tablets.add(info.getTabletStatus().getTabletId());
@@ -64,7 +64,6 @@ class ListTabletsRequest extends KuduRpc<ListTabletsResponse> {
ListTabletsResponse response = new ListTabletsResponse(timeoutTracker.getElapsedMillis(),
tsUUID,
tablets);
- return new Pair<ListTabletsResponse, Object>(
- response, respBuilder.hasError() ? respBuilder.getError() : null);
+ return new Pair<>(response, respBuilder.hasError() ? respBuilder.getError() : null);
}
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Negotiator.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Negotiator.java
index 17a7442..7617de4 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Negotiator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Negotiator.java
@@ -91,7 +91,7 @@ import org.apache.kudu.util.SecurityUtil;
public class Negotiator extends SimpleChannelUpstreamHandler {
private static final Logger LOG = LoggerFactory.getLogger(Negotiator.class);
- private final SaslClientCallbackHandler SASL_CALLBACK = new SaslClientCallbackHandler();
+ private final SaslClientCallbackHandler saslCallback = new SaslClientCallbackHandler();
private static final ImmutableSet<RpcHeader.RpcFeatureFlag> SUPPORTED_RPC_FEATURES =
ImmutableSet.of(
RpcHeader.RpcFeatureFlag.APPLICATION_FEATURE_FLAGS,
@@ -154,7 +154,7 @@ public class Negotiator extends SimpleChannelUpstreamHandler {
*/
private final SignedTokenPB authnToken;
- private static enum AuthnTokenNotUsedReason {
+ private enum AuthnTokenNotUsedReason {
NONE_AVAILABLE("no token is available"),
NO_TRUSTED_CERTS("no TLS certificates are trusted by the client"),
FORBIDDEN_BY_POLICY("this connection will be used to acquire a new token and " +
@@ -164,8 +164,10 @@ public class Negotiator extends SimpleChannelUpstreamHandler {
AuthnTokenNotUsedReason(String msg) {
this.msg = msg;
}
+
final String msg;
- };
+ }
+
private AuthnTokenNotUsedReason authnTokenNotUsedReason = null;
private State state = State.INITIAL;
@@ -448,7 +450,7 @@ public class Negotiator extends SimpleChannelUpstreamHandler {
"kudu",
remoteHostname,
props,
- SASL_CALLBACK);
+ saslCallback);
chosenMech = clientMech;
break;
} catch (SaslException e) {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Operation.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Operation.java
index 2c02e5d..ec6b768 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Operation.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Operation.java
@@ -207,8 +207,7 @@ public abstract class Operation extends KuduRpc<OperationResponse> {
builder.getTimestamp(),
this,
error);
- return new Pair<OperationResponse, Object>(
- response, builder.hasError() ? builder.getError() : null);
+ return new Pair<>(response, builder.hasError() ? builder.getError() : null);
}
@Override
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
index 341792d..b3ee835 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/PartialRow.java
@@ -954,34 +954,6 @@ public class PartialRow {
}
/**
- * Get the specified column's value as an Object.
- *
- * This method is useful when you don't care about autoboxing
- * and your existing type handling logic is based on Java types.
- *
- * The Object type is based on the column's {@link Type}:
- * Type.BOOL -> java.lang.Boolean
- * Type.INT8 -> java.lang.Byte
- * Type.INT16 -> java.lang.Short
- * Type.INT32 -> java.lang.Integer
- * Type.INT64 -> java.lang.Long
- * Type.UNIXTIME_MICROS -> java.sql.Timestamp
- * Type.FLOAT -> java.lang.Float
- * Type.DOUBLE -> java.lang.Double
- * Type.STRING -> java.lang.String
- * Type.VARCHAR -> java.lang.String
- * Type.BINARY -> byte[]
- * Type.DECIMAL -> java.math.BigDecimal
- *
- * @param columnName name of the column in the schema
- * @return the column's value as an Object, null if the column value is null or unset
- * @throws IndexOutOfBoundsException if the column doesn't exist
- */
- public Object getObject(String columnName) {
- return getObject(this.schema.getColumnIndex(columnName));
- }
-
- /**
* Add the specified column's value as an Object.
*
* This method is useful when you don't care about autoboxing
@@ -1045,11 +1017,21 @@ public class PartialRow {
return;
}
switch (col.getType()) {
- case BOOL: addBoolean(columnIndex, (Boolean) val); break;
- case INT8: addByte(columnIndex, (Byte) val); break;
- case INT16: addShort(columnIndex, (Short) val); break;
- case INT32: addInt(columnIndex, (Integer) val); break;
- case INT64: addLong(columnIndex, (Long) val); break;
+ case BOOL:
+ addBoolean(columnIndex, (Boolean) val);
+ break;
+ case INT8:
+ addByte(columnIndex, (Byte) val);
+ break;
+ case INT16:
+ addShort(columnIndex, (Short) val);
+ break;
+ case INT32:
+ addInt(columnIndex, (Integer) val);
+ break;
+ case INT64:
+ addLong(columnIndex, (Long) val);
+ break;
case UNIXTIME_MICROS:
if (val instanceof Timestamp) {
addTimestamp(columnIndex, (Timestamp) val);
@@ -1057,10 +1039,18 @@ public class PartialRow {
addLong(columnIndex, (Long) val);
}
break;
- case FLOAT: addFloat(columnIndex, (Float) val); break;
- case DOUBLE: addDouble(columnIndex, (Double) val); break;
- case STRING: addString(columnIndex, (String) val); break;
- case VARCHAR: addVarchar(columnIndex, (String) val); break;
+ case FLOAT:
+ addFloat(columnIndex, (Float) val);
+ break;
+ case DOUBLE:
+ addDouble(columnIndex, (Double) val);
+ break;
+ case STRING:
+ addString(columnIndex, (String) val);
+ break;
+ case VARCHAR:
+ addVarchar(columnIndex, (String) val);
+ break;
case BINARY:
if (val instanceof byte[]) {
addBinary(columnIndex, (byte[]) val);
@@ -1068,7 +1058,9 @@ public class PartialRow {
addBinary(columnIndex, (ByteBuffer) val);
}
break;
- case DECIMAL: addDecimal(columnIndex, (BigDecimal) val); break;
+ case DECIMAL:
+ addDecimal(columnIndex, (BigDecimal) val);
+ break;
default:
throw new IllegalArgumentException("Unsupported column type: " + col.getType());
}
@@ -1099,13 +1091,43 @@ public class PartialRow {
* Type.BINARY -> byte[]
* Type.DECIMAL -> java.math.BigDecimal
*
+ * @param columnName name of the column in the schema
+ * @return the column's value as an Object, null if the column value is null or unset
+ * @throws IndexOutOfBoundsException if the column doesn't exist
+ */
+ public Object getObject(String columnName) {
+ return getObject(this.schema.getColumnIndex(columnName));
+ }
+
+ /**
+ * Get the specified column's value as an Object.
+ *
+ * This method is useful when you don't care about autoboxing
+ * and your existing type handling logic is based on Java types.
+ *
+ * The Object type is based on the column's {@link Type}:
+ * Type.BOOL -> java.lang.Boolean
+ * Type.INT8 -> java.lang.Byte
+ * Type.INT16 -> java.lang.Short
+ * Type.INT32 -> java.lang.Integer
+ * Type.INT64 -> java.lang.Long
+ * Type.UNIXTIME_MICROS -> java.sql.Timestamp
+ * Type.FLOAT -> java.lang.Float
+ * Type.DOUBLE -> java.lang.Double
+ * Type.STRING -> java.lang.String
+ * Type.VARCHAR -> java.lang.String
+ * Type.BINARY -> byte[]
+ * Type.DECIMAL -> java.math.BigDecimal
+ *
* @param columnIndex Column index in the schema
* @return the column's value as an Object, null if the column value is null or unset
* @throws IndexOutOfBoundsException if the column doesn't exist
*/
public Object getObject(int columnIndex) {
checkColumnExists(schema.getColumnByIndex(columnIndex));
- if (isNull(columnIndex) || !isSet(columnIndex)) return null;
+ if (isNull(columnIndex) || !isSet(columnIndex)) {
+ return null;
+ }
Type type = schema.getColumnByIndex(columnIndex).getType();
switch (type) {
case BOOL: return getBoolean(columnIndex);
@@ -1645,18 +1667,18 @@ public class PartialRow {
case VARCHAR:
case STRING:
case BINARY: {
- ByteBuffer aData = a.varLengthData.get(index).duplicate();
- ByteBuffer bData = b.varLengthData.get(index).duplicate();
- aData.reset();
- bData.reset();
- int aLen = aData.limit() - aData.position();
- int bLen = bData.limit() - bData.position();
-
- if (aLen != bLen) {
+ ByteBuffer dataA = a.varLengthData.get(index).duplicate();
+ ByteBuffer dataB = b.varLengthData.get(index).duplicate();
+ dataA.reset();
+ dataB.reset();
+ int lenA = dataA.limit() - dataA.position();
+ int lenB = dataB.limit() - dataB.position();
+
+ if (lenA != lenB) {
return false;
}
- for (int i = 0; i < aLen; i++) {
- if (aData.get(aData.position() + i) != bData.get(bData.position() + i)) {
+ for (int i = 0; i < lenA; i++) {
+ if (dataA.get(dataA.position() + i) != dataB.get(dataB.position() + i)) {
return false;
}
}
@@ -1734,21 +1756,21 @@ public class PartialRow {
case STRING:
case BINARY: {
// Check that b is 1 byte bigger than a, the extra byte is 0, and the other bytes are equal.
- ByteBuffer aData = lower.varLengthData.get(index).duplicate();
- ByteBuffer bData = upper.varLengthData.get(index).duplicate();
- aData.reset();
- bData.reset();
- int aLen = aData.limit() - aData.position();
- int bLen = bData.limit() - bData.position();
-
- if (aLen == Integer.MAX_VALUE ||
- aLen + 1 != bLen ||
- bData.get(bData.limit() - 1) != 0) {
+ ByteBuffer dataA = lower.varLengthData.get(index).duplicate();
+ ByteBuffer dataB = upper.varLengthData.get(index).duplicate();
+ dataA.reset();
+ dataB.reset();
+ int lenA = dataA.limit() - dataA.position();
+ int lenB = dataB.limit() - dataB.position();
+
+ if (lenA == Integer.MAX_VALUE ||
+ lenA + 1 != lenB ||
+ dataB.get(dataB.limit() - 1) != 0) {
return false;
}
- for (int i = 0; i < aLen; i++) {
- if (aData.get(aData.position() + i) != bData.get(bData.position() + i)) {
+ for (int i = 0; i < lenA; i++) {
+ if (dataA.get(dataA.position() + i) != dataB.get(dataB.position() + i)) {
return false;
}
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/Partition.java b/java/kudu-client/src/main/java/org/apache/kudu/client/Partition.java
index 8c830e0..7f9a80f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Partition.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Partition.java
@@ -227,7 +227,7 @@ public class Partition implements Comparable<Partition> {
PartitionSchema partitionSchema = table.getPartitionSchema();
PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
- if (rangeSchema.getColumns().isEmpty()) {
+ if (rangeSchema.getColumnIds().isEmpty()) {
return "";
}
if (rangeKeyStart.length == 0 && rangeKeyEnd.length == 0) {
@@ -235,11 +235,11 @@ public class Partition implements Comparable<Partition> {
}
List<Integer> idxs = new ArrayList<>();
- for (int id : partitionSchema.getRangeSchema().getColumns()) {
+ for (int id : partitionSchema.getRangeSchema().getColumnIds()) {
idxs.add(schema.getColumnIndex(id));
}
- int numColumns = rangeSchema.getColumns().size();
+ int numColumns = rangeSchema.getColumnIds().size();
StringBuilder sb = new StringBuilder();
if (rangeKeyEnd.length == 0) {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/PartitionPruner.java b/java/kudu-client/src/main/java/org/apache/kudu/client/PartitionPruner.java
index ba9e459..8785cc4 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/PartitionPruner.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/PartitionPruner.java
@@ -360,7 +360,7 @@ public class PartitionPruner {
PartialRow row = schema.newPartialRow();
int pushedPredicates = 0;
- List<Integer> rangePartitionColumnIdxs = idsToIndexes(schema, rangeSchema.getColumns());
+ List<Integer> rangePartitionColumnIdxs = idsToIndexes(schema, rangeSchema.getColumnIds());
// Copy predicates into the row in range partition key column order,
// stopping after the first missing predicate.
@@ -421,7 +421,7 @@ public class PartitionPruner {
int pushedPredicates = 0;
KuduPredicate finalPredicate = null;
- List<Integer> rangePartitionColumnIdxs = idsToIndexes(schema, rangeSchema.getColumns());
+ List<Integer> rangePartitionColumnIdxs = idsToIndexes(schema, rangeSchema.getColumnIds());
// Step 1: copy predicates into the row in range partition key column order, stopping after
// the first missing predicate.
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
index a8e6176..e4dc71b 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
@@ -119,7 +119,7 @@ public class ProtobufHelper {
schemaBuilder.setReadDefaultValue(UnsafeByteOperations.unsafeWrap(
objectToWireFormat(column, column.getDefaultValue())));
}
- if(column.getTypeAttributes() != null) {
+ if (column.getTypeAttributes() != null) {
schemaBuilder.setTypeAttributes(
columnTypeAttributesToPb(Common.ColumnTypeAttributesPB.newBuilder(), column));
}
@@ -170,10 +170,10 @@ public class ProtobufHelper {
public static ColumnTypeAttributes pbToColumnTypeAttributes(Common.ColumnTypeAttributesPB pb) {
ColumnTypeAttributes.ColumnTypeAttributesBuilder builder =
new ColumnTypeAttributes.ColumnTypeAttributesBuilder();
- if(pb.hasPrecision()) {
+ if (pb.hasPrecision()) {
builder.precision(pb.getPrecision());
}
- if(pb.hasScale()) {
+ if (pb.hasScale()) {
builder.scale(pb.getScale());
}
if (pb.hasLength()) {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
index 74d8b9d..5ed424f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
@@ -64,7 +64,7 @@ public class RemoteTablet implements Comparable<RemoteTablet> {
@GuardedBy("tabletServers")
private final Map<String, ServerInfo> tabletServers;
private final AtomicReference<List<LocatedTablet.Replica>> replicas =
- new AtomicReference(ImmutableList.of());
+ new AtomicReference<>(ImmutableList.of());
private final Partition partition;
@GuardedBy("tabletServers")
@@ -197,8 +197,8 @@ public class RemoteTablet implements Comparable<RemoteTablet> {
// structure of a location to determine proximity.
synchronized (tabletServers) {
ServerInfo result = null;
- List<ServerInfo> localServers = new ArrayList();
- List<ServerInfo> serversInSameLocation = new ArrayList();
+ List<ServerInfo> localServers = new ArrayList<>();
+ List<ServerInfo> serversInSameLocation = new ArrayList<>();
int randomIndex = randomInt % tabletServers.size();
int index = 0;
for (ServerInfo e : tabletServers.values()) {
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RequestTracker.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RequestTracker.java
index 7db88fa..a66e2a7 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RequestTracker.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RequestTracker.java
@@ -82,7 +82,7 @@ public class RequestTracker {
assert sequenceId != NO_SEQ_NO;
synchronized (lock) {
boolean removed = incompleteRpcs.remove(sequenceId);
- assert(removed) : "Could not remove seqid " + sequenceId + " from request tracker";
+ assert (removed) : "Could not remove seqid " + sequenceId + " from request tracker";
}
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ResourceMetrics.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ResourceMetrics.java
index d9a3282..01ee22b 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ResourceMetrics.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ResourceMetrics.java
@@ -19,7 +19,6 @@ package org.apache.kudu.client;
import static com.google.protobuf.Descriptors.FieldDescriptor.JavaType;
-import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.LongAdder;
@@ -27,11 +26,11 @@ import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
import com.google.protobuf.Descriptors.FieldDescriptor;
-
-import org.apache.kudu.tserver.Tserver.ResourceMetricsPB;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
+import org.apache.kudu.tserver.Tserver.ResourceMetricsPB;
+
/**
* A container for scanner resource metrics.
* <p>
@@ -49,8 +48,8 @@ public class ResourceMetrics {
* @return a map of metric name to metric value
*/
public Map<String, Long> get() {
- return metrics.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().sum()));
+ return metrics.entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().sum()));
}
/**
@@ -59,7 +58,7 @@ public class ResourceMetrics {
* @return the value of the named metric; if the metric is not found, returns 0
*/
public long getMetric(String name) {
- return metrics.getOrDefault(name, new LongAdder()).sum();
+ return metrics.getOrDefault(name, new LongAdder()).sum();
}
/**
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
index c1558c4..e793092 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResult.java
@@ -609,7 +609,9 @@ public class RowResult {
*/
public Object getObject(int columnIndex) {
checkValidColumn(columnIndex);
- if (isNull(columnIndex)) return null;
+ if (isNull(columnIndex)) {
+ return null;
+ }
Type type = schema.getColumnByIndex(columnIndex).getType();
switch (type) {
case BOOL: return getBoolean(columnIndex);
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
index aba2ba8..d4a15aa 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
@@ -94,7 +94,8 @@ public class RowResultIterator extends KuduRpcResponse implements Iterator<RowRe
" bytes of data but expected " + expectedSize + " for " + numRows + " rows");
throw new NonRecoverableException(statusIllegalState);
}
- return new RowResultIterator(elapsedMillis, tsUUID, schema, numRows, bs, indirectBs, reuseRowResult);
+ return new RowResultIterator(elapsedMillis, tsUUID, schema, numRows, bs, indirectBs,
+ reuseRowResult);
}
/**
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
index 27e4110..52dd786 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcProxy.java
@@ -44,7 +44,6 @@ import org.apache.kudu.rpc.RpcHeader.RpcFeatureFlag;
import org.apache.kudu.tserver.Tserver;
import org.apache.kudu.util.Pair;
-
/**
* This is a 'stateless' helper to send RPCs to a Kudu server ('stateless' in the sense that it
* does not keep any state itself besides the references to the {@link AsyncKuduClient} and
@@ -83,16 +82,6 @@ class RpcProxy {
}
/**
- * Send the specified RPC using the connection to the Kudu server.
- *
- * @param <R> type of the RPC
- * @param rpc the RPC to send over the connection
- */
- <R> void sendRpc(final KuduRpc<R> rpc) {
- sendRpc(client, connection, rpc);
- }
-
- /**
* Fails the next numFail RPCs by throwing the passed exception.
* @param numFail the number of RPCs to fail
* @param exception the exception to throw when failing an rpc
@@ -108,6 +97,16 @@ class RpcProxy {
* Send the specified RPC using the connection to the Kudu server.
*
* @param <R> type of the RPC
+ * @param rpc the RPC to send over the connection
+ */
+ <R> void sendRpc(final KuduRpc<R> rpc) {
+ sendRpc(client, connection, rpc);
+ }
+
+ /**
+ * Send the specified RPC using the connection to the Kudu server.
+ *
+ * @param <R> type of the RPC
* @param client client object to handle response and sending retries, if needed
* @param connection connection to send the request over
* @param rpc the RPC to send over the connection
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
index 73c726a..83dc1f3 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
@@ -153,7 +153,8 @@ class RpcTraceFrame {
/**
* Returns a String wih the trace summary in the following format:
*
- * Trace Summary(trace-duration ms): Sent(n), Received(n), Delayed(n), MasterRefresh(n), AuthRefresh(n), Truncated: ?
+ * Trace Summary(trace-duration ms): Sent(n), Received(n), Delayed(n), MasterRefresh(n),
+ * AuthRefresh(n), Truncated: ?
* Sent: (server-uuid, [ rpc-method, count ], ...), ...
* Received: (server-uuid, [ rpc-status, count ], ...), ...
* Delayed: (server-uuid, [ rpc-method, count ], ...), ...
@@ -215,6 +216,8 @@ class RpcTraceFrame {
case TRACE_TRUNCATED:
truncated = true;
break;
+ default:
+ throw new IllegalArgumentException("Unexpected action: " + trace.getAction());
}
maxTime = Long.max(maxTime, trace.getTimestampMs() - baseTimestamp);
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/SecurityContext.java b/java/kudu-client/src/main/java/org/apache/kudu/client/SecurityContext.java
index 0f28489..da7a08a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/SecurityContext.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/SecurityContext.java
@@ -227,7 +227,8 @@ class SecurityContext {
throw new RuntimeException(e.getCause());
}
if (newSubject == null || SecurityUtil.getKerberosPrincipalOrNull(newSubject) == null) {
- LOG.warn("Tried to refresh Kerberos credentials but was unable to re-login from ticket cache");
+ LOG.warn("Tried to refresh Kerberos credentials but was unable to re-login from " +
+ "ticket cache");
loggedRefreshFailure = true;
nextAllowedRefreshNanotime = now + TimeUnit.SECONDS.toNanos(REFRESH_RATE_LIMIT_SECS);
return;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/SplitKeyRangeRequest.java b/java/kudu-client/src/main/java/org/apache/kudu/client/SplitKeyRangeRequest.java
index f106245..3a82e56 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/SplitKeyRangeRequest.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/SplitKeyRangeRequest.java
@@ -118,15 +118,11 @@ class SplitKeyRangeRequest extends KuduRpc<SplitKeyRangeResponse> {
Tserver.SplitKeyRangeResponsePB.newBuilder();
readProtobuf(callResponse.getPBMessage(), respBuilder);
- List<KeyRangePB> keyRanges = new ArrayList<>();
- for (KeyRangePB keyRange : respBuilder.getRangesList()) {
- keyRanges.add(keyRange);
- }
+ List<KeyRangePB> keyRanges = new ArrayList<>(respBuilder.getRangesList());
SplitKeyRangeResponse response = new SplitKeyRangeResponse(
timeoutTracker.getElapsedMillis(), tsUuid, keyRanges);
- return new Pair<SplitKeyRangeResponse, Object>(response,
- respBuilder.hasError() ? respBuilder.getError() : null);
+ return new Pair<>(response, respBuilder.hasError() ? respBuilder.getError() : null);
}
@Override
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/BloomFilter.java b/java/kudu-client/src/main/java/org/apache/kudu/util/BloomFilter.java
index 16d70c2..703dbf5 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/BloomFilter.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/BloomFilter.java
@@ -43,15 +43,15 @@ import org.apache.yetus.audience.InterfaceStability;
* <p>Here is an example for use:
* <pre>
* {@code
- * BloomFilter bf = BloomFilter.BySizeAndFPRate(nBytes);
+ * BloomFilter bf = BloomFilter.BySizeAndFPRate(numBytes);
* bf.put(1);
* bf.put(3);
* bf.put(4);
* byte[] bitSet = bf.getBitSet();
- * byte[] nHashes = bf.getNHashes();
+ * byte[] numHashes = bf.getNumHashes();
* String hashFunctionName = bf.getHashFunctionName();
* // TODO: implement the interface for serializing and sending
- * // (bitSet, nHashes, hashFunctionName) to TServer.
+ * // (bitSet, numHashes, hashFunctionName) to TServer.
* }
* </pre>
*/
@@ -61,50 +61,51 @@ import org.apache.yetus.audience.InterfaceStability;
public class BloomFilter {
private final BitSet bitSet;
- private final int nHashes;
+ private final int numHashes;
private final byte[] byteBuffer;
private final HashFunction hashFunction;
private static final double DEFAULT_FP_RATE = 0.01;
- private BloomFilter(BitSet bitSet, int nHashes, HashFunction hashFunction) {
+ private BloomFilter(BitSet bitSet, int numHashes, HashFunction hashFunction) {
Preconditions.checkArgument(bitSet.size() >= 8, "Number of bits in " +
- "bitset should be at least 8, but found %s.", bitSet.size());
+ "bitset should be at least 8, but found %s.", bitSet.size());
this.bitSet = bitSet;
- this.nHashes = nHashes;
+ this.numHashes = numHashes;
this.hashFunction = hashFunction;
byteBuffer = new byte[8];
}
/**
* Generate bloom filter, default hashing is {@code Murmur2} and false positive rate is 0.01.
- * @param nBytes size of bloom filter in bytes
+ * @param numBytes size of bloom filter in bytes
*/
- public static BloomFilter bySize(int nBytes) {
- return bySizeAndFPRate(nBytes, DEFAULT_FP_RATE);
+ public static BloomFilter bySize(int numBytes) {
+ return bySizeAndFPRate(numBytes, DEFAULT_FP_RATE);
}
/**
* Generate bloom filter, default hashing is {@code Murmur2}.
- * @param nBytes size of bloom filter in bytes
+ * @param numBytes size of bloom filter in bytes
* @param fpRate the probability that TServer will erroneously return a record that has not
* ever been {@code put} into the {@code BloomFilter}.
*/
- public static BloomFilter bySizeAndFPRate(int nBytes, double fpRate) {
- return bySizeAndFPRate(nBytes, fpRate, HashFunctions.MURMUR2);
+ public static BloomFilter bySizeAndFPRate(int numBytes, double fpRate) {
+ return bySizeAndFPRate(numBytes, fpRate, HashFunctions.MURMUR2);
}
/**
* Generate bloom filter.
- * @param nBytes size of bloom filter in bytes
+ * @param numBytes size of bloom filter in bytes
* @param fpRate the probability that TServer will erroneously return a record that has not
* ever been {@code put} into the {@code BloomFilter}.
* @param hashFunction hashing used when updating or checking containment, user should pick
* the hashing function from {@code HashFunctions}
*/
- public static BloomFilter bySizeAndFPRate(int nBytes, double fpRate, HashFunction hashFunction) {
- int nBits = nBytes * 8;
- int nHashes = computeOptimalHashCount(nBits, optimalExpectedCount(nBytes, fpRate));
- return new BloomFilter(new BitSet(nBits), nHashes, hashFunction);
+ public static BloomFilter bySizeAndFPRate(int numBytes, double fpRate,
+ HashFunction hashFunction) {
+ int numBits = numBytes * 8;
+ int numHashes = computeOptimalHashCount(numBits, optimalExpectedCount(numBytes, fpRate));
+ return new BloomFilter(new BitSet(numBits), numHashes, hashFunction);
}
/**
@@ -138,10 +139,10 @@ public class BloomFilter {
*/
public static BloomFilter byCountAndFPRate(
int expectedCount, double fpRate, HashFunction hashFunction) {
- int nBytes = optimalNumOfBytes(expectedCount, fpRate);
- int nBits = nBytes * 8;
- int nHashes = computeOptimalHashCount(nBits, expectedCount);
- return new BloomFilter(new BitSet(nBits), nHashes, hashFunction);
+ int numBytes = optimalNumOfBytes(expectedCount, fpRate);
+ int numBits = numBytes * 8;
+ int numHashes = computeOptimalHashCount(numBits, expectedCount);
+ return new BloomFilter(new BitSet(numBits), numHashes, hashFunction);
}
/**
@@ -233,8 +234,8 @@ public class BloomFilter {
/**
* Get the number of hashing times when updating or checking containment.
*/
- public int getNHashes() {
- return nHashes;
+ public int getNumHashes() {
+ return numHashes;
}
/**
@@ -276,7 +277,7 @@ public class BloomFilter {
long h1 = (0xFFFFFFFFL & h);
long h2 = (h >>> 32);
long tmp = h1;
- for (int i = 0; i < nHashes; i++) {
+ for (int i = 0; i < numHashes; i++) {
long bitPos = tmp % bitSet.size();
bitSet.set((int)bitPos);
tmp += h2;
@@ -359,7 +360,7 @@ public class BloomFilter {
long h1 = (0xFFFFFFFFL & h);
long h2 = (h >>> 32);
long tmp = h1;
- int remHashes = nHashes;
+ int remHashes = numHashes;
while (remHashes != 0) {
long bitPos = tmp % bitSet.size();
if (!bitSet.get((int)bitPos)) {
@@ -380,15 +381,17 @@ public class BloomFilter {
return (int) Math.ceil(-expectedCount * Math.log(fpRate) / (Math.log(2) * Math.log(2) * 8));
}
- private static int optimalExpectedCount(int nBytes, double fpRate) {
- int nBits = nBytes * 8;
- return (int) Math.ceil(-nBits * kNaturalLog2 * kNaturalLog2 / Math.log(fpRate));
+ private static int optimalExpectedCount(int numBytes, double fpRate) {
+ int numBits = numBytes * 8;
+ return (int) Math.ceil(-numBits * kNaturalLog2 * kNaturalLog2 / Math.log(fpRate));
}
- private static int computeOptimalHashCount(int nBits, int elems) {
- int nHashes = (int)(nBits * kNaturalLog2 / elems);
- if (nHashes < 1) nHashes = 1;
- return nHashes;
+ private static int computeOptimalHashCount(int numBits, int elems) {
+ int numHashes = (int)(numBits * kNaturalLog2 / elems);
+ if (numHashes < 1) {
+ numHashes = 1;
+ }
+ return numHashes;
}
@Override
@@ -396,8 +399,8 @@ public class BloomFilter {
StringBuilder sb = new StringBuilder();
sb.append("BloomFilter(nBits=");
sb.append(bitSet.size());
- sb.append(", nHashes=");
- sb.append(nHashes);
+ sb.append(", numHashes=");
+ sb.append(numHashes);
sb.append(", hashing=");
sb.append(hashFunction);
sb.append(")");
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/CharUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/CharUtil.java
index bd1639d..98ed31a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/CharUtil.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/CharUtil.java
@@ -17,9 +17,10 @@
package org.apache.kudu.util;
-import org.apache.kudu.ColumnTypeAttributes;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.kudu.ColumnTypeAttributes;
+
@InterfaceAudience.Private
public class CharUtil {
public static final int MIN_VARCHAR_LENGTH = 1;
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/DataGenerator.java b/java/kudu-client/src/main/java/org/apache/kudu/util/DataGenerator.java
index 3dffba4..095e3c9 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/DataGenerator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/DataGenerator.java
@@ -92,30 +92,40 @@ public class DataGenerator {
switch (type) {
// TODO(ghenke): Support range bound configuration.
case BOOL:
- row.addBoolean(i, random.nextBoolean()); break;
+ row.addBoolean(i, random.nextBoolean());
+ break;
case INT8:
- row.addByte(i, (byte) random.nextInt()); break;
+ row.addByte(i, (byte) random.nextInt());
+ break;
case INT16:
- row.addShort(i, (short) random.nextInt()); break;
+ row.addShort(i, (short) random.nextInt());
+ break;
case INT32:
- row.addInt(i, random.nextInt()); break;
+ row.addInt(i, random.nextInt());
+ break;
case INT64:
case UNIXTIME_MICROS:
- row.addLong(i, random.nextLong()); break;
+ row.addLong(i, random.nextLong());
+ break;
case FLOAT:
- row.addFloat(i, random.nextFloat()); break;
+ row.addFloat(i, random.nextFloat());
+ break;
case DOUBLE:
- row.addDouble(i, random.nextDouble()); break;
+ row.addDouble(i, random.nextDouble());
+ break;
case DECIMAL:
- row.addDecimal(i, randomDecimal(col.getTypeAttributes(), random)); break;
+ row.addDecimal(i, randomDecimal(col.getTypeAttributes(), random));
+ break;
case VARCHAR:
row.addVarchar(i, randomString(Math.min(col.getTypeAttributes().getLength(),
stringLength), random));
break;
case STRING:
- row.addString(i, randomString(stringLength, random)); break;
+ row.addString(i, randomString(stringLength, random));
+ break;
case BINARY:
- row.addBinary(i, randomBinary(binaryLength, random)); break;
+ row.addBinary(i, randomBinary(binaryLength, random));
+ break;
default:
throw new UnsupportedOperationException("Unsupported type " + type);
}
@@ -136,7 +146,7 @@ public class DataGenerator {
* Utility method to return a random string value.
*/
public static String randomString(int length, Random random) {
- byte bytes[] = new byte[length];
+ byte[] bytes = new byte[length];
random.nextBytes(bytes);
return DatatypeConverter.printBase64Binary(bytes);
}
@@ -145,7 +155,7 @@ public class DataGenerator {
* Utility method to return a random binary value.
*/
public static byte[] randomBinary(int length, Random random) {
- byte bytes[] = new byte[length];
+ byte[] bytes = new byte[length];
random.nextBytes(bytes);
return bytes;
}
@@ -161,7 +171,8 @@ public class DataGenerator {
private float nullRate = 0.1f;
private float defaultRate = 0.1f;
- public DataGeneratorBuilder() {}
+ public DataGeneratorBuilder() {
+ }
/**
* Define a custom Random instance to use for any random generation.
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/DecimalUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/DecimalUtil.java
index f3fa51b..83ec926 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/DecimalUtil.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/DecimalUtil.java
@@ -133,7 +133,8 @@ public class DecimalUtil {
}
if (val.precision() > targetPrecision) {
throw new IllegalArgumentException("Value precision " + val.precision() +
- " (after scale coercion) can't be coerced to target precision " + targetPrecision + ". ");
+ " (after scale coercion) can't be coerced to target precision " +
+ targetPrecision + ". ");
}
return val;
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/SchemaGenerator.java b/java/kudu-client/src/main/java/org/apache/kudu/util/SchemaGenerator.java
index adac3be..78b7734 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/SchemaGenerator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/SchemaGenerator.java
@@ -128,8 +128,8 @@ public class SchemaGenerator {
if (type == Type.VARCHAR) {
int length = random.nextInt(
- (CharUtil.MAX_VARCHAR_LENGTH - CharUtil.MIN_VARCHAR_LENGTH) + 1)
- + CharUtil.MIN_VARCHAR_LENGTH;
+ (CharUtil.MAX_VARCHAR_LENGTH - CharUtil.MIN_VARCHAR_LENGTH) + 1) +
+ CharUtil.MIN_VARCHAR_LENGTH;
typeAttributes = CharUtil.typeAttributes(length);
builder.typeAttributes(typeAttributes);
}
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java b/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java
index 3434c7a..d3d362e 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/Slices.java
@@ -44,7 +44,8 @@ public final class Slices {
*/
public static final Slice EMPTY_SLICE = new Slice(0);
- private Slices() {}
+ private Slices() {
+ }
public static Slice ensureSize(Slice existingSlice, int minWritableBytes) {
if (existingSlice == null) {
@@ -149,7 +150,7 @@ public final class Slices {
new ThreadLocal<Map<Charset, CharsetEncoder>>() {
@Override
protected Map<Charset, CharsetEncoder> initialValue() {
- return new IdentityHashMap<Charset, CharsetEncoder>();
+ return new IdentityHashMap<>();
}
};
@@ -157,7 +158,7 @@ public final class Slices {
new ThreadLocal<Map<Charset, CharsetDecoder>>() {
@Override
protected Map<Charset, CharsetDecoder> initialValue() {
- return new IdentityHashMap<Charset, CharsetDecoder>();
+ return new IdentityHashMap<>();
}
};
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/util/StringUtil.java b/java/kudu-client/src/main/java/org/apache/kudu/util/StringUtil.java
index 87c41a7..88bd436 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/util/StringUtil.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/util/StringUtil.java
@@ -86,5 +86,6 @@ public class StringUtil {
}
/** Non-constructable utility class. */
- private StringUtil() { }
+ private StringUtil() {
+ }
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java b/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
index 3da514d..84678cc 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/TestColumnSchema.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu;
import static org.junit.Assert.assertEquals;
@@ -38,12 +39,13 @@ public class TestColumnSchema {
@Test
public void testToString() {
- ColumnSchema col1 = new ColumnSchemaBuilder("col1", Type.STRING).build();
- ColumnSchema col2 = new ColumnSchemaBuilder("col2", Type.INT64).build();
- ColumnSchema col3 = new ColumnSchemaBuilder("col3", Type.DECIMAL)
+ final ColumnSchema col1 = new ColumnSchemaBuilder("col1", Type.STRING).build();
+ final ColumnSchema col2 = new ColumnSchemaBuilder("col2", Type.INT64).build();
+ final ColumnSchema col3 = new ColumnSchemaBuilder("col3", Type.DECIMAL)
.typeAttributes(DecimalUtil.typeAttributes(5, 2))
.build();
- ColumnSchema col4 = new ColumnSchemaBuilder("col4", Type.INT16).comment("test comment").build();
+ final ColumnSchema col4 = new ColumnSchemaBuilder("col4", Type.INT16)
+ .comment("test comment").build();
assertEquals("Column name: col1, type: string", col1.toString());
assertEquals("Column name: col2, type: int64", col2.toString());
@@ -100,6 +102,7 @@ public class TestColumnSchema {
ColumnSchema commentInt3 = new ColumnSchemaBuilder("col1", Type.INT32).comment("Test").build();
assertNotEquals(commentInt1, commentInt3);
}
+
@Test
public void testOutOfRangeVarchar() throws Exception {
expectedException.expect(IllegalArgumentException.class);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/TestType.java b/java/kudu-client/src/test/java/org/apache/kudu/TestType.java
index 0c4f65e..2552a67 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/TestType.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/TestType.java
@@ -14,13 +14,13 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu;
import static org.junit.Assert.assertEquals;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.apache.kudu.test.junit.RetryRule;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java
index ac4c2e8..5cc72e8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClient.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
@@ -360,7 +361,7 @@ public class ITClient {
for (RowResult row : scanner) {
results.add(row);
}
- if (results.isEmpty() || results.size() > 1) {
+ if (results.size() != 1) {
reportError("Random get got 0 or many rows " + results.size() + " for key " + key, null);
return false;
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClientStress.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClientStress.java
index 9daab10..0f4b288 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITClientStress.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITClientStress.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createFourTabletsTableWithNineRows;
@@ -66,7 +67,7 @@ public class ITClientStress {
// Capture logs so we can check that no exceptions are logged.
CapturingLogAppender cla = new CapturingLogAppender();
- try (Closeable c = cla.attach()){
+ try (Closeable c = cla.attach()) {
Stopwatch s = Stopwatch.createStarted();
while (s.elapsed(TimeUnit.SECONDS) < secondsToRun &&
thrown.get() == null) {
@@ -105,7 +106,7 @@ public class ITClientStress {
* Impala 2.8 front-end under a high-concurrency workload. Each query
* starts a new client, fetches scan tokens, and closes the client.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testManyShortClientsGeneratingScanTokens() throws Exception {
final String TABLE_NAME = "testManyClients";
final int SECONDS_TO_RUN = 10;
@@ -136,7 +137,7 @@ public class ITClientStress {
* Stress test which performs upserts from many sessions on different threads
* sharing the same KuduClient and KuduTable instance.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testMultipleSessions() throws Exception {
final String TABLE_NAME = "testMultipleSessions";
final int SECONDS_TO_RUN = 10;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITNonFaultTolerantScanner.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITNonFaultTolerantScanner.java
index f34653b..9f5a766 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITNonFaultTolerantScanner.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITNonFaultTolerantScanner.java
@@ -39,7 +39,7 @@ public class ITNonFaultTolerantScanner extends ITScannerMultiTablet {
int rowCount = 0;
int loopCount = 0;
- while(scanner.hasMoreRows()) {
+ while (scanner.hasMoreRows()) {
loopCount++;
RowResultIterator rri = scanner.nextRows();
rowCount += rri.getNumRows();
@@ -62,7 +62,7 @@ public class ITNonFaultTolerantScanner extends ITScannerMultiTablet {
* Tests non fault tolerant scanner by killing the tablet server while scanning and
* verifies it throws {@link NonRecoverableException} as expected.
*/
- @Test(timeout = 100000, expected=NonRecoverableException.class)
+ @Test(timeout = 100000, expected = NonRecoverableException.class)
public void testNonFaultTolerantScannerKill() throws Exception {
serverFaultInjection(false, false, false);
}
@@ -71,7 +71,7 @@ public class ITNonFaultTolerantScanner extends ITScannerMultiTablet {
* Tests non fault tolerant scanner by restarting the tablet server while scanning and
* verifies it throws {@link NonRecoverableException} as expected.
*/
- @Test(timeout = 100000, expected=NonRecoverableException.class)
+ @Test(timeout = 100000, expected = NonRecoverableException.class)
public void testNonFaultTolerantScannerRestart() throws Exception {
serverFaultInjection(true, false, false);
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java
index dc38fab..76d9471 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/ITScannerMultiTablet.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.getBasicSchema;
@@ -36,7 +37,7 @@ import org.apache.kudu.test.KuduTestHarness;
public class ITScannerMultiTablet {
private static final String TABLE_NAME =
- ITScannerMultiTablet.class.getName()+"-"+System.currentTimeMillis();
+ ITScannerMultiTablet.class.getName() + "-" + System.currentTimeMillis();
protected static final int ROW_COUNT = 20000;
protected static final int TABLET_COUNT = 3;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java
index 85da8ae..d1f5cb0 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAlterTable.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInTable;
@@ -21,6 +22,7 @@ import static org.apache.kudu.test.ClientTestUtil.scanTableToStrings;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -116,7 +118,7 @@ public class TestAlterTable {
@Test
public void testAlterAddColumns() throws Exception {
- KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of());
+ KuduTable table = createTable(ImmutableList.of());
insertRows(table, 0, 100);
assertEquals(100, countRowsInTable(table));
@@ -130,7 +132,7 @@ public class TestAlterTable {
assertEquals(5, table.getSchema().getColumnCount());
// Add a row with addNullableDef=null
- KuduSession session = client.newSession();
+ final KuduSession session = client.newSession();
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
row.addInt("c0", 101);
@@ -144,8 +146,8 @@ public class TestAlterTable {
assertEquals(String.format("row errors: %s", Arrays.toString(rowErrors)), 0, rowErrors.length);
// Check defaults applied, and that row key=101
- List<String> actual = scanTableToStrings(table);
- List<String> expected = new ArrayList<>(101);
+ final List<String> actual = scanTableToStrings(table);
+ final List<String> expected = new ArrayList<>(101);
for (int i = 0; i < 100; i++) {
expected.add(i, String.format("INT32 c0=%d, INT32 c1=%d, INT32 addNonNull=100" +
", INT32 addNullable=NULL, INT32 addNullableDef=200", i, i));
@@ -158,7 +160,7 @@ public class TestAlterTable {
@Test
public void testAlterModifyColumns() throws Exception {
- KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of());
+ KuduTable table = createTable(ImmutableList.of());
insertRows(table, 0, 100);
assertEquals(100, countRowsInTable(table));
@@ -166,7 +168,7 @@ public class TestAlterTable {
ColumnSchema col = table.getSchema().getColumns().get(1);
assertEquals(CompressionAlgorithm.DEFAULT_COMPRESSION, col.getCompressionAlgorithm());
assertEquals(Encoding.AUTO_ENCODING, col.getEncoding());
- assertEquals(null, col.getDefaultValue());
+ assertNull(col.getDefaultValue());
// Alter the table.
client.alterTable(tableName, new AlterTableOptions()
@@ -184,7 +186,7 @@ public class TestAlterTable {
@Test
public void testRenameKeyColumn() throws Exception {
- KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of());
+ KuduTable table = createTable(ImmutableList.of());
insertRows(table, 0, 100);
assertEquals(100, countRowsInTable(table));
@@ -233,7 +235,7 @@ public class TestAlterTable {
@Test
public void testAlterRangePartitioning() throws Exception {
- KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of());
+ KuduTable table = createTable(ImmutableList.of());
Schema schema = table.getSchema();
// Insert some rows, and then drop the partition and ensure that the table is empty.
@@ -323,7 +325,7 @@ public class TestAlterTable {
RangePartitionBound.EXCLUSIVE_BOUND,
RangePartitionBound.INCLUSIVE_BOUND);
- KuduTable table = client.createTable(tableName, schema, createOptions);
+ final KuduTable table = client.createTable(tableName, schema, createOptions);
lower.addInt("c0", 199);
upper.addInt("c0", 299);
@@ -484,7 +486,7 @@ public class TestAlterTable {
@Test
public void testAlterExtraConfigs() throws Exception {
- KuduTable table = createTable(ImmutableList.<Pair<Integer,Integer>>of());
+ KuduTable table = createTable(ImmutableList.of());
insertRows(table, 0, 100);
assertEquals(100, countRowsInTable(table));
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
index 59517d4..17d3a15 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -186,22 +187,22 @@ public class TestAsyncKuduClient {
@Test
public void testNoLeader() throws Exception {
final int requestBatchSize = 10;
- CreateTableOptions options = getBasicCreateTableOptions();
- KuduTable table = client.createTable(
+ final CreateTableOptions options = getBasicCreateTableOptions();
+ final KuduTable table = client.createTable(
"testNoLeader-" + System.currentTimeMillis(),
basicSchema,
options);
// Lookup the current locations so that we can pass some valid information to discoverTablets.
- List<LocatedTablet> tablets = asyncClient
+ final List<LocatedTablet> tablets = asyncClient
.locateTable(table, null, null, requestBatchSize, DEFAULT_SLEEP)
.join(DEFAULT_SLEEP);
- LocatedTablet tablet = tablets.get(0);
- LocatedTablet.Replica leader = tablet.getLeaderReplica();
+ final LocatedTablet tablet = tablets.get(0);
+ final LocatedTablet.Replica leader = tablet.getLeaderReplica();
// Fake a master lookup that only returns one follower for the tablet.
- List<Master.TabletLocationsPB> tabletLocations = new ArrayList<>();
- List<Master.TSInfoPB> tsInfos = new ArrayList<>();
+ final List<Master.TabletLocationsPB> tabletLocations = new ArrayList<>();
+ final List<Master.TSInfoPB> tsInfos = new ArrayList<>();
Master.TabletLocationsPB.Builder tabletPb = Master.TabletLocationsPB.newBuilder();
tabletPb.setPartition(ProtobufUtils.getFakePartitionPB());
tabletPb.setTabletId(ByteString.copyFrom(tablet.getTabletId()));
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
index 6286e78..2f2abd9 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInTable;
@@ -192,7 +193,7 @@ public class TestAsyncKuduSession {
session.setFlushMode(SessionConfiguration.FlushMode.AUTO_FLUSH_SYNC);
session.apply(createBasicSchemaInsert(nonReplicatedTable, 1)).join();
- int numClientsBefore = client.getConnectionListCopy().size();
+ final int numClientsBefore = client.getConnectionListCopy().size();
// Restart all the tablet servers.
harness.killAllTabletServers();
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthTokenReacquire.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthTokenReacquire.java
index 242d948..24aef14 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthTokenReacquire.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthTokenReacquire.java
@@ -62,14 +62,15 @@ public class TestAuthTokenReacquire {
// Inject additional INVALID_AUTHENTICATION_TOKEN responses from both the
// master and tablet servers, even for not-yet-expired tokens.
- private static final MiniKuduClusterBuilder clusterBuilder = KuduTestHarness.getBaseClusterBuilder()
- .enableKerberos()
- .addMasterServerFlag(String.format("--authn_token_validity_seconds=%d", TOKEN_TTL_SEC))
- .addMasterServerFlag(String.format("--authz_token_validity_seconds=%d", TOKEN_TTL_SEC))
- .addMasterServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5")
- .addTabletServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5")
- .addTabletServerFlag("--tserver_enforce_access_control=true")
- .addTabletServerFlag("--tserver_inject_invalid_authz_token_ratio=0.5");
+ private static final MiniKuduClusterBuilder clusterBuilder =
+ KuduTestHarness.getBaseClusterBuilder()
+ .enableKerberos()
+ .addMasterServerFlag(String.format("--authn_token_validity_seconds=%d", TOKEN_TTL_SEC))
+ .addMasterServerFlag(String.format("--authz_token_validity_seconds=%d", TOKEN_TTL_SEC))
+ .addMasterServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5")
+ .addTabletServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5")
+ .addTabletServerFlag("--tserver_enforce_access_control=true")
+ .addTabletServerFlag("--tserver_inject_invalid_authz_token_ratio=0.5");
private KuduClient client;
private AsyncKuduClient asyncClient;
@@ -109,7 +110,7 @@ public class TestAuthTokenReacquire {
// To ratchet up the intensity a bit, run the scenario by several concurrent threads.
List<Thread> threads = new ArrayList<>();
final Map<Integer, Throwable> exceptions =
- Collections.synchronizedMap(new HashMap<Integer, Throwable>());
+ Collections.synchronizedMap(new HashMap<>());
for (int i = 0; i < 8; ++i) {
final int threadIdx = i;
Thread thread = new Thread(new Runnable() {
@@ -149,7 +150,8 @@ public class TestAuthTokenReacquire {
try {
client.deleteTable(tableName);
} catch (KuduException ex) {
- // See the above comment about table creation. The same idea applies to table deletion.
+ // See the above comment about table creation.
+ // The same idea applies to table deletion.
// TODO(KUDU-1537): Remove this workaround when table deletion is exactly-once.
if (!ex.getStatus().isNotFound()) {
throw ex;
@@ -199,13 +201,15 @@ public class TestAuthTokenReacquire {
@Test
public void testBasicWorkflow() throws Exception {
- KuduTable table = client.createTable(TABLE_NAME, basicSchema,
+ final KuduTable table = client.createTable(TABLE_NAME, basicSchema,
getBasicCreateTableOptions());
- String tableId = table.getTableId();
+ final String tableId = table.getTableId();
int key = 0;
// Drop all connections so the first write needs to reconnect with a new authn token.
+ // CHECKSTYLE:OFF
Token.SignedTokenPB originalToken = asyncClient.securityContext.getAuthenticationToken();
+ // CHECKSTYLE:ON
dropConnectionsAndExpireTokens();
KuduSession session = client.newSession();
session.setTimeoutMillis(OP_TIMEOUT_MS);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthnTokenReacquireOpen.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthnTokenReacquireOpen.java
index 00f84ef..dc98a65 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthnTokenReacquireOpen.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthnTokenReacquireOpen.java
@@ -49,18 +49,22 @@ public class TestAuthnTokenReacquireOpen {
private static final Schema basicSchema = ClientTestUtil.getBasicSchema();
- private static final MiniKuduClusterBuilder clusterBuilder = KuduTestHarness.getBaseClusterBuilder()
- // We want to have a cluster with a single master.
- .numMasterServers(1)
- // Set appropriate TTL for authn token and connection keep-alive property, so the client could
- // keep an open connection to the master when its authn token is already expired. Inject
- // additional INVALID_AUTHENTICATION_TOKEN responses from the tablet server even for
- // not-yet-expired tokens for an extra stress on the client.
- .enableKerberos()
- .addMasterServerFlag(String.format("--authn_token_validity_seconds=%d", TOKEN_TTL_SEC))
- .addMasterServerFlag(String.format("--rpc_default_keepalive_time_ms=%d", KEEPALIVE_TIME_MS))
- .addTabletServerFlag(String.format("--rpc_default_keepalive_time_ms=%d", KEEPALIVE_TIME_MS))
- .addTabletServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5");
+ private static final MiniKuduClusterBuilder clusterBuilder =
+ KuduTestHarness.getBaseClusterBuilder()
+ // We want to have a cluster with a single master.
+ .numMasterServers(1)
+ // Set appropriate TTL for authn token and connection keep-alive property, so the client
+ // could keep an open connection to the master when its authn token is already expired.
+ // Inject additional INVALID_AUTHENTICATION_TOKEN responses from the tablet server even
+ // for not-yet-expired tokens for an extra stress on the client.
+ .enableKerberos()
+ .addMasterServerFlag(
+ String.format("--authn_token_validity_seconds=%d", TOKEN_TTL_SEC))
+ .addMasterServerFlag(
+ String.format("--rpc_default_keepalive_time_ms=%d", KEEPALIVE_TIME_MS))
+ .addTabletServerFlag(
+ String.format("--rpc_default_keepalive_time_ms=%d", KEEPALIVE_TIME_MS))
+ .addTabletServerFlag("--rpc_inject_invalid_authn_token_ratio=0.5");
private KuduClient client;
private AsyncKuduClient asyncClient;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthzTokenCache.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthzTokenCache.java
index b697b2f..06d81e7 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthzTokenCache.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAuthzTokenCache.java
@@ -85,7 +85,7 @@ public class TestAuthzTokenCache {
// upon accessing a table.
final KuduTable table = client.createTable(tableName, getBasicSchema(),
getBasicCreateTableOptions());
- AuthzTokenCache tokenCache = asyncClient.getAuthzTokenCache();
+ final AuthzTokenCache tokenCache = asyncClient.getAuthzTokenCache();
String tableId = table.getTableId();
Token.SignedTokenPB originalToken = asyncClient.getAuthzToken(tableId);
assertNotNull(originalToken);
@@ -112,6 +112,7 @@ public class TestAuthzTokenCache {
final KuduTable table = client.createTable(tableName, getBasicSchema(),
getBasicCreateTableOptions());
final String tableId = table.getTableId();
+
class AuthzTokenFetcher implements Callable<Exception> {
@Override
public Exception call() {
@@ -123,6 +124,7 @@ public class TestAuthzTokenCache {
return null;
}
}
+
// Send a bunch of authz token requests in parallel.
final int NUM_THREADS = 30;
ArrayList<AuthzTokenFetcher> fetchers = new ArrayList<>();
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java
index 80002dd..186d2b0 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBitSet.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBloomFilter.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBloomFilter.java
index 22fe72b..d1b86f2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBloomFilter.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBloomFilter.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -29,68 +30,68 @@ import org.apache.kudu.util.BloomFilter;
public class TestBloomFilter {
- private int nBytes = 32 * 1024;
- private long kRandomSeed = System.currentTimeMillis();
- private int nKeys = 2000;
+ private int numBytes = 32 * 1024;
+ private long randomSeed = System.currentTimeMillis();
+ private int numKeys = 2000;
@Rule
public RetryRule retryRule = new RetryRule();
@Test
public void testNumberOfHashes() {
- assertEquals(BloomFilter.byCountAndFPRate(10, 0.1).getNHashes(), 3);
- assertEquals(BloomFilter.byCountAndFPRate(100, 0.2).getNHashes(), 2);
- assertEquals(BloomFilter.byCountAndFPRate(1000, 0.05).getNHashes(), 4);
- assertEquals(BloomFilter.byCountAndFPRate(10000, 0.01).getNHashes(), 6);
- assertEquals(BloomFilter.bySizeAndFPRate(10, 0.1).getNHashes(), 3);
- assertEquals(BloomFilter.bySizeAndFPRate(1000, 0.2).getNHashes(), 2);
- assertEquals(BloomFilter.bySizeAndFPRate(100000, 0.05).getNHashes(), 4);
- assertEquals(BloomFilter.bySizeAndFPRate(10000000, 0.01).getNHashes(), 6);
+ assertEquals(BloomFilter.byCountAndFPRate(10, 0.1).getNumHashes(), 3);
+ assertEquals(BloomFilter.byCountAndFPRate(100, 0.2).getNumHashes(), 2);
+ assertEquals(BloomFilter.byCountAndFPRate(1000, 0.05).getNumHashes(), 4);
+ assertEquals(BloomFilter.byCountAndFPRate(10000, 0.01).getNumHashes(), 6);
+ assertEquals(BloomFilter.bySizeAndFPRate(10, 0.1).getNumHashes(), 3);
+ assertEquals(BloomFilter.bySizeAndFPRate(1000, 0.2).getNumHashes(), 2);
+ assertEquals(BloomFilter.bySizeAndFPRate(100000, 0.05).getNumHashes(), 4);
+ assertEquals(BloomFilter.bySizeAndFPRate(10000000, 0.01).getNumHashes(), 6);
}
@Test
public void testIntGenBFBySize() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put integers into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextInt());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextInt()));
}
}
@Test
public void testIntGenBFByCount() {
- final BloomFilter bf = BloomFilter.byCount(nKeys);
+ final BloomFilter bf = BloomFilter.byCount(numKeys);
// Put integers into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextInt());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextInt()));
}
}
@Test
public void testBytes() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put byte arrays into bloomfilter by random
- Random rand = new Random(kRandomSeed);
+ Random rand = new Random(randomSeed);
byte[] bytes = new byte[64];
- for (int i = 0; i < nKeys; i++) {
+ for (int i = 0; i < numKeys; i++) {
rand.nextBytes(bytes);
bf.put(bytes);
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
rand.nextBytes(bytes);
assertTrue(bf.mayContain(bytes));
}
@@ -98,90 +99,90 @@ public class TestBloomFilter {
@Test
public void testBoolean() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put booleans into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextBoolean());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextBoolean()));
}
}
@Test
public void testShort() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put shorts into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put((short)rand.nextInt());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain((short)rand.nextInt()));
}
}
@Test
public void testLong() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put longs into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextLong());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextLong()));
}
}
@Test
public void testFloat() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put floats into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextFloat());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextFloat()));
}
}
@Test
public void testDouble() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put doubles into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextDouble());
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextDouble()));
}
}
@Test
public void testString() {
- final BloomFilter bf = BloomFilter.bySize(nBytes);
+ final BloomFilter bf = BloomFilter.bySize(numBytes);
// Put strings into bloomfilter by random
- Random rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ Random rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
bf.put(rand.nextInt() + "");
}
// Reset the rand and check existence of the keys.
- rand = new Random(kRandomSeed);
- for (int i = 0; i < nKeys; i++) {
+ rand = new Random(randomSeed);
+ for (int i = 0; i < numKeys; i++) {
assertTrue(bf.mayContain(rand.nextInt() + ""));
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java
index e475163..f17dc93 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestBytes.java
@@ -14,9 +14,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
@@ -44,7 +46,7 @@ public class TestBytes {
Bytes.setUnsignedByte(bytes, (short) 1);
assertTrue(Bytes.getBoolean(bytes));
Bytes.setUnsignedByte(bytes, (short) 0);
- assertTrue(!Bytes.getBoolean(bytes));
+ assertFalse(Bytes.getBoolean(bytes));
// BYTES
short smallUbyte = 120;
@@ -97,14 +99,14 @@ public class TestBytes {
assertEquals(largeUlong, Bytes.getUnsignedLong(bytes));
// FLOAT
- float aFloat = 123.456f;
- Bytes.setFloat(bytes, aFloat);
- assertEquals(aFloat, Bytes.getFloat(bytes), 0.001);
+ float floatVal = 123.456f;
+ Bytes.setFloat(bytes, floatVal);
+ assertEquals(floatVal, Bytes.getFloat(bytes), 0.001);
// DOUBLE
- double aDouble = 123.456;
- Bytes.setDouble(bytes, aDouble);
- assertEquals(aDouble, Bytes.getDouble(bytes), 0.001);
+ double doubleVal = 123.456;
+ Bytes.setDouble(bytes, doubleVal);
+ assertEquals(doubleVal, Bytes.getDouble(bytes), 0.001);
// DECIMAL (32 bits)
BigDecimal smallDecimal = new BigDecimal(BigInteger.valueOf(123456789), 0,
@@ -112,10 +114,10 @@ public class TestBytes {
Bytes.setBigDecimal(bytes, smallDecimal, DecimalUtil.MAX_DECIMAL32_PRECISION);
assertEquals(smallDecimal,
Bytes.getDecimal(bytes, 0, DecimalUtil.MAX_DECIMAL32_PRECISION, 0));
- BigDecimal nSmallDecimal = new BigDecimal(BigInteger.valueOf(-123456789), 0,
+ BigDecimal negSmallDecimal = new BigDecimal(BigInteger.valueOf(-123456789), 0,
new MathContext(DecimalUtil.MAX_DECIMAL32_PRECISION, RoundingMode.UNNECESSARY));
- Bytes.setBigDecimal(bytes, nSmallDecimal, DecimalUtil.MAX_DECIMAL32_PRECISION);
- assertEquals(nSmallDecimal,
+ Bytes.setBigDecimal(bytes, negSmallDecimal, DecimalUtil.MAX_DECIMAL32_PRECISION);
+ assertEquals(negSmallDecimal,
Bytes.getDecimal(bytes, 0, DecimalUtil.MAX_DECIMAL32_PRECISION, 0));
// DECIMAL (64 bits)
@@ -124,10 +126,10 @@ public class TestBytes {
Bytes.setBigDecimal(bytes, mediumDecimal, DecimalUtil.MAX_DECIMAL64_PRECISION);
assertEquals(mediumDecimal,
Bytes.getDecimal(bytes, DecimalUtil.MAX_DECIMAL64_PRECISION, 0));
- BigDecimal nMediumDecimal = new BigDecimal(BigInteger.valueOf(-123456789L), 0,
+ BigDecimal negMediumDecimal = new BigDecimal(BigInteger.valueOf(-123456789L), 0,
new MathContext(DecimalUtil.MAX_DECIMAL64_PRECISION, RoundingMode.UNNECESSARY));
- Bytes.setBigDecimal(bytes, nMediumDecimal, DecimalUtil.MAX_DECIMAL64_PRECISION);
- assertEquals(nMediumDecimal,
+ Bytes.setBigDecimal(bytes, negMediumDecimal, DecimalUtil.MAX_DECIMAL64_PRECISION);
+ assertEquals(negMediumDecimal,
Bytes.getDecimal(bytes, DecimalUtil.MAX_DECIMAL64_PRECISION, 0));
// DECIMAL (128 bits)
@@ -137,11 +139,11 @@ public class TestBytes {
Bytes.setBigDecimal(bytes, largeDecimal, DecimalUtil.MAX_DECIMAL128_PRECISION);
assertEquals(largeDecimal,
Bytes.getDecimal(bytes, DecimalUtil.MAX_DECIMAL128_PRECISION, 0));
- BigDecimal nLargeDecimal =
+ BigDecimal negLargeDecimal =
new BigDecimal(new java.math.BigInteger("-1234567891011121314151617181920212223"), 0,
new MathContext(DecimalUtil.MAX_DECIMAL128_PRECISION, RoundingMode.UNNECESSARY));
- Bytes.setBigDecimal(bytes, nLargeDecimal, DecimalUtil.MAX_DECIMAL128_PRECISION);
- assertEquals(nLargeDecimal,
+ Bytes.setBigDecimal(bytes, negLargeDecimal, DecimalUtil.MAX_DECIMAL128_PRECISION);
+ assertEquals(negLargeDecimal,
Bytes.getDecimal(bytes, DecimalUtil.MAX_DECIMAL128_PRECISION, 0));
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestClientFailoverSupport.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestClientFailoverSupport.java
index 16d2618..65a67b8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestClientFailoverSupport.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestClientFailoverSupport.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
@@ -79,8 +80,8 @@ public class TestClientFailoverSupport {
@Override
public boolean get() throws Exception {
AsyncKuduScanner scanner = asyncClient.newScannerBuilder(table).build();
- int read_count = countRowsInScan(scanner);
- return read_count == rowCount;
+ int readCount = countRowsInScan(scanner);
+ return readCount == rowCount;
}
}, timeoutMs);
}
@@ -105,9 +106,9 @@ public class TestClientFailoverSupport {
* If we can successfully read back the rows written, that shows the client handled the failover
* correctly.
*/
+ @SuppressWarnings("deprecation")
private void doTestMasterFailover(MasterFailureType failureType) throws Exception {
- final String TABLE_NAME = TestClientFailoverSupport.class.getName()
- + "-" + failureType;
+ final String TABLE_NAME = TestClientFailoverSupport.class.getName() + "-" + failureType;
client.createTable(TABLE_NAME, basicSchema, getBasicCreateTableOptions());
KuduTable table = client.openTable(TABLE_NAME);
@@ -123,12 +124,14 @@ public class TestClientFailoverSupport {
// Kill or restart the leader master.
switch (failureType) {
- case KILL:
- harness.killLeaderMasterServer();
- break;
- case RESTART:
- harness.restartLeaderMaster();
- break;
+ case KILL:
+ harness.killLeaderMasterServer();
+ break;
+ case RESTART:
+ harness.restartLeaderMaster();
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected failure type: " + failureType);
}
// Kill the tablet server leader. This will force us to go back to the
@@ -140,10 +143,10 @@ public class TestClientFailoverSupport {
harness.killTabletLeader(tablets.get(0));
// Insert some more rows.
- for (int i = TOTAL_ROWS_TO_INSERT; i < 2*TOTAL_ROWS_TO_INSERT; i++) {
+ for (int i = TOTAL_ROWS_TO_INSERT; i < 2 * TOTAL_ROWS_TO_INSERT; i++) {
session.apply(createBasicSchemaInsert(table, i));
}
- waitUntilRowCount(table, 2*TOTAL_ROWS_TO_INSERT, DEFAULT_SLEEP);
+ waitUntilRowCount(table, 2 * TOTAL_ROWS_TO_INSERT, DEFAULT_SLEEP);
client.deleteTable(TABLE_NAME);
assertFalse(client.tableExists(TABLE_NAME));
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java
index 3732921..a8bc1de 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestColumnRangePredicate.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -39,14 +40,16 @@ public class TestColumnRangePredicate {
public RetryRule retryRule = new RetryRule();
@Test
+ @SuppressWarnings("deprecation")
public void testRawLists() {
- ColumnSchema col1 = new ColumnSchema.ColumnSchemaBuilder("col1", Type.INT32).build();
- ColumnSchema col2 = new ColumnSchema.ColumnSchemaBuilder("col2", Type.STRING).build();
+ final ColumnSchema col1 =
+ new ColumnSchema.ColumnSchemaBuilder("col1", Type.INT32).build();
+ final ColumnSchema col2 =
+ new ColumnSchema.ColumnSchemaBuilder("col2", Type.STRING).build();
- ColumnSchema col3 = new ColumnSchema.ColumnSchemaBuilder("col3", Type.DECIMAL)
+ final ColumnSchema col3 = new ColumnSchema.ColumnSchemaBuilder("col3", Type.DECIMAL)
.typeAttributes(new ColumnTypeAttributes.ColumnTypeAttributesBuilder()
- .precision(6).scale(2).build()
- ).build();
+ .precision(6).scale(2).build()).build();
ColumnRangePredicate pred1 = new ColumnRangePredicate(col1);
pred1.setLowerBound(1);
@@ -79,12 +82,15 @@ public class TestColumnRangePredicate {
assertFalse(decodedPreds.get(0).hasInclusiveUpperBound());
assertEquals(col1.getName(), decodedPreds.get(1).getColumn().getName());
- assertEquals(2, Bytes.getInt(decodedPreds.get(1).getInclusiveUpperBound().toByteArray()));
+ assertEquals(2,
+ Bytes.getInt(decodedPreds.get(1).getInclusiveUpperBound().toByteArray()));
assertFalse(decodedPreds.get(1).hasLowerBound());
assertEquals(col2.getName(), decodedPreds.get(2).getColumn().getName());
- assertEquals("aaa", Bytes.getString(decodedPreds.get(2).getLowerBound().toByteArray()));
- assertEquals("bbb", Bytes.getString(decodedPreds.get(2).getInclusiveUpperBound().toByteArray()));
+ assertEquals("aaa",
+ Bytes.getString(decodedPreds.get(2).getLowerBound().toByteArray()));
+ assertEquals("bbb",
+ Bytes.getString(decodedPreds.get(2).getInclusiveUpperBound().toByteArray()));
assertEquals(col3.getName(), decodedPreds.get(3).getColumn().getName());
assertEquals(12345, Bytes.getInt(decodedPreds.get(3).getLowerBound().toByteArray()));
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectToCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectToCluster.java
index 63430bc..6cadf5d 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectToCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectToCluster.java
@@ -50,7 +50,7 @@ public class TestConnectToCluster {
* RPC when connecting to a master which does not support the new
* ConnectToMaster RPC.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testFallbackConnectRpc() throws Exception {
try (MiniKuduCluster cluster = new MiniKuduCluster.MiniKuduClusterBuilder()
.addMasterServerFlag("--master_support_connect_to_master_rpc=0")
@@ -58,7 +58,7 @@ public class TestConnectToCluster {
.numTabletServers(0)
.build();
KuduClient c = new KuduClient.KuduClientBuilder(cluster.getMasterAddressesAsString())
- .build()) {
+ .build()) {
// Call some method which uses the master. This forces us to connect
// and verifies that the fallback works.
c.listTabletServers();
@@ -71,7 +71,7 @@ public class TestConnectToCluster {
* the resulting exception should clarify their error rather than
* saying that no leader was found.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testConnectToOneOfManyMasters() throws Exception {
int successes = 0;
try (MiniKuduCluster cluster = new MiniKuduCluster.MiniKuduClusterBuilder()
@@ -111,11 +111,11 @@ public class TestConnectToCluster {
*/
@Test(timeout = 10000)
public void testAggregateResponses() throws Exception {
- NonRecoverableException reusableNRE = new NonRecoverableException(
+ final NonRecoverableException reusableNRE = new NonRecoverableException(
Status.RuntimeError(""));
- RecoverableException reusableRE = new RecoverableException(
+ final RecoverableException reusableRE = new RecoverableException(
Status.RuntimeError(""));
- NoLeaderFoundException retryResponse =
+ final NoLeaderFoundException retryResponse =
new NoLeaderFoundException(Status.RuntimeError(""));
// We don't test for a particular good response, so as long as we pass something that's not an
// exception to runTest() we're good.
@@ -247,8 +247,6 @@ public class TestConnectToCluster {
grrm.getDeferred().join(); // Don't care about the response.
if ((expectedResponse instanceof Exception)) {
fail("Should not work " + expectedResponse.getClass());
- } else {
- // ok
}
} catch (Exception ex) {
assertEquals(expectedResponse.getClass(), ex.getClass());
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
index f111053..f202435 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestConnectionCache.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestErrorCollector.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestErrorCollector.java
index c742e9e..63b37b9 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestErrorCollector.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestErrorCollector.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import org.junit.Assert;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java
index d1ce86a..f7e8ffd 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestFlexiblePartitioning.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.KuduTestHarness.DEFAULT_SLEEP;
@@ -121,6 +122,7 @@ public class TestFlexiblePartitioning {
return rows;
}
+ @SuppressWarnings("deprecation")
private void testPartitionSchema(CreateTableOptions tableBuilder) throws Exception {
Schema schema = createSchema();
@@ -178,7 +180,8 @@ public class TestFlexiblePartitioning {
PartialRow upperBound = schema.newPartialRow();
maxRow.fillPartialRow(upperBound);
- Set<Row> expected = Sets.filter(rows, Predicates.and(minRow.gtePred()::apply, maxRow.ltPred()));
+ Set<Row> expected =
+ Sets.filter(rows, Predicates.and(minRow.gtePred()::apply, maxRow.ltPred()));
KuduScanner scanner = client.newScannerBuilder(table)
.lowerBound(lowerBound)
@@ -202,9 +205,9 @@ public class TestFlexiblePartitioning {
for (LocatedTablet tablet : tablets) {
KuduScanner scanner = client.newScannerBuilder(table)
- .lowerBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyStart())
- .exclusiveUpperBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyEnd())
- .build();
+ .lowerBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyStart())
+ .exclusiveUpperBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyEnd())
+ .build();
Set<Row> tabletResults = collectRows(scanner);
Set<Row> intersection = Sets.intersection(results, tabletResults);
assertEquals(new HashSet<>(), intersection);
@@ -222,16 +225,17 @@ public class TestFlexiblePartitioning {
PartialRow upperBound = schema.newPartialRow();
maxRow.fillPartialRow(upperBound);
- Set<Row> expected = Sets.filter(rows, Predicates.and(minRow.gtePred()::apply, maxRow.ltPred()));
+ Set<Row> expected = Sets.filter(rows,
+ Predicates.and(minRow.gtePred()::apply, maxRow.ltPred()));
Set<Row> results = new HashSet<>();
for (LocatedTablet tablet : tablets) {
KuduScanner scanner = client.newScannerBuilder(table)
- .lowerBound(lowerBound)
- .exclusiveUpperBound(upperBound)
- .lowerBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyStart())
- .exclusiveUpperBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyEnd())
- .build();
+ .lowerBound(lowerBound)
+ .exclusiveUpperBound(upperBound)
+ .lowerBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyStart())
+ .exclusiveUpperBoundPartitionKeyRaw(tablet.getPartition().getPartitionKeyEnd())
+ .build();
Set<Row> tabletResults = collectRows(scanner);
Set<Row> intersection = Sets.intersection(results, tabletResults);
assertEquals(new HashSet<>(), intersection);
@@ -247,7 +251,7 @@ public class TestFlexiblePartitioning {
CreateTableOptions tableBuilder = new CreateTableOptions();
tableBuilder.addHashPartitions(ImmutableList.of("a"), 3);
tableBuilder.addHashPartitions(ImmutableList.of("b", "c"), 3, 42);
- tableBuilder.setRangePartitionColumns(ImmutableList.<String>of());
+ tableBuilder.setRangePartitionColumns(ImmutableList.of());
testPartitionSchema(tableBuilder);
}
@@ -374,37 +378,37 @@ public class TestFlexiblePartitioning {
@Test(timeout = 100000)
public void testUnpartitionedTable() throws Exception {
CreateTableOptions tableBuilder =
- new CreateTableOptions().setRangePartitionColumns(ImmutableList.<String>of());
+ new CreateTableOptions().setRangePartitionColumns(ImmutableList.of());
testPartitionSchema(tableBuilder);
}
public static class Row implements Comparable<Row> {
- private final String a;
- private final String b;
- private final String c;
+ private final String valA;
+ private final String valB;
+ private final String valC;
public Row(String a, String b, String c) {
- this.a = a;
- this.b = b;
- this.c = c;
+ this.valA = a;
+ this.valB = b;
+ this.valC = c;
}
- public String getA() {
- return a;
+ public String getValA() {
+ return valA;
}
- public String getB() {
- return b;
+ public String getValB() {
+ return valB;
}
- public String getC() {
- return c;
+ public String getValC() {
+ return valC;
}
public void fillPartialRow(PartialRow row) {
- row.addString("a", a);
- row.addString("b", b);
- row.addString("c", c);
+ row.addString("a", valA);
+ row.addString("b", valB);
+ row.addString("c", valC);
}
private static Row fromResult(RowResult result) {
@@ -433,34 +437,38 @@ public class TestFlexiblePartitioning {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Row)) return false;
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Row)) {
+ return false;
+ }
Row row = (Row) o;
- return Objects.equals(a, row.a)
- && Objects.equals(b, row.b)
- && Objects.equals(c, row.c);
+ return Objects.equals(valA, row.valA) &&
+ Objects.equals(valB, row.valB) &&
+ Objects.equals(valC, row.valC);
}
@Override
public int hashCode() {
- return Objects.hash(a, b, c);
+ return Objects.hash(valA, valB, valC);
}
@Override
public int compareTo(Row other) {
return ComparisonChain.start()
- .compare(a, other.a)
- .compare(b, other.b)
- .compare(c, other.c)
+ .compare(valA, other.valA)
+ .compare(valB, other.valB)
+ .compare(valC, other.valC)
.result();
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
- .add("a", a)
- .add("b", b)
- .add("c", c)
+ .add("a", valA)
+ .add("b", valB)
+ .add("c", valC)
.toString();
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHandleTooBusy.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHandleTooBusy.java
index c540867..b3cb9f5 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHandleTooBusy.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHandleTooBusy.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.getBasicCreateTableOptions;
@@ -42,7 +43,8 @@ public class TestHandleTooBusy {
private static final Schema basicSchema = ClientTestUtil.getBasicSchema();
- private static final MiniKuduClusterBuilder clusterBuilder = KuduTestHarness.getBaseClusterBuilder()
+ private static final MiniKuduClusterBuilder clusterBuilder =
+ KuduTestHarness.getBaseClusterBuilder()
// Short queue to provoke overflow.
.addMasterServerFlag("--rpc_service_queue_length=1")
// Low number of service threads, so things stay in the queue.
@@ -57,7 +59,7 @@ public class TestHandleTooBusy {
* Provoke overflows in the master RPC queue while connecting to the master
* and performing location lookups.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testMasterLookupOverflow() throws Exception {
harness.getClient().createTable(TABLE_NAME, basicSchema, getBasicCreateTableOptions());
ExecutorService exec = Executors.newCachedThreadPool();
@@ -67,8 +69,9 @@ public class TestHandleTooBusy {
@Override
public Void call() throws Exception {
for (int i = 0; i < 5; i++) {
- try (KuduClient c = new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
- .build()) {
+ try (KuduClient c =
+ new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
+ .build()) {
KuduTable table = c.openTable(TABLE_NAME);
for (int j = 0; j < 5; j++) {
KuduScanToken.KuduScanTokenBuilder scanBuilder = c.newScanTokenBuilder(table);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java
index f916987..f5bc9a8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestHybridTime.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.Type.STRING;
@@ -52,7 +53,7 @@ public class TestHybridTime {
// Generate a unique table name
private static final String TABLE_NAME =
- TestHybridTime.class.getName() + "-" + System.currentTimeMillis();
+ TestHybridTime.class.getName() + "-" + System.currentTimeMillis();
private static final Schema schema = getSchema();
private KuduTable table;
@@ -134,9 +135,9 @@ public class TestHybridTime {
long snapshotTime = physicalAndLogicalToHTTimestamp(futureTs, logicalValues.get(i));
int expected = i + 1;
assertEquals(
- String.format("wrong number of rows for write %d at logical timestamp %d", i, logicalValue),
- expected,
- scanAtSnapshot(snapshotTime));
+ String.format("wrong number of rows for write %d at logical timestamp %d",
+ i, logicalValue),
+ expected, scanAtSnapshot(snapshotTime));
}
// The last snapshots needs to be one into the future w.r.t. the last write's timestamp
@@ -149,7 +150,8 @@ public class TestHybridTime {
}
private int scanAtSnapshot(long time) throws Exception {
- AsyncKuduScanner.AsyncKuduScannerBuilder builder = harness.getAsyncClient().newScannerBuilder(table)
+ AsyncKuduScanner.AsyncKuduScannerBuilder builder =
+ harness.getAsyncClient().newScannerBuilder(table)
.snapshotTimestampRaw(time)
.readMode(AsyncKuduScanner.ReadMode.READ_AT_SNAPSHOT);
return countRowsInScan(builder.build());
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
index ec9670d..d7708d8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -92,7 +93,7 @@ public class TestKeyEncoding {
}
return new PartitionSchema(
new PartitionSchema.RangeSchema(columnIds),
- ImmutableList.<PartitionSchema.HashBucketSchema>of(), schema);
+ ImmutableList.of(), schema);
}
/**
@@ -319,7 +320,7 @@ public class TestKeyEncoding {
new ColumnSchemaBuilder("b", Type.STRING).key(true),
new ColumnSchemaBuilder("c", Type.STRING).key(true));
- PartitionSchema partitionSchema =
+ final PartitionSchema partitionSchema =
new PartitionSchema(new RangeSchema(ImmutableList.of(0, 1, 2)),
ImmutableList.of(
new HashBucketSchema(ImmutableList.of(0, 1), 32, 0),
@@ -401,17 +402,17 @@ public class TestKeyEncoding {
KuduTable table = client.createTable("testAllPrimaryKeyTypes-" + System.currentTimeMillis(),
schema, defaultCreateTableOptions(schema));
- KuduSession session = client.newSession();
+ final KuduSession session = client.newSession();
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
row.addByte(0, (byte) 1);
row.addShort(1, (short) 2);
row.addInt(2, 3);
- row.addLong(3, 4l);
+ row.addLong(3, 4L);
row.addString(4, "foo");
row.addBinary(5, "bar".getBytes(UTF_8));
- row.addLong(6, 6l);
+ row.addLong(6, 6L);
row.addDecimal(7, BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL32));
row.addDecimal(8, BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL64));
row.addDecimal(9, new BigDecimal(DecimalUtil.MAX_UNSCALED_DECIMAL128));
@@ -430,10 +431,10 @@ public class TestKeyEncoding {
assertEquals((byte) 0x01, rr.getByte(0));
assertEquals((short) 2, rr.getShort(1));
assertEquals(3, rr.getInt(2));
- assertEquals(4l, rr.getLong(3));
+ assertEquals(4L, rr.getLong(3));
assertBytesEquals(rr.getBinaryCopy(4), "foo");
assertBytesEquals(rr.getBinaryCopy(5), "bar");
- assertEquals(6l, rr.getLong(6));
+ assertEquals(6L, rr.getLong(6));
assertTrue(BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL32)
.compareTo(rr.getDecimal(7)) == 0);
assertTrue(BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL64)
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
index 91703dc..b4b3d2d 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -110,23 +111,23 @@ public class TestKuduClient {
assertTrue(client.hasLastPropagatedTimestamp());
assertTrue(asyncClient.hasLastPropagatedTimestamp());
- long initial_ts = client.getLastPropagatedTimestamp();
+ long initialTs = client.getLastPropagatedTimestamp();
// Check that the initial timestamp is consistent with the asynchronous client.
- assertEquals(initial_ts, client.getLastPropagatedTimestamp());
- assertEquals(initial_ts, asyncClient.getLastPropagatedTimestamp());
+ assertEquals(initialTs, client.getLastPropagatedTimestamp());
+ assertEquals(initialTs, asyncClient.getLastPropagatedTimestamp());
// Attempt to change the timestamp to a lower value. This should not change
// the internal timestamp, as it must be monotonically increasing.
- client.updateLastPropagatedTimestamp(initial_ts - 1);
- assertEquals(initial_ts, client.getLastPropagatedTimestamp());
- assertEquals(initial_ts, asyncClient.getLastPropagatedTimestamp());
+ client.updateLastPropagatedTimestamp(initialTs - 1);
+ assertEquals(initialTs, client.getLastPropagatedTimestamp());
+ assertEquals(initialTs, asyncClient.getLastPropagatedTimestamp());
// Use the synchronous client to update the last propagated timestamp and
// check with both clients that the timestamp was updated.
- client.updateLastPropagatedTimestamp(initial_ts + 1);
- assertEquals(initial_ts + 1, client.getLastPropagatedTimestamp());
- assertEquals(initial_ts + 1, asyncClient.getLastPropagatedTimestamp());
+ client.updateLastPropagatedTimestamp(initialTs + 1);
+ assertEquals(initialTs + 1, client.getLastPropagatedTimestamp());
+ assertEquals(initialTs + 1, asyncClient.getLastPropagatedTimestamp());
}
/**
@@ -382,10 +383,6 @@ public class TestKuduClient {
// Two rows which should not succeed.
"fail_1,a,b,c,NULL",
"fail_2,a,b,NULL,d");
- List<String> expectedStrings = ImmutableList.of(
- "STRING key=r1, STRING c1=a, STRING c2=b, STRING c3=c, STRING c4=d",
- "STRING key=r2, STRING c1=NULL, STRING c2=NULL, STRING c3=c, STRING c4=d",
- "STRING key=r3, STRING c1=NULL, STRING c2=def, STRING c3=c, STRING c4=def");
for (String row : rows) {
try {
String[] fields = row.split(",", -1);
@@ -411,6 +408,10 @@ public class TestKuduClient {
session.flush();
// Check that we got the results we expected.
+ List<String> expectedStrings = ImmutableList.of(
+ "STRING key=r1, STRING c1=a, STRING c2=b, STRING c3=c, STRING c4=d",
+ "STRING key=r2, STRING c1=NULL, STRING c2=NULL, STRING c3=c, STRING c4=d",
+ "STRING key=r3, STRING c1=NULL, STRING c2=def, STRING c3=c, STRING c4=def");
List<String> rowStrings = scanTableToStrings(table);
Collections.sort(rowStrings);
assertArrayEquals(rowStrings.toArray(new String[0]),
@@ -450,13 +451,11 @@ public class TestKuduClient {
List<String> rowStrings = scanTableToStrings(table);
assertEquals(100, rowStrings.size());
assertEquals(
- "VARCHAR key(10)=key_03, VARCHAR c1(10)=c1_3, VARCHAR c2(10)=c2_3," +
- " VARCHAR c3(10)=c3_3, VARCHAR c4(10)=c4_3",
- rowStrings.get(3));
+ "VARCHAR key(10)=key_03, VARCHAR c1(10)=c1_3, VARCHAR c2(10)=c2_3," +
+ " VARCHAR c3(10)=c3_3, VARCHAR c4(10)=c4_3", rowStrings.get(3));
assertEquals(
- "VARCHAR key(10)=key_04, VARCHAR c1(10)=c1_4, VARCHAR c2(10)=c2_4," +
- " VARCHAR c3(10)=NULL, VARCHAR c4(10)=c4_4",
- rowStrings.get(4));
+ "VARCHAR key(10)=key_04, VARCHAR c1(10)=c1_4, VARCHAR c2(10)=c2_4," +
+ " VARCHAR c3(10)=NULL, VARCHAR c4(10)=c4_4", rowStrings.get(4));
KuduScanner scanner = client.newScannerBuilder(table).build();
@@ -469,8 +468,10 @@ public class TestKuduClient {
try {
next.getInt("c2");
fail("IllegalArgumentException was not thrown when accessing " +
- "a VARCHAR column with getInt");
- } catch (IllegalArgumentException ignored) {}
+ "a VARCHAR column with getInt");
+ } catch (IllegalArgumentException ignored) {
+ // ignored
+ }
}
/**
@@ -523,8 +524,10 @@ public class TestKuduClient {
try {
next.getInt("c2");
fail("IllegalArgumentException was not thrown when accessing " +
- "a string column with getInt");
- } catch (IllegalArgumentException ignored) {}
+ "a string column with getInt");
+ } catch (IllegalArgumentException ignored) {
+ // ignored
+ }
}
/**
@@ -535,7 +538,6 @@ public class TestKuduClient {
Schema schema = createManyStringsSchema();
client.createTable(TABLE_NAME, schema, getBasicCreateTableOptions());
- KuduSession session = client.newSession();
KuduTable table = client.openTable(TABLE_NAME);
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
@@ -544,6 +546,7 @@ public class TestKuduClient {
row.addString("c2", "hello"); // some normal chars
row.addString("c4", "🐱"); // supplemental plane
+ KuduSession session = client.newSession();
session.apply(insert);
session.flush();
@@ -586,8 +589,8 @@ public class TestKuduClient {
assertEquals(100, rowStrings.size());
for (int i = 0; i < rowStrings.size(); i++) {
StringBuilder expectedRow = new StringBuilder();
- expectedRow.append(String.format("BINARY key=\"key_%02d\", STRING c1=✁✂✃✄✆, DOUBLE c2=%.1f,"
- + " BINARY c3=", i, (double) i));
+ expectedRow.append(String.format("BINARY key=\"key_%02d\", STRING c1=✁✂✃✄✆, DOUBLE c2=%.1f," +
+ " BINARY c3=", i, (double) i));
if (i % 2 == 1) {
expectedRow.append(Bytes.pretty(testArray));
} else {
@@ -614,7 +617,7 @@ public class TestKuduClient {
Insert insert = table.newInsert();
PartialRow row = insert.getRow();
long timestamp = System.currentTimeMillis() * 1000;
- while(timestamp == lastTimestamp) {
+ while (timestamp == lastTimestamp) {
timestamp = System.currentTimeMillis() * 1000;
}
timestamps.add(timestamp);
@@ -675,9 +678,10 @@ public class TestKuduClient {
assertEquals(9, rowStrings.size());
for (int i = 0; i < rowStrings.size(); i++) {
StringBuilder expectedRow = new StringBuilder();
- expectedRow.append(String.format("DECIMAL key(18, 0)=%s, DECIMAL c1(38, 0)=", String.valueOf(i)));
+ expectedRow.append(String.format("DECIMAL key(18, 0)=%s, DECIMAL c1(38, 0)=",
+ String.valueOf(i)));
if (i % 2 == 1) {
- expectedRow.append(String.valueOf(i));
+ expectedRow.append(i);
} else {
expectedRow.append("NULL");
}
@@ -694,14 +698,14 @@ public class TestKuduClient {
client.createTable(TABLE_NAME, basicSchema, getBasicTableOptionsWithNonCoveredRange());
KuduTable table = client.openTable(TABLE_NAME);
KuduSession session = client.newSession();
- int num_rows = 100;
- for (int key = 0; key < num_rows; key++) {
+ int numRows = 100;
+ for (int key = 0; key < numRows; key++) {
session.apply(createBasicSchemaInsert(table, key));
}
// Test with some non-positive limits, expecting to raise an exception.
- int non_positives[] = { -1, 0 };
- for (int limit : non_positives) {
+ int[] nonPositives = { -1, 0 };
+ for (int limit : nonPositives) {
try {
client.newScannerBuilder(table).limit(limit).build();
fail();
@@ -711,7 +715,7 @@ public class TestKuduClient {
}
// Test with a limit and ensure we get the expected number of rows.
- int limits[] = { num_rows - 1, num_rows, num_rows + 1 };
+ int[] limits = { numRows - 1, numRows, numRows + 1 };
for (int limit : limits) {
KuduScanner scanner = client.newScannerBuilder(table)
.limit(limit)
@@ -720,8 +724,8 @@ public class TestKuduClient {
while (scanner.hasMoreRows()) {
count += scanner.nextRows().getNumRows();
}
- assertEquals(String.format("Limit %d returned %d/%d rows", limit, count, num_rows),
- Math.min(num_rows, limit), count);
+ assertEquals(String.format("Limit %d returned %d/%d rows", limit, count, numRows),
+ Math.min(numRows, limit), count);
}
// Now test with limits for async scanners.
@@ -729,7 +733,7 @@ public class TestKuduClient {
AsyncKuduScanner scanner = new AsyncKuduScanner.AsyncKuduScannerBuilder(asyncClient, table)
.limit(limit)
.build();
- assertEquals(Math.min(limit, num_rows), countRowsInScan(scanner));
+ assertEquals(Math.min(limit, numRows), countRowsInScan(scanner));
}
}
@@ -784,8 +788,8 @@ public class TestKuduClient {
// IS NOT NULL
assertEquals(100, scanTableToStrings(table,
- KuduPredicate.newIsNotNullPredicate(schema.getColumn("c1")),
- KuduPredicate.newIsNotNullPredicate(schema.getColumn("key"))
+ KuduPredicate.newIsNotNullPredicate(schema.getColumn("c1")),
+ KuduPredicate.newIsNotNullPredicate(schema.getColumn("key"))
).size());
assertEquals(50, scanTableToStrings(table,
KuduPredicate.newIsNotNullPredicate(schema.getColumn("c3"))
@@ -793,28 +797,28 @@ public class TestKuduClient {
// IS NULL
assertEquals(0, scanTableToStrings(table,
- KuduPredicate.newIsNullPredicate(schema.getColumn("c2")),
- KuduPredicate.newIsNullPredicate(schema.getColumn("key"))
+ KuduPredicate.newIsNullPredicate(schema.getColumn("c2")),
+ KuduPredicate.newIsNullPredicate(schema.getColumn("key"))
).size());
assertEquals(50, scanTableToStrings(table,
- KuduPredicate.newIsNullPredicate(schema.getColumn("c3"))
+ KuduPredicate.newIsNullPredicate(schema.getColumn("c3"))
).size());
// IN list
assertEquals(3, scanTableToStrings(table,
- KuduPredicate.newInListPredicate(schema.getColumn("key"),
- ImmutableList.of("key_30", "key_01", "invalid", "key_99"))
+ KuduPredicate.newInListPredicate(schema.getColumn("key"),
+ ImmutableList.of("key_30", "key_01", "invalid", "key_99"))
).size());
assertEquals(3, scanTableToStrings(table,
- KuduPredicate.newInListPredicate(schema.getColumn("c2"),
- ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99"))
+ KuduPredicate.newInListPredicate(schema.getColumn("c2"),
+ ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99"))
).size());
assertEquals(2, scanTableToStrings(table,
- KuduPredicate.newInListPredicate(schema.getColumn("c2"),
- ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99")),
- KuduPredicate.newIsNotNullPredicate(schema.getColumn("c2")),
- KuduPredicate.newInListPredicate(schema.getColumn("key"),
- ImmutableList.of("key_30", "key_45", "invalid", "key_99"))
+ KuduPredicate.newInListPredicate(schema.getColumn("c2"),
+ ImmutableList.of("c2_30", "c2_1", "invalid", "c2_99")),
+ KuduPredicate.newIsNotNullPredicate(schema.getColumn("c2")),
+ KuduPredicate.newInListPredicate(schema.getColumn("key"),
+ ImmutableList.of("key_30", "key_45", "invalid", "key_99"))
).size());
}
@@ -902,7 +906,8 @@ public class TestKuduClient {
}
KuduTable table = client.openTable(TABLE_NAME);
- AsyncKuduScanner scanner = new AsyncKuduScanner.AsyncKuduScannerBuilder(asyncClient, table).build();
+ AsyncKuduScanner scanner =
+ new AsyncKuduScanner.AsyncKuduScannerBuilder(asyncClient, table).build();
assertEquals(1, countRowsInScan(scanner));
}
@@ -961,11 +966,13 @@ public class TestKuduClient {
@Test(timeout = 100000)
public void testCustomNioExecutor() throws Exception {
long startTime = System.nanoTime();
- try (KuduClient localClient = new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
- .nioExecutors(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(2))
- .bossCount(1)
- .workerCount(2)
- .build()) {
+ try (KuduClient localClient =
+ new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
+ .nioExecutors(Executors.newFixedThreadPool(1),
+ Executors.newFixedThreadPool(2))
+ .bossCount(1)
+ .workerCount(2)
+ .build()) {
long buildTime = (System.nanoTime() - startTime) / 1000000000L;
assertTrue("Building KuduClient is slow, maybe netty get stuck", buildTime < 3);
localClient.createTable(TABLE_NAME, basicSchema, getBasicCreateTableOptions());
@@ -991,13 +998,13 @@ public class TestKuduClient {
});
threads[t].start();
}
- for (int t = 0; t< 4;t++) {
+ for (int t = 0; t < 4; t++) {
threads[t].join();
}
}
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testNoDefaultPartitioning() throws Exception {
client.createTable(TABLE_NAME, basicSchema, new CreateTableOptions());
}
@@ -1021,13 +1028,14 @@ public class TestKuduClient {
// Add a range partition with a separate client. The new client is necessary
// in order to avoid clearing the meta cache as part of the alter operation.
- try (KuduClient alterClient = new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
- .defaultAdminOperationTimeoutMs(harness.DEFAULT_SLEEP)
- .build()) {
- AlterTableOptions alter = new AlterTableOptions();
+ try (KuduClient alterClient =
+ new KuduClient.KuduClientBuilder(harness.getMasterAddressesAsString())
+ .defaultAdminOperationTimeoutMs(KuduTestHarness.DEFAULT_SLEEP)
+ .build()) {
lower = basicSchema.newPartialRow();
upper = basicSchema.newPartialRow();
lower.addInt("key", 1);
+ AlterTableOptions alter = new AlterTableOptions();
alter.addRangePartition(lower, upper);
alterClient.alterTable(TABLE_NAME, alter);
}
@@ -1143,7 +1151,7 @@ public class TestKuduClient {
// Create a new client.
AsyncKuduClient asyncKuduClient = new AsyncKuduClient
.AsyncKuduClientBuilder(harness.getMasterAddressesAsString())
- .defaultAdminOperationTimeoutMs(harness.DEFAULT_SLEEP)
+ .defaultAdminOperationTimeoutMs(KuduTestHarness.DEFAULT_SLEEP)
.build();
// From the same client continuously performs inserts to a tablet
// in the given flush mode.
@@ -1177,9 +1185,9 @@ public class TestKuduClient {
long preTs = asyncKuduClient.getLastPropagatedTimestamp();
assertNotEquals(AsyncKuduClient.NO_TIMESTAMP, preTs);
- long row_count = countRowsInScan(syncScanner);
- long expected_count = 100L * (i + 1);
- assertTrue(expected_count <= row_count);
+ long rowCount = countRowsInScan(syncScanner);
+ long expectedCount = 100L * (i + 1);
+ assertTrue(expectedCount <= rowCount);
// After the scan, verify that the chosen snapshot timestamp is
// returned from the server and it is larger than the previous
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPartitioner.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPartitioner.java
index 1153051..29bd3ed 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPartitioner.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPartitioner.java
@@ -58,9 +58,9 @@ public class TestKuduPartitioner {
// 3333-6666 x x x
// >=6666 x x x
Schema basicSchema = getBasicSchema();
- int numRanges = 3;
- int numHashPartitions = 3;
- String tableName = "TestPartitioner";
+ final int numRanges = 3;
+ final int numHashPartitions = 3;
+ final String tableName = "TestPartitioner";
List<PartialRow> splitRows = new ArrayList<>();
for (int split : Arrays.asList(3333, 6666)) {
@@ -120,15 +120,14 @@ public class TestKuduPartitioner {
// If we recreate the partitioner, it should get the new partitioning info.
part = new KuduPartitioner.KuduPartitionerBuilder(table).build();
- numRanges = 1;
- assertEquals(numRanges * numHashPartitions, part.numPartitions());
+ assertEquals(numHashPartitions, part.numPartitions());
}
@Test
public void testPartitionerNonCoveredRange() throws Exception {
- Schema basicSchema = getBasicSchema();
- int numHashPartitions = 3;
- String tableName = "TestPartitionerNonCoveredRange";
+ final Schema basicSchema = getBasicSchema();
+ final int numHashPartitions = 3;
+ final String tableName = "TestPartitionerNonCoveredRange";
CreateTableOptions createOptions = new CreateTableOptions();
createOptions.addHashPartitions(Collections.singletonList("key"), numHashPartitions);
@@ -203,7 +202,8 @@ public class TestKuduPartitioner {
// This partitioner should build correctly because the table cache holds the partitions
// from the previous partitioner.
- KuduPartitioner partitionerFromCache = new KuduPartitioner.KuduPartitionerBuilder(table).build();
+ KuduPartitioner partitionerFromCache =
+ new KuduPartitioner.KuduPartitionerBuilder(table).build();
assertEquals(partitioner.numPartitions(), partitionerFromCache.numPartitions());
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
index dd9c827..14d436c 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
@@ -826,8 +826,10 @@ public class TestKuduPredicate {
new byte[] { (byte) 0 },
new byte[] { (byte) 10 }));
- testMerge(KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 12, (byte) 14, (byte) 16, (byte) 18)),
- KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 14, (byte) 18, (byte) 20)),
+ testMerge(KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 12, (byte) 14,
+ (byte) 16, (byte) 18)),
+ KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 14, (byte) 18,
+ (byte) 20)),
KuduPredicate.newInListPredicate(byteCol, ImmutableList.of((byte) 14, (byte) 18)));
testMerge(KuduPredicate.newComparisonPredicate(shortCol, GREATER_EQUAL, 0),
@@ -837,8 +839,10 @@ public class TestKuduPredicate {
Bytes.fromShort((short) 0),
Bytes.fromShort((short) 10)));
- testMerge(KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 12, (short) 14, (short) 16, (short) 18)),
- KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 14, (short) 18, (short) 20)),
+ testMerge(KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 12, (short) 14,
+ (short) 16, (short) 18)),
+ KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 14, (short) 18,
+ (short) 20)),
KuduPredicate.newInListPredicate(shortCol, ImmutableList.of((short) 14, (short) 18)));
testMerge(KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, 0),
@@ -949,14 +953,14 @@ public class TestKuduPredicate {
new byte[] {98, 97, 114},
new byte[] {102, 111, 111}));
- byte[] bA = "a".getBytes(UTF_8);
- byte[] bB = "b".getBytes(UTF_8);
- byte[] bC = "c".getBytes(UTF_8);
- byte[] bD = "d".getBytes(UTF_8);
- byte[] bE = "e".getBytes(UTF_8);
- testMerge(KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bA, bB, bC, bD)),
- KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bB, bD, bE)),
- KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bB, bD)));
+ byte[] valA = "a".getBytes(UTF_8);
+ byte[] valB = "b".getBytes(UTF_8);
+ byte[] valC = "c".getBytes(UTF_8);
+ byte[] valD = "d".getBytes(UTF_8);
+ byte[] valE = "e".getBytes(UTF_8);
+ testMerge(KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(valA, valB, valC, valD)),
+ KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(valB, valD, valE)),
+ KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(valB, valD)));
}
@Test
@@ -970,16 +974,21 @@ public class TestKuduPredicate {
Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, LESS_EQUAL, 10),
KuduPredicate.newComparisonPredicate(longCol, LESS, 11));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, LESS_EQUAL, 12.345f),
- KuduPredicate.newComparisonPredicate(floatCol, LESS, Math.nextAfter(12.345f, Float.POSITIVE_INFINITY)));
+ KuduPredicate.newComparisonPredicate(floatCol, LESS, Math.nextAfter(12.345f,
+ Float.POSITIVE_INFINITY)));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, LESS_EQUAL, 12.345),
- KuduPredicate.newComparisonPredicate(doubleCol, LESS, Math.nextAfter(12.345, Float.POSITIVE_INFINITY)));
+ KuduPredicate.newComparisonPredicate(doubleCol, LESS, Math.nextAfter(12.345,
+ Float.POSITIVE_INFINITY)));
Assert.assertEquals(
- KuduPredicate.newComparisonPredicate(decimal32Col, LESS_EQUAL, BigDecimal.valueOf(12345,2)),
- KuduPredicate.newComparisonPredicate(decimal32Col, LESS, BigDecimal.valueOf(12346,2)));
+ KuduPredicate.newComparisonPredicate(decimal32Col, LESS_EQUAL,
+ BigDecimal.valueOf(12345,2)),
+ KuduPredicate.newComparisonPredicate(decimal32Col, LESS,
+ BigDecimal.valueOf(12346,2)));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(stringCol, LESS_EQUAL, "a"),
KuduPredicate.newComparisonPredicate(stringCol, LESS, "a\0"));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(binaryCol, LESS_EQUAL, new byte[] { (byte) 10 }),
- KuduPredicate.newComparisonPredicate(binaryCol, LESS, new byte[] { (byte) 10, (byte) 0 }));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(binaryCol, LESS_EQUAL, new byte[] { (byte) 10 }),
+ KuduPredicate.newComparisonPredicate(binaryCol, LESS, new byte[] { (byte) 10, (byte) 0 }));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(varcharCol, LESS_EQUAL, "a"),
KuduPredicate.newComparisonPredicate(varcharCol, LESS, "a\0"));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(byteCol, LESS_EQUAL, Byte.MAX_VALUE),
@@ -990,14 +999,18 @@ public class TestKuduPredicate {
KuduPredicate.newIsNotNullPredicate(intCol));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, LESS_EQUAL, Long.MAX_VALUE),
KuduPredicate.newIsNotNullPredicate(longCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, LESS_EQUAL, Float.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(floatCol, LESS, Float.POSITIVE_INFINITY));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, LESS_EQUAL, Float.POSITIVE_INFINITY),
- KuduPredicate.newIsNotNullPredicate(floatCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, LESS_EQUAL, Double.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(doubleCol, LESS, Double.POSITIVE_INFINITY));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, LESS_EQUAL, Double.POSITIVE_INFINITY),
- KuduPredicate.newIsNotNullPredicate(doubleCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, LESS_EQUAL, Float.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(floatCol, LESS, Float.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, LESS_EQUAL, Float.POSITIVE_INFINITY),
+ KuduPredicate.newIsNotNullPredicate(floatCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, LESS_EQUAL, Double.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(doubleCol, LESS, Double.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, LESS_EQUAL, Double.POSITIVE_INFINITY),
+ KuduPredicate.newIsNotNullPredicate(doubleCol));
}
@Test
@@ -1010,17 +1023,25 @@ public class TestKuduPredicate {
KuduPredicate.newComparisonPredicate(intCol, GREATER, 10));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, 11),
KuduPredicate.newComparisonPredicate(longCol, GREATER, 10));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Math.nextAfter(12.345f, Float.MAX_VALUE)),
- KuduPredicate.newComparisonPredicate(floatCol, GREATER, 12.345f));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Math.nextAfter(12.345, Float.MAX_VALUE)),
- KuduPredicate.newComparisonPredicate(doubleCol, GREATER, 12.345));
Assert.assertEquals(
- KuduPredicate.newComparisonPredicate(decimal32Col, GREATER_EQUAL, BigDecimal.valueOf(12346, 2)),
- KuduPredicate.newComparisonPredicate(decimal32Col, GREATER, BigDecimal.valueOf(12345, 2)));
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL,
+ Math.nextAfter(12.345f, Float.MAX_VALUE)),
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER, 12.345f));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL,
+ Math.nextAfter(12.345, Float.MAX_VALUE)),
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER, 12.345));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(decimal32Col, GREATER_EQUAL,
+ BigDecimal.valueOf(12346, 2)),
+ KuduPredicate.newComparisonPredicate(decimal32Col, GREATER,
+ BigDecimal.valueOf(12345, 2)));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(stringCol, GREATER_EQUAL, "a\0"),
KuduPredicate.newComparisonPredicate(stringCol, GREATER, "a"));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(binaryCol, GREATER_EQUAL, new byte[] { (byte) 10, (byte) 0 }),
- KuduPredicate.newComparisonPredicate(binaryCol, GREATER, new byte[] { (byte) 10 }));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(binaryCol, GREATER_EQUAL,
+ new byte[] { (byte) 10, (byte) 0 }),
+ KuduPredicate.newComparisonPredicate(binaryCol, GREATER, new byte[] { (byte) 10 }));
Assert.assertEquals(KuduPredicate.none(byteCol),
KuduPredicate.newComparisonPredicate(byteCol, GREATER, Byte.MAX_VALUE));
@@ -1030,14 +1051,18 @@ public class TestKuduPredicate {
KuduPredicate.newComparisonPredicate(intCol, GREATER, Integer.MAX_VALUE));
Assert.assertEquals(KuduPredicate.none(longCol),
KuduPredicate.newComparisonPredicate(longCol, GREATER, Long.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.POSITIVE_INFINITY),
- KuduPredicate.newComparisonPredicate(floatCol, GREATER, Float.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.none(floatCol),
- KuduPredicate.newComparisonPredicate(floatCol, GREATER, Float.POSITIVE_INFINITY));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.POSITIVE_INFINITY),
- KuduPredicate.newComparisonPredicate(doubleCol, GREATER, Double.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.none(doubleCol),
- KuduPredicate.newComparisonPredicate(doubleCol, GREATER, Double.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.POSITIVE_INFINITY),
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER, Float.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.none(floatCol),
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER, Float.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.POSITIVE_INFINITY),
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER, Double.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.none(doubleCol),
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER, Double.POSITIVE_INFINITY));
}
@Test
@@ -1050,10 +1075,12 @@ public class TestKuduPredicate {
KuduPredicate.none(intCol));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, LESS, Long.MIN_VALUE),
KuduPredicate.none(longCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, LESS, Float.NEGATIVE_INFINITY),
- KuduPredicate.none(floatCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, LESS, Double.NEGATIVE_INFINITY),
- KuduPredicate.none(doubleCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, LESS, Float.NEGATIVE_INFINITY),
+ KuduPredicate.none(floatCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, LESS, Double.NEGATIVE_INFINITY),
+ KuduPredicate.none(doubleCol));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(decimal32Col, LESS,
DecimalUtil.minValue(DecimalUtil.MAX_DECIMAL32_PRECISION, 2)),
KuduPredicate.none(decimal32Col));
@@ -1073,18 +1100,24 @@ public class TestKuduPredicate {
@Test
public void testGreaterEqual() {
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(byteCol, GREATER_EQUAL, Byte.MIN_VALUE),
- KuduPredicate.newIsNotNullPredicate(byteCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(shortCol, GREATER_EQUAL, Short.MIN_VALUE),
- KuduPredicate.newIsNotNullPredicate(shortCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(intCol, GREATER_EQUAL, Integer.MIN_VALUE),
- KuduPredicate.newIsNotNullPredicate(intCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, Long.MIN_VALUE),
- KuduPredicate.newIsNotNullPredicate(longCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.NEGATIVE_INFINITY),
- KuduPredicate.newIsNotNullPredicate(floatCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.NEGATIVE_INFINITY),
- KuduPredicate.newIsNotNullPredicate(doubleCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(byteCol, GREATER_EQUAL, Byte.MIN_VALUE),
+ KuduPredicate.newIsNotNullPredicate(byteCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(shortCol, GREATER_EQUAL, Short.MIN_VALUE),
+ KuduPredicate.newIsNotNullPredicate(shortCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(intCol, GREATER_EQUAL, Integer.MIN_VALUE),
+ KuduPredicate.newIsNotNullPredicate(intCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, Long.MIN_VALUE),
+ KuduPredicate.newIsNotNullPredicate(longCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.NEGATIVE_INFINITY),
+ KuduPredicate.newIsNotNullPredicate(floatCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.NEGATIVE_INFINITY),
+ KuduPredicate.newIsNotNullPredicate(doubleCol));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(decimal32Col, GREATER_EQUAL,
DecimalUtil.minValue(DecimalUtil.MAX_DECIMAL32_PRECISION, 2)),
KuduPredicate.newIsNotNullPredicate(decimal32Col));
@@ -1096,23 +1129,30 @@ public class TestKuduPredicate {
KuduPredicate.newIsNotNullPredicate(decimal128Col));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(stringCol, GREATER_EQUAL, ""),
KuduPredicate.newIsNotNullPredicate(stringCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(binaryCol, GREATER_EQUAL, new byte[] {}),
- KuduPredicate.newIsNotNullPredicate(binaryCol));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(binaryCol, GREATER_EQUAL, new byte[] {}),
+ KuduPredicate.newIsNotNullPredicate(binaryCol));
Assert.assertEquals(KuduPredicate.newComparisonPredicate(varcharCol, GREATER_EQUAL, ""),
KuduPredicate.newIsNotNullPredicate(varcharCol));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(byteCol, GREATER_EQUAL, Byte.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(byteCol, EQUAL, Byte.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(shortCol, GREATER_EQUAL, Short.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(shortCol, EQUAL, Short.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(intCol, GREATER_EQUAL, Integer.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(intCol, EQUAL, Integer.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, Long.MAX_VALUE),
- KuduPredicate.newComparisonPredicate(longCol, EQUAL, Long.MAX_VALUE));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.POSITIVE_INFINITY),
- KuduPredicate.newComparisonPredicate(floatCol, EQUAL, Float.POSITIVE_INFINITY));
- Assert.assertEquals(KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.POSITIVE_INFINITY),
- KuduPredicate.newComparisonPredicate(doubleCol, EQUAL, Double.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(byteCol, GREATER_EQUAL, Byte.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(byteCol, EQUAL, Byte.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(shortCol, GREATER_EQUAL, Short.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(shortCol, EQUAL, Short.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(intCol, GREATER_EQUAL, Integer.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(intCol, EQUAL, Integer.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(longCol, GREATER_EQUAL, Long.MAX_VALUE),
+ KuduPredicate.newComparisonPredicate(longCol, EQUAL, Long.MAX_VALUE));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(floatCol, GREATER_EQUAL, Float.POSITIVE_INFINITY),
+ KuduPredicate.newComparisonPredicate(floatCol, EQUAL, Float.POSITIVE_INFINITY));
+ Assert.assertEquals(
+ KuduPredicate.newComparisonPredicate(doubleCol, GREATER_EQUAL, Double.POSITIVE_INFINITY),
+ KuduPredicate.newComparisonPredicate(doubleCol, EQUAL, Double.POSITIVE_INFINITY));
}
@Test
@@ -1154,19 +1194,19 @@ public class TestKuduPredicate {
@Test
public void testToString() {
Assert.assertEquals("`bool` = true",
- KuduPredicate.newComparisonPredicate(boolCol, EQUAL, true).toString());
+ KuduPredicate.newComparisonPredicate(boolCol, EQUAL, true).toString());
Assert.assertEquals("`byte` = 11",
- KuduPredicate.newComparisonPredicate(byteCol, EQUAL, 11).toString());
+ KuduPredicate.newComparisonPredicate(byteCol, EQUAL, 11).toString());
Assert.assertEquals("`short` = 11",
- KuduPredicate.newComparisonPredicate(shortCol, EQUAL, 11).toString());
+ KuduPredicate.newComparisonPredicate(shortCol, EQUAL, 11).toString());
Assert.assertEquals("`int` = -123",
- KuduPredicate.newComparisonPredicate(intCol, EQUAL, -123).toString());
+ KuduPredicate.newComparisonPredicate(intCol, EQUAL, -123).toString());
Assert.assertEquals("`long` = 5454",
- KuduPredicate.newComparisonPredicate(longCol, EQUAL, 5454).toString());
+ KuduPredicate.newComparisonPredicate(longCol, EQUAL, 5454).toString());
Assert.assertEquals("`float` = 123.456",
- KuduPredicate.newComparisonPredicate(floatCol, EQUAL, 123.456f).toString());
+ KuduPredicate.newComparisonPredicate(floatCol, EQUAL, 123.456f).toString());
Assert.assertEquals("`double` = 123.456",
- KuduPredicate.newComparisonPredicate(doubleCol, EQUAL, 123.456).toString());
+ KuduPredicate.newComparisonPredicate(doubleCol, EQUAL, 123.456).toString());
Assert.assertEquals("`decimal32` = 123.45",
KuduPredicate.newComparisonPredicate(decimal32Col, EQUAL,
BigDecimal.valueOf(12345, 2)).toString());
@@ -1177,7 +1217,7 @@ public class TestKuduPredicate {
KuduPredicate.newComparisonPredicate(decimal128Col, EQUAL,
new BigDecimal("1234567891011121314.15")).toString());
Assert.assertEquals("`string` = \"my string\"",
- KuduPredicate.newComparisonPredicate(stringCol, EQUAL, "my string").toString());
+ KuduPredicate.newComparisonPredicate(stringCol, EQUAL, "my string").toString());
Assert.assertEquals("`binary` = 0xAB01CD", KuduPredicate.newComparisonPredicate(
binaryCol, EQUAL, new byte[] { (byte) 0xAB, (byte) 0x01, (byte) 0xCD }).toString());
Assert.assertEquals("`int` IN (-10, 0, 10)",
@@ -1187,7 +1227,7 @@ public class TestKuduPredicate {
Assert.assertEquals("`string` IS NULL",
KuduPredicate.newIsNullPredicate(stringCol).toString());
Assert.assertEquals("`varchar` = \"my varchar\"",
- KuduPredicate.newComparisonPredicate(varcharCol, EQUAL, "my varchar").toString());
+ KuduPredicate.newComparisonPredicate(varcharCol, EQUAL, "my varchar").toString());
Assert.assertEquals("`varchar` IS NOT NULL",
KuduPredicate.newIsNotNullPredicate(varcharCol).toString());
Assert.assertEquals("`varchar` IS NULL",
@@ -1215,7 +1255,7 @@ public class TestKuduPredicate {
Assert.assertEquals("`double` IN (78.9, 123.456)", KuduPredicate.newInListPredicate(
doubleCol, ImmutableList.of(123.456d, 78.9d)).toString());
Assert.assertEquals("`string` IN (\"a\", \"my string\")",
- KuduPredicate.newInListPredicate(stringCol, ImmutableList.of("my string", "a")).toString());
+ KuduPredicate.newInListPredicate(stringCol, ImmutableList.of("my string", "a")).toString());
Assert.assertEquals("`binary` IN (0x00, 0xAB01CD)", KuduPredicate.newInListPredicate(
binaryCol, ImmutableList.of(new byte[] { (byte) 0xAB, (byte) 0x01, (byte) 0xCD },
new byte[] { (byte) 0x00 })).toString());
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduScanner.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduScanner.java
index 155e226..01246b0 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduScanner.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduScanner.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.client.AsyncKuduScanner.DEFAULT_IS_DELETED_COL_NAME;
@@ -181,8 +182,8 @@ public class TestKuduScanner {
@Test(timeout = 100000)
public void testOpenScanWithDroppedPartition() throws Exception {
// Create a table with 2 range partitions.
- Schema basicSchema = getBasicSchema();
- String tableName = "testOpenScanWithDroppedPartition";
+ final Schema basicSchema = getBasicSchema();
+ final String tableName = "testOpenScanWithDroppedPartition";
PartialRow bottom = basicSchema.newPartialRow();
bottom.addInt("key", 0);
PartialRow middle = basicSchema.newPartialRow();
@@ -258,13 +259,14 @@ public class TestKuduScanner {
long startHT = client.getLastPropagatedTimestamp() + 1;
LOG.info("startHT: {}", startHT);
- // Generate row mutations. The mutations performed here are what should be seen by the diff scan.
+ // Generate row mutations.
+ // The mutations performed here are what should be seen by the diff scan.
int mutationBounds = 10;
int expectedNumInserts = random.nextInt(mutationBounds);
int expectedNumUpdates = random.nextInt(mutationBounds);
int expectedNumDeletes = random.nextInt(mutationBounds);
- List<Operation> operations =
- generateMutationOperations(table, expectedNumInserts, expectedNumUpdates, expectedNumDeletes);
+ List<Operation> operations = generateMutationOperations(table, expectedNumInserts,
+ expectedNumUpdates, expectedNumDeletes);
Map<Integer, ChangeType> mutations = applyOperations(operations);
LOG.info("Mutations: {}", mutations);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
index af3b5ed..c5a651b 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduSession.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
@@ -250,8 +251,9 @@ public class TestKuduSession {
@Test(timeout = 10000)
public void testOverWritingValues() throws Exception {
- KuduTable table = client.createTable(tableName, basicSchema, getBasicCreateTableOptions());
- KuduSession session = client.newSession();
+ final KuduTable table =
+ client.createTable(tableName, basicSchema, getBasicCreateTableOptions());
+ final KuduSession session = client.newSession();
Insert insert = createInsert(table, 0);
PartialRow row = insert.getRow();
@@ -372,7 +374,7 @@ public class TestKuduSession {
assertTrue(result.hasRowError());
assertTrue(result.getRowError().getErrorStatus().isNotFound());
} else {
- assertTrue(!result.hasRowError());
+ assertFalse(result.hasRowError());
}
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
index 643c55b..3303d11 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduTable.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createBasicSchemaInsert;
@@ -80,7 +81,8 @@ public class TestKuduTable {
.encoding(ColumnSchema.Encoding.PLAIN_ENCODING)
.compressionAlgorithm(ColumnSchema.CompressionAlgorithm.NO_COMPRESSION)
.build());
- KuduTable table = client.createTable(tableName, new Schema(columns), getBasicCreateTableOptions());
+ KuduTable table =
+ client.createTable(tableName, new Schema(columns), getBasicCreateTableOptions());
KuduSession session = client.newSession();
// Insert a row before a default is defined and check the value is NULL.
insertDefaultRow(table, session, 0);
@@ -174,7 +176,7 @@ public class TestKuduTable {
// Delete it.
client.alterTable(tableName, new AlterTableOptions().dropColumn("newtestaddint"));
- String newTableName = tableName +"new";
+ String newTableName = tableName + "new";
// Rename our table.
client.alterTable(tableName, new AlterTableOptions().renameTable(newTableName));
@@ -214,12 +216,13 @@ public class TestKuduTable {
}
/**
- * Test creating tables of different sizes and see that we get the correct number of tablets back
- * @throws Exception
+ * Test creating tables of different sizes and see that we get the correct number of tablets back.
*/
@Test
+ @SuppressWarnings("deprecation")
public void testGetLocations() throws Exception {
- int initialTableCount = asyncClient.getTablesList().join(DEFAULT_SLEEP).getTablesList().size();
+ final int initialTableCount =
+ asyncClient.getTablesList().join(DEFAULT_SLEEP).getTablesList().size();
final String NON_EXISTENT_TABLE = "NON_EXISTENT_TABLE";
@@ -233,7 +236,7 @@ public class TestKuduTable {
// Test with defaults
String tableWithDefault = tableName + "-WithDefault";
CreateTableOptions builder = getBasicCreateTableOptions();
- List<ColumnSchema> columns = new ArrayList<ColumnSchema>(BASIC_SCHEMA.getColumnCount());
+ List<ColumnSchema> columns = new ArrayList<>(BASIC_SCHEMA.getColumnCount());
int defaultInt = 30;
String defaultString = "data";
for (ColumnSchema columnSchema : BASIC_SCHEMA.getColumns()) {
@@ -277,37 +280,52 @@ public class TestKuduTable {
KuduTable table = createTableWithSplitsAndTest(splitTablePrefix, 30);
- List<LocatedTablet>tablets = table.getTabletsLocations(null, getKeyInBytes(9), DEFAULT_SLEEP);
+ List<LocatedTablet> tablets =
+ table.getTabletsLocations(null, getKeyInBytes(9), DEFAULT_SLEEP);
assertEquals(9, tablets.size());
- assertEquals(9, table.asyncGetTabletsLocations(null, getKeyInBytes(9), DEFAULT_SLEEP).join().size());
+ assertEquals(9,
+ table.asyncGetTabletsLocations(null, getKeyInBytes(9), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(0), getKeyInBytes(9), DEFAULT_SLEEP);
assertEquals(9, tablets.size());
- assertEquals(9, table.asyncGetTabletsLocations(getKeyInBytes(0), getKeyInBytes(9), DEFAULT_SLEEP).join().size());
+ assertEquals(9,
+ table.asyncGetTabletsLocations(getKeyInBytes(0),
+ getKeyInBytes(9), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(5), getKeyInBytes(9), DEFAULT_SLEEP);
assertEquals(4, tablets.size());
- assertEquals(4, table.asyncGetTabletsLocations(getKeyInBytes(5), getKeyInBytes(9), DEFAULT_SLEEP).join().size());
+ assertEquals(4,
+ table.asyncGetTabletsLocations(getKeyInBytes(5),
+ getKeyInBytes(9), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(5), getKeyInBytes(14), DEFAULT_SLEEP);
assertEquals(9, tablets.size());
- assertEquals(9, table.asyncGetTabletsLocations(getKeyInBytes(5), getKeyInBytes(14), DEFAULT_SLEEP).join().size());
+ assertEquals(9,
+ table.asyncGetTabletsLocations(getKeyInBytes(5),
+ getKeyInBytes(14), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(5), getKeyInBytes(31), DEFAULT_SLEEP);
assertEquals(26, tablets.size());
- assertEquals(26, table.asyncGetTabletsLocations(getKeyInBytes(5), getKeyInBytes(31), DEFAULT_SLEEP).join().size());
+ assertEquals(26,
+ table.asyncGetTabletsLocations(getKeyInBytes(5),
+ getKeyInBytes(31), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(5), null, DEFAULT_SLEEP);
assertEquals(26, tablets.size());
- assertEquals(26, table.asyncGetTabletsLocations(getKeyInBytes(5), null, DEFAULT_SLEEP).join().size());
+ assertEquals(26,
+ table.asyncGetTabletsLocations(getKeyInBytes(5), null, DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(null, getKeyInBytes(10000), DEFAULT_SLEEP);
assertEquals(31, tablets.size());
- assertEquals(31, table.asyncGetTabletsLocations(null, getKeyInBytes(10000), DEFAULT_SLEEP).join().size());
+ assertEquals(31,
+ table.asyncGetTabletsLocations(null,
+ getKeyInBytes(10000), DEFAULT_SLEEP).join().size());
tablets = table.getTabletsLocations(getKeyInBytes(20), getKeyInBytes(10000), DEFAULT_SLEEP);
assertEquals(11, tablets.size());
- assertEquals(11, table.asyncGetTabletsLocations(getKeyInBytes(20), getKeyInBytes(10000), DEFAULT_SLEEP).join().size());
+ assertEquals(11,
+ table.asyncGetTabletsLocations(getKeyInBytes(20),
+ getKeyInBytes(10000), DEFAULT_SLEEP).join().size());
// Test listing tables.
assertEquals(0, asyncClient.getTablesList(NON_EXISTENT_TABLE)
@@ -316,14 +334,15 @@ public class TestKuduTable {
.join(DEFAULT_SLEEP).getTablesList().size());
assertEquals(initialTableCount + 5,
asyncClient.getTablesList().join(DEFAULT_SLEEP).getTablesList().size());
- assertFalse(asyncClient.getTablesList(tableWithDefault).
- join(DEFAULT_SLEEP).getTablesList().isEmpty());
+ assertFalse(asyncClient.getTablesList(tableWithDefault)
+ .join(DEFAULT_SLEEP).getTablesList().isEmpty());
assertFalse(asyncClient.tableExists(NON_EXISTENT_TABLE).join(DEFAULT_SLEEP));
assertTrue(asyncClient.tableExists(tableWithDefault).join(DEFAULT_SLEEP));
}
@Test(timeout = 100000)
+ @SuppressWarnings("deprecation")
public void testLocateTableNonCoveringRange() throws Exception {
client.createTable(tableName, basicSchema, getBasicTableOptionsWithNonCoveredRange());
KuduTable table = client.openTable(tableName);
@@ -370,17 +389,18 @@ public class TestKuduTable {
}
@Test(timeout = 100000)
+ @SuppressWarnings("deprecation")
public void testAlterTableNonCoveringRange() throws Exception {
client.createTable(tableName, basicSchema, getBasicTableOptionsWithNonCoveredRange());
- KuduTable table = client.openTable(tableName);
- KuduSession session = client.newSession();
+ final KuduTable table = client.openTable(tableName);
+ final KuduSession session = client.newSession();
AlterTableOptions ato = new AlterTableOptions();
- PartialRow bLowerBound = BASIC_SCHEMA.newPartialRow();
- bLowerBound.addInt("key", 300);
- PartialRow bUpperBound = BASIC_SCHEMA.newPartialRow();
- bUpperBound.addInt("key", 400);
- ato.addRangePartition(bLowerBound, bUpperBound);
+ PartialRow lowerBound = BASIC_SCHEMA.newPartialRow();
+ lowerBound.addInt("key", 300);
+ PartialRow upperBound = BASIC_SCHEMA.newPartialRow();
+ upperBound.addInt("key", 400);
+ ato.addRangePartition(lowerBound, upperBound);
client.alterTable(tableName, ato);
Insert insert = createBasicSchemaInsert(table, 301);
@@ -398,11 +418,11 @@ public class TestKuduTable {
session.apply(insert);
ato = new AlterTableOptions();
- bLowerBound = BASIC_SCHEMA.newPartialRow();
- bLowerBound.addInt("key", 200);
- bUpperBound = BASIC_SCHEMA.newPartialRow();
- bUpperBound.addInt("key", 300);
- ato.dropRangePartition(bLowerBound, bUpperBound);
+ lowerBound = BASIC_SCHEMA.newPartialRow();
+ lowerBound.addInt("key", 200);
+ upperBound = BASIC_SCHEMA.newPartialRow();
+ upperBound.addInt("key", 300);
+ ato.dropRangePartition(lowerBound, upperBound);
client.alterTable(tableName, ato);
insert = createBasicSchemaInsert(table, 202);
@@ -567,6 +587,7 @@ public class TestKuduTable {
client.openTable(tableName).getFormattedRangePartitions(10000));
}
+ @SuppressWarnings("deprecation")
private KuduTable createTableWithSplitsAndTest(String tableNamePrefix, int splitsCount)
throws Exception {
String newTableName = tableNamePrefix + "-" + splitsCount;
@@ -672,7 +693,9 @@ public class TestKuduTable {
try {
table.getSchema().getColumn(newName);
fail(String.format("New column name %s should not yet be visible", newName));
- } catch (IllegalArgumentException e) {}
+ } catch (IllegalArgumentException e) {
+ // ignored
+ }
// After waiting for the alter to finish and reloading the schema,
// 'newName' should be visible and 'oldName' should be gone.
@@ -681,7 +704,9 @@ public class TestKuduTable {
try {
table.getSchema().getColumn(oldName);
fail(String.format("Old column name %s should not be visible", oldName));
- } catch (IllegalArgumentException e) {}
+ } catch (IllegalArgumentException e) {
+ // ignored
+ }
table.getSchema().getColumn(newName);
LOG.info("Test passed on attempt {}", i + 1);
return;
@@ -750,18 +775,19 @@ public class TestKuduTable {
}
@Test(timeout = 100000)
+ @SuppressWarnings("deprecation")
public void testDimensionLabel() throws Exception {
// Create a table with dimension label.
- KuduTable table = client.createTable(tableName, basicSchema,
+ final KuduTable table = client.createTable(tableName, basicSchema,
getBasicTableOptionsWithNonCoveredRange().setDimensionLabel("labelA"));
// Add a range partition to the table with dimension label.
AlterTableOptions ato = new AlterTableOptions();
- PartialRow bLowerBound = BASIC_SCHEMA.newPartialRow();
- bLowerBound.addInt("key", 300);
- PartialRow bUpperBound = BASIC_SCHEMA.newPartialRow();
- bUpperBound.addInt("key", 400);
- ato.addRangePartition(bLowerBound, bUpperBound, "labelB",
+ PartialRow lowerBound = BASIC_SCHEMA.newPartialRow();
+ lowerBound.addInt("key", 300);
+ PartialRow upperBound = BASIC_SCHEMA.newPartialRow();
+ upperBound.addInt("key", 400);
+ ato.addRangePartition(lowerBound, upperBound, "labelB",
RangePartitionBound.INCLUSIVE_BOUND,
RangePartitionBound.EXCLUSIVE_BOUND);
client.alterTable(tableName, ato);
@@ -815,6 +841,6 @@ public class TestKuduTable {
currentStatistics = table.getTableStatistics();
assertTrue(currentStatistics.getOnDiskSize() >= prevStatistics.getOnDiskSize());
assertTrue(currentStatistics.getLiveRowCount() >= prevStatistics.getLiveRowCount());
- assertTrue(currentStatistics.getLiveRowCount() == num);
+ assertEquals(num, currentStatistics.getLiveRowCount());
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java
index ecd33c0..656a660 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestLeaderFailover.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java
index d0dcebf..2702e50 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMasterFailover.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
@@ -44,14 +45,17 @@ public class TestMasterFailover {
public void testKillLeaderBeforeCreateClient() throws Exception {
doTestKillLeader(KillBefore.CREATE_CLIENT);
}
+
@Test(timeout = 30000)
public void testKillLeaderBeforeCreateTable() throws Exception {
doTestKillLeader(KillBefore.CREATE_TABLE);
}
+
@Test(timeout = 30000)
public void testKillLeaderBeforeOpenTable() throws Exception {
doTestKillLeader(KillBefore.OPEN_TABLE);
}
+
@Test(timeout = 30000)
public void testKillLeaderBeforeScanTable() throws Exception {
doTestKillLeader(KillBefore.SCAN_TABLE);
@@ -61,8 +65,8 @@ public class TestMasterFailover {
String tableName = "TestMasterFailover-killBefore=" + killBefore;
int countMasters = harness.getMasterServers().size();
if (countMasters < 3) {
- throw new Exception("This test requires at least 3 master servers, but only "
- + countMasters + " are specified.");
+ throw new Exception("This test requires at least 3 master servers, but only " +
+ countMasters + " are specified.");
}
if (killBefore == KillBefore.CREATE_CLIENT) {
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMultipleLeaderFailover.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMultipleLeaderFailover.java
index 52edd32..e2daeef 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestMultipleLeaderFailover.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestMultipleLeaderFailover.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.countRowsInScan;
@@ -45,8 +46,8 @@ public class TestMultipleLeaderFailover {
@Override
public boolean get() throws Exception {
AsyncKuduScanner scanner = harness.getAsyncClient().newScannerBuilder(table).build();
- int read_count = countRowsInScan(scanner);
- return read_count == rowCount;
+ int readCount = countRowsInScan(scanner);
+ return readCount == rowCount;
}
}, timeoutMs);
}
@@ -57,6 +58,7 @@ public class TestMultipleLeaderFailover {
* Finally it counts to make sure we have total_rows_to_insert of them.
*/
@Test(timeout = 100000)
+ @SuppressWarnings("deprecation")
public void testMultipleFailover() throws Exception {
KuduTable table;
CreateTableOptions builder = getBasicCreateTableOptions();
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
index 89ff3da..54c9d9a 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiation.java
@@ -56,8 +56,8 @@ public class TestNegotiation {
try (MiniKuduCluster cluster = clusterBuilder.build()) {
cluster.kdestroy();
try (Closeable c = cla.attach();
- KuduClient client = new KuduClient.KuduClientBuilder(cluster.getMasterAddressesAsString())
- .build()
+ KuduClient client =
+ new KuduClient.KuduClientBuilder(cluster.getMasterAddressesAsString()).build()
) {
assertTrue(client.getTablesList().getTablesList().isEmpty());
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiator.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiator.java
index 1b48d3a..32ddade 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiator.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestNegotiator.java
@@ -107,7 +107,7 @@ public class TestNegotiator {
private void startNegotiation(boolean fakeLoopback) {
Negotiator negotiator = new Negotiator("127.0.0.1", secContext, false);
negotiator.overrideLoopbackForTests = fakeLoopback;
- embedder = new DecoderEmbedder<Object>(negotiator);
+ embedder = new DecoderEmbedder<>(negotiator);
negotiator.sendHello(embedder.getPipeline().getChannel());
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
index ec8599e..b64fbb0 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestOperation.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -44,7 +45,7 @@ public class TestOperation {
public RetryRule retryRule = new RetryRule();
private Schema createManyStringsSchema() {
- ArrayList<ColumnSchema> columns = new ArrayList<ColumnSchema>(4);
+ ArrayList<ColumnSchema> columns = new ArrayList<>(4);
columns.add(new ColumnSchema.ColumnSchemaBuilder("c0", Type.STRING).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c1", Type.STRING).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c2", Type.STRING).build());
@@ -67,7 +68,7 @@ public class TestOperation {
{
WriteRequestPBOrBuilder pb =
- Operation.createAndFillWriteRequestPB(ImmutableList.<Operation>of(insert));
+ Operation.createAndFillWriteRequestPB(ImmutableList.of(insert));
RowOperationsPB rowOps = pb.getRowOperations();
assertEquals(6 * 5, rowOps.getIndirectData().size());
assertEquals("c0_valc1_valc2_valc3_valc4_val", rowOps.getIndirectData().toStringUtf8());
@@ -98,7 +99,7 @@ public class TestOperation {
row.setNull("c3");
{
WriteRequestPBOrBuilder pb =
- Operation.createAndFillWriteRequestPB(ImmutableList.<Operation>of(insert));
+ Operation.createAndFillWriteRequestPB(ImmutableList.of(insert));
RowOperationsPB rowOps = pb.getRowOperations();
assertEquals(6 * 4, rowOps.getIndirectData().size());
assertEquals("c0_valc1_valc2_valc4_val", rowOps.getIndirectData().toStringUtf8());
@@ -113,7 +114,9 @@ public class TestOperation {
int offset = 3;
int indirOffset = 0;
for (int i = 0; i <= 4; i++) {
- if (i == 3) continue;
+ if (i == 3) {
+ continue;
+ }
// The offset into the indirect buffer
assertEquals(indirOffset, Bytes.getLong(rows, offset));
indirOffset += 6;
@@ -128,7 +131,7 @@ public class TestOperation {
}
private Schema createAllTypesKeySchema() {
- ArrayList<ColumnSchema> columns = new ArrayList<ColumnSchema>(7);
+ ArrayList<ColumnSchema> columns = new ArrayList<>(7);
columns.add(new ColumnSchema.ColumnSchemaBuilder("c0", Type.INT8).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c1", Type.INT16).key(true).build());
columns.add(new ColumnSchema.ColumnSchemaBuilder("c2", Type.INT32).key(true).build());
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
index 215236b..a7c5d53 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartialRow.java
@@ -55,13 +55,18 @@ public class TestPartialRow {
assertEquals(52.35F, partialRow.getFloat("float"), 0.0f);
assertEquals(53.35, partialRow.getDouble("double"), 0.0);
assertEquals("fun with ütf\0", partialRow.getString("string"));
- assertArrayEquals(new byte[] { 0, 1, 2, 3, 4 }, partialRow.getBinaryCopy("binary-array"));
- assertArrayEquals(new byte[] { 5, 6, 7, 8, 9 }, partialRow.getBinaryCopy("binary-bytebuffer"));
- assertEquals(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3, 4 }), partialRow.getBinary("binary-array"));
- assertEquals(ByteBuffer.wrap(new byte[] { 5, 6, 7, 8, 9 }), partialRow.getBinary("binary-bytebuffer"));
+ assertArrayEquals(new byte[] { 0, 1, 2, 3, 4 },
+ partialRow.getBinaryCopy("binary-array"));
+ assertArrayEquals(new byte[] { 5, 6, 7, 8, 9 },
+ partialRow.getBinaryCopy("binary-bytebuffer"));
+ assertEquals(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3, 4 }),
+ partialRow.getBinary("binary-array"));
+ assertEquals(ByteBuffer.wrap(new byte[] { 5, 6, 7, 8, 9 }),
+ partialRow.getBinary("binary-bytebuffer"));
assertTrue(partialRow.isSet("null"));
assertTrue(partialRow.isNull("null"));
- assertEquals(BigDecimal.valueOf(12345, 3), partialRow.getDecimal("decimal"));
+ assertEquals(BigDecimal.valueOf(12345, 3),
+ partialRow.getDecimal("decimal"));
}
@Test
@@ -88,12 +93,15 @@ public class TestPartialRow {
assertTrue(partialRow.getObject("varchar") instanceof String);
assertEquals("árvíztűrő ", partialRow.getObject("varchar"));
assertTrue(partialRow.getObject("binary-array") instanceof byte[]);
- assertArrayEquals(new byte[] { 0, 1, 2, 3, 4 }, partialRow.getBinaryCopy("binary-array"));
+ assertArrayEquals(new byte[] { 0, 1, 2, 3, 4 },
+ partialRow.getBinaryCopy("binary-array"));
assertTrue(partialRow.getObject("binary-bytebuffer") instanceof byte[]);
- assertEquals(ByteBuffer.wrap(new byte[] { 5, 6, 7, 8, 9 }), partialRow.getBinary("binary-bytebuffer"));
+ assertEquals(ByteBuffer.wrap(new byte[] { 5, 6, 7, 8, 9 }),
+ partialRow.getBinary("binary-bytebuffer"));
assertNull(partialRow.getObject("null"));
assertTrue(partialRow.getObject("decimal") instanceof BigDecimal);
- assertEquals(BigDecimal.valueOf(12345, 3), partialRow.getObject("decimal"));
+ assertEquals(BigDecimal.valueOf(12345, 3),
+ partialRow.getObject("decimal"));
}
@Test
@@ -342,7 +350,8 @@ public class TestPartialRow {
assertEquals("(int8 int8=42, int32 int32=42, double double=52.35, " +
"string string=\"fun with ütf\\0\", binary binary-bytebuffer=[2, 3, 4], " +
"decimal(5, 3) decimal=12.345, varchar(10) varchar=\"árvíztűrő \")",
- row.toString());
+
+ row.toString());
}
@Test
@@ -502,18 +511,42 @@ public class TestPartialRow {
private void callAddByName(PartialRow partialRow, String columnName, Type type) {
switch (type) {
- case INT8: partialRow.addByte(columnName, (byte) 42); break;
- case INT16: partialRow.addShort(columnName, (short) 43); break;
- case INT32: partialRow.addInt(columnName, 44); break;
- case INT64: partialRow.addLong(columnName, 45); break;
- case UNIXTIME_MICROS: partialRow.addTimestamp(columnName, new Timestamp(1234567890)); break;
- case VARCHAR: partialRow.addVarchar(columnName, "fun with ütf\0"); break;
- case STRING: partialRow.addString(columnName, "fun with ütf\0"); break;
- case BINARY: partialRow.addBinary(columnName, new byte[] { 0, 1, 2, 3, 4 }); break;
- case FLOAT: partialRow.addFloat(columnName, 52.35F); break;
- case DOUBLE: partialRow.addDouble(columnName, 53.35); break;
- case BOOL: partialRow.addBoolean(columnName, true); break;
- case DECIMAL: partialRow.addDecimal(columnName, BigDecimal.valueOf(12345, 3)); break;
+ case INT8:
+ partialRow.addByte(columnName, (byte) 42);
+ break;
+ case INT16:
+ partialRow.addShort(columnName, (short) 43);
+ break;
+ case INT32:
+ partialRow.addInt(columnName, 44);
+ break;
+ case INT64:
+ partialRow.addLong(columnName, 45);
+ break;
+ case UNIXTIME_MICROS:
+ partialRow.addTimestamp(columnName, new Timestamp(1234567890));
+ break;
+ case VARCHAR:
+ partialRow.addVarchar(columnName, "fun with ütf\0");
+ break;
+ case STRING:
+ partialRow.addString(columnName, "fun with ütf\0");
+ break;
+ case BINARY:
+ partialRow.addBinary(columnName, new byte[] { 0, 1, 2, 3, 4 });
+ break;
+ case FLOAT:
+ partialRow.addFloat(columnName, 52.35F);
+ break;
+ case DOUBLE:
+ partialRow.addDouble(columnName, 53.35);
+ break;
+ case BOOL:
+ partialRow.addBoolean(columnName, true);
+ break;
+ case DECIMAL:
+ partialRow.addDecimal(columnName, BigDecimal.valueOf(12345, 3));
+ break;
default:
throw new UnsupportedOperationException();
}
@@ -521,18 +554,42 @@ public class TestPartialRow {
private void callAddByIndex(PartialRow partialRow, int columnIndex, Type type) {
switch (type) {
- case INT8: partialRow.addByte(columnIndex, (byte) 42); break;
- case INT16: partialRow.addShort(columnIndex, (short) 43); break;
- case INT32: partialRow.addInt(columnIndex, 44); break;
- case INT64: partialRow.addLong(columnIndex, 45); break;
- case UNIXTIME_MICROS: partialRow.addTimestamp(columnIndex, new Timestamp(1234567890)); break;
- case VARCHAR: partialRow.addVarchar(columnIndex, "fun with ütf\0"); break;
- case STRING: partialRow.addString(columnIndex, "fun with ütf\0"); break;
- case BINARY: partialRow.addBinary(columnIndex, new byte[] { 0, 1, 2, 3, 4 }); break;
- case FLOAT: partialRow.addFloat(columnIndex, 52.35F); break;
- case DOUBLE: partialRow.addDouble(columnIndex, 53.35); break;
- case BOOL: partialRow.addBoolean(columnIndex, true); break;
- case DECIMAL: partialRow.addDecimal(columnIndex, BigDecimal.valueOf(12345, 3)); break;
+ case INT8:
+ partialRow.addByte(columnIndex, (byte) 42);
+ break;
+ case INT16:
+ partialRow.addShort(columnIndex, (short) 43);
+ break;
+ case INT32:
+ partialRow.addInt(columnIndex, 44);
+ break;
+ case INT64:
+ partialRow.addLong(columnIndex, 45);
+ break;
+ case UNIXTIME_MICROS:
+ partialRow.addTimestamp(columnIndex, new Timestamp(1234567890));
+ break;
+ case VARCHAR:
+ partialRow.addVarchar(columnIndex, "fun with ütf\0");
+ break;
+ case STRING:
+ partialRow.addString(columnIndex, "fun with ütf\0");
+ break;
+ case BINARY:
+ partialRow.addBinary(columnIndex, new byte[] { 0, 1, 2, 3, 4 });
+ break;
+ case FLOAT:
+ partialRow.addFloat(columnIndex, 52.35F);
+ break;
+ case DOUBLE:
+ partialRow.addDouble(columnIndex, 53.35);
+ break;
+ case BOOL:
+ partialRow.addBoolean(columnIndex, true);
+ break;
+ case DECIMAL:
+ partialRow.addDecimal(columnIndex, BigDecimal.valueOf(12345, 3));
+ break;
default:
throw new UnsupportedOperationException();
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
index fc8a68c..4bc01b2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestPartitionPruner.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -81,7 +82,9 @@ public class TestPartitionPruner {
int scannedPartitions = 0;
for (Partition partition : partitions) {
- if (!pruner.shouldPruneForTests(partition)) scannedPartitions++;
+ if (!pruner.shouldPruneForTests(partition)) {
+ scannedPartitions++;
+ }
}
// Check that the number of ScanTokens built for the scan matches.
@@ -150,7 +153,9 @@ public class TestPartitionPruner {
int scannedPartitions = 0;
for (Partition partition : partitions) {
- if (!pruner.shouldPruneForTests(partition)) scannedPartitions++;
+ if (!pruner.shouldPruneForTests(partition)) {
+ scannedPartitions++;
+ }
}
assertEquals(expectedTablets, scannedPartitions);
@@ -306,8 +311,8 @@ public class TestPartitionPruner {
KuduTable table = client.openTable(tableName);
List<Partition> partitions = getTablePartitions(table);
- byte min = Byte.MIN_VALUE;
- byte max = Byte.MAX_VALUE;
+ final byte min = Byte.MIN_VALUE;
+ final byte max = Byte.MAX_VALUE;
// No bounds
checkPartitionsPrimaryKey(2, table, partitions,
@@ -437,10 +442,10 @@ public class TestPartitionPruner {
// c >= MIN
checkPartitions(3, 1, table, partitions,
- KuduPredicate.newComparisonPredicate(c, ComparisonOp.GREATER_EQUAL, Byte.MIN_VALUE));
+ KuduPredicate.newComparisonPredicate(c, ComparisonOp.GREATER_EQUAL, Byte.MIN_VALUE));
// c >= MAX
checkPartitions(1, 1, table, partitions,
- KuduPredicate.newComparisonPredicate(c, ComparisonOp.GREATER_EQUAL, Byte.MAX_VALUE));
+ KuduPredicate.newComparisonPredicate(c, ComparisonOp.GREATER_EQUAL, Byte.MAX_VALUE));
// c >= -10
// c < 0
@@ -539,7 +544,7 @@ public class TestPartitionPruner {
// c IN (0, 1, 2)
checkPartitions(2, 1, table, partitions,
- KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1, (byte) 2)));
+ KuduPredicate.newInListPredicate(c, ImmutableList.of((byte) 0, (byte) 1, (byte) 2)));
// c IN (-10, 0)
// b < "m"
@@ -565,10 +570,10 @@ public class TestPartitionPruner {
ColumnSchema a = new ColumnSchema.ColumnSchemaBuilder("a", Type.INT8).key(true).build();
ColumnSchema b = new ColumnSchema.ColumnSchemaBuilder("b", Type.INT8).key(true).build();
ColumnSchema c = new ColumnSchema.ColumnSchemaBuilder("c", Type.INT8).key(true).build();
- Schema schema = new Schema(ImmutableList.of(a, b, c));
+ final Schema schema = new Schema(ImmutableList.of(a, b, c));
CreateTableOptions tableBuilder = new CreateTableOptions();
- tableBuilder.setRangePartitionColumns(new ArrayList<String>());
+ tableBuilder.setRangePartitionColumns(new ArrayList<>());
tableBuilder.addHashPartitions(ImmutableList.of("a"), 2);
tableBuilder.addHashPartitions(ImmutableList.of("b", "c"), 2);
@@ -634,10 +639,10 @@ public class TestPartitionPruner {
ColumnSchema a = new ColumnSchema.ColumnSchemaBuilder("a", Type.INT8).key(true).build();
ColumnSchema b = new ColumnSchema.ColumnSchemaBuilder("b", Type.INT8).key(true).build();
ColumnSchema c = new ColumnSchema.ColumnSchemaBuilder("c", Type.INT8).key(true).build();
- Schema schema = new Schema(ImmutableList.of(a, b, c));
+ final Schema schema = new Schema(ImmutableList.of(a, b, c));
CreateTableOptions tableBuilder = new CreateTableOptions();
- tableBuilder.setRangePartitionColumns(new ArrayList<String>());
+ tableBuilder.setRangePartitionColumns(new ArrayList<>());
tableBuilder.addHashPartitions(ImmutableList.of("a"), 3);
tableBuilder.addHashPartitions(ImmutableList.of("b"), 3);
tableBuilder.addHashPartitions(ImmutableList.of("c"), 3);
@@ -685,10 +690,10 @@ public class TestPartitionPruner {
ColumnSchema a = new ColumnSchema.ColumnSchemaBuilder("a", Type.INT8).key(true).build();
ColumnSchema b = new ColumnSchema.ColumnSchemaBuilder("b", Type.INT8).key(true).build();
ColumnSchema c = new ColumnSchema.ColumnSchemaBuilder("c", Type.INT8).key(true).build();
- Schema schema = new Schema(ImmutableList.of(a, b, c));
+ final Schema schema = new Schema(ImmutableList.of(a, b, c));
CreateTableOptions tableBuilder = new CreateTableOptions();
- tableBuilder.setRangePartitionColumns(new ArrayList<String>());
+ tableBuilder.setRangePartitionColumns(new ArrayList<>());
tableBuilder.addHashPartitions(ImmutableList.of("a"), 3);
tableBuilder.addHashPartitions(ImmutableList.of("b", "c"), 3);
@@ -703,7 +708,7 @@ public class TestPartitionPruner {
// a in [0, 1, 8];
checkPartitions(9, 1, table, partitions,
- KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1, (byte) 8)));
+ KuduPredicate.newInListPredicate(a, ImmutableList.of((byte) 0, (byte) 1, (byte) 8)));
// b in [0, 1];
checkPartitions(9, 1, table, partitions,
@@ -750,9 +755,13 @@ public class TestPartitionPruner {
// PARTITION VALUES >= 10);
// HASH (host, metric) 2 PARTITIONS;
- ColumnSchema host = new ColumnSchema.ColumnSchemaBuilder("host", Type.STRING).key(true).build();
- ColumnSchema metric = new ColumnSchema.ColumnSchemaBuilder("metric", Type.STRING).key(true).build();
- ColumnSchema timestamp = new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.UNIXTIME_MICROS).key(true).build();
+ ColumnSchema host =
+ new ColumnSchema.ColumnSchemaBuilder("host", Type.STRING).key(true).build();
+ ColumnSchema metric =
+ new ColumnSchema.ColumnSchemaBuilder("metric", Type.STRING).key(true).build();
+ ColumnSchema timestamp =
+ new ColumnSchema.ColumnSchemaBuilder("timestamp", Type.UNIXTIME_MICROS)
+ .key(true).build();
ColumnSchema value = new ColumnSchema.ColumnSchemaBuilder("value", Type.DOUBLE).build();
Schema schema = new Schema(ImmutableList.of(host, metric, timestamp, value));
@@ -813,9 +822,9 @@ public class TestPartitionPruner {
// metric = "a"
// timestamp >= 10;
checkPartitions(1, 1, table, partitions,
- KuduPredicate.newComparisonPredicate(host, ComparisonOp.EQUAL, "a"),
- KuduPredicate.newComparisonPredicate(metric, ComparisonOp.EQUAL, "a"),
- KuduPredicate.newComparisonPredicate(timestamp, ComparisonOp.GREATER_EQUAL, 10));
+ KuduPredicate.newComparisonPredicate(host, ComparisonOp.EQUAL, "a"),
+ KuduPredicate.newComparisonPredicate(metric, ComparisonOp.EQUAL, "a"),
+ KuduPredicate.newComparisonPredicate(timestamp, ComparisonOp.GREATER_EQUAL, 10));
// host = "a"
// metric = "a"
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRemoteTablet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRemoteTablet.java
index c241d1d..25b097c 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRemoteTablet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRemoteTablet.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRequestTracker.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRequestTracker.java
index 1989b24..234bf07 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRequestTracker.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRequestTracker.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -89,6 +90,7 @@ public class TestRequestTracker {
private static class Checker {
long curIncomplete = 0;
+
public synchronized void check(long seqNo, long firstIncomplete) {
Assert.assertTrue("should not send a seq number that was previously marked complete",
seqNo >= curIncomplete);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowErrors.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowErrors.java
index 940ccbb..5f122a2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowErrors.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowErrors.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createBasicSchemaInsert;
@@ -86,7 +87,7 @@ public class TestRowErrors {
KuduSession session = harness.getClient().newSession();
session.setFlushMode(KuduSession.FlushMode.AUTO_FLUSH_BACKGROUND);
- int dupRows = 3;
+ final int dupRows = 3;
session.apply(createInsert(12));
session.apply(createInsert(22));
session.apply(createInsert(32));
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
index c5c3d99..05a5106 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -63,7 +64,7 @@ public class TestRowResult {
row.addByte(0, (byte) 1);
row.addShort(1, (short) 2);
row.addInt(2, 3);
- row.addLong(3, 4l);
+ row.addLong(3, 4L);
row.addBoolean(4, true);
row.addFloat(5, 5.6f);
row.addDouble(6, 7.8);
@@ -109,15 +110,18 @@ public class TestRowResult {
assertEquals(5.6f, rr.getFloat(5), .001f);
assertEquals(5.6f, (float) rr.getObject(5), .001f);
- assertEquals(5.6f, rr.getFloat(allTypesSchema.getColumnByIndex(5).getName()), .001f);
+ assertEquals(5.6f,
+ rr.getFloat(allTypesSchema.getColumnByIndex(5).getName()), .001f);
assertEquals(7.8, rr.getDouble(6), .001);
assertEquals(7.8, (double) rr.getObject(6), .001);
- assertEquals(7.8, rr.getDouble(allTypesSchema.getColumnByIndex(6).getName()), .001f);
+ assertEquals(7.8,
+ rr.getDouble(allTypesSchema.getColumnByIndex(6).getName()), .001f);
assertEquals("string-value", rr.getString(7));
assertEquals("string-value", rr.getObject(7));
- assertEquals("string-value", rr.getString(allTypesSchema.getColumnByIndex(7).getName()));
+ assertEquals("string-value",
+ rr.getString(allTypesSchema.getColumnByIndex(7).getName()));
assertArrayEquals("binary-array".getBytes(UTF_8), rr.getBinaryCopy(8));
assertArrayEquals("binary-array".getBytes(UTF_8), (byte[]) rr.getObject(8));
@@ -138,15 +142,18 @@ public class TestRowResult {
assertEquals(new Timestamp(11), rr.getTimestamp(11));
assertEquals(new Timestamp(11), rr.getObject(11));
- assertEquals(new Timestamp(11), rr.getTimestamp(allTypesSchema.getColumnByIndex(11).getName()));
+ assertEquals(new Timestamp(11),
+ rr.getTimestamp(allTypesSchema.getColumnByIndex(11).getName()));
assertEquals(BigDecimal.valueOf(12345, 3), rr.getDecimal(12));
assertEquals(BigDecimal.valueOf(12345, 3), rr.getObject(12));
- assertEquals(BigDecimal.valueOf(12345, 3), rr.getDecimal(allTypesSchema.getColumnByIndex(12).getName()));
+ assertEquals(BigDecimal.valueOf(12345, 3),
+ rr.getDecimal(allTypesSchema.getColumnByIndex(12).getName()));
assertEquals("varcharval", rr.getVarchar(13));
assertEquals("varcharval", rr.getObject(13));
- assertEquals("varcharval", rr.getVarchar(allTypesSchema.getColumnByIndex(13).getName()));
+ assertEquals("varcharval",
+ rr.getVarchar(allTypesSchema.getColumnByIndex(13).getName()));
// We test with the column name once since it's the same method for all types, unlike above.
assertEquals(Type.INT8, rr.getColumnType(allTypesSchema.getColumnByIndex(0).getName()));
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
index c125d47..4546bf6 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanPredicate.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanPredicate.java
index d0173db..8213b39 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanPredicate.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanPredicate.java
@@ -72,7 +72,8 @@ public class TestScanPredicate {
}
private int countRows(KuduTable table, KuduPredicate... predicates) throws Exception {
- KuduScanner.KuduScannerBuilder scanBuilder = new KuduScanner.KuduScannerBuilder(asyncClient, table);
+ KuduScanner.KuduScannerBuilder scanBuilder =
+ new KuduScanner.KuduScannerBuilder(asyncClient, table);
for (KuduPredicate predicate : predicates) {
scanBuilder.addPredicate(predicate);
}
@@ -148,9 +149,8 @@ public class TestScanPredicate {
100.0F,
Float.MAX_VALUE,
Float.POSITIVE_INFINITY
-
- // TODO: uncomment after fixing KUDU-1386
- // Float.NaN
+ // TODO: uncomment after fixing KUDU-1386
+ // Float.NaN
);
}
@@ -192,8 +192,8 @@ public class TestScanPredicate {
Double.MAX_VALUE,
Double.POSITIVE_INFINITY
- // TODO: uncomment after fixing KUDU-1386
- // Double.NaN
+ // TODO: uncomment after fixing KUDU-1386
+ // Double.NaN
);
}
@@ -465,7 +465,7 @@ public class TestScanPredicate {
KuduTable table = client.openTable("float-table");
NavigableSet<Float> values = createFloatValues();
- List<Float> testValues = createFloatTestValues();
+ final List<Float> testValues = createFloatTestValues();
KuduSession session = client.newSession();
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
long i = 0;
@@ -524,7 +524,7 @@ public class TestScanPredicate {
KuduTable table = client.openTable("double-table");
NavigableSet<Double> values = createDoubleValues();
- List<Double> testValues = createDoubleTestValues();
+ final List<Double> testValues = createDoubleTestValues();
KuduSession session = client.newSession();
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
long i = 0;
@@ -587,7 +587,7 @@ public class TestScanPredicate {
KuduTable table = client.openTable("decimal-table");
NavigableSet<BigDecimal> values = createDecimalValues();
- List<BigDecimal> testValues = createDecimalTestValues();
+ final List<BigDecimal> testValues = createDecimalTestValues();
KuduSession session = client.newSession();
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
long i = 0;
@@ -655,7 +655,7 @@ public class TestScanPredicate {
KuduTable table = client.openTable("string-table");
NavigableSet<String> values = createStringValues();
- List<String> testValues = createStringTestValues();
+ final List<String> testValues = createStringTestValues();
KuduSession session = client.newSession();
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
long i = 0;
@@ -723,7 +723,7 @@ public class TestScanPredicate {
KuduTable table = client.openTable("binary-table");
NavigableSet<String> values = createStringValues();
- List<String> testValues = createStringTestValues();
+ final List<String> testValues = createStringTestValues();
KuduSession session = client.newSession();
session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH);
long i = 0;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanToken.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanToken.java
index e8057c0..d3611f0 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanToken.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScanToken.java
@@ -239,7 +239,7 @@ public class TestScanToken {
@Test
public void testScanTokensConcurrentColumnRename() throws Exception {
Schema schema = getBasicSchema();
- String oldColName = schema.getColumnByIndex(1).getName();
+ final String oldColName = schema.getColumnByIndex(1).getName();
CreateTableOptions createOptions = new CreateTableOptions();
createOptions.setRangePartitionColumns(ImmutableList.of());
createOptions.setNumReplicas(1);
@@ -359,8 +359,10 @@ public class TestScanToken {
for (KuduScanner scanner : scanners) {
scannedRows += countRowsInScan(scanner);
}
- assertTrue(String.format("%d >= %d / 3?", scannedRows, numRows), scannedRows >= numRows / 3);
- assertTrue(String.format("%d <= 2 * %d / 3?", scannedRows, numRows), scannedRows <= 2 * numRows / 3);
+ assertTrue(String.format("%d >= %d / 3?", scannedRows, numRows),
+ scannedRows >= numRows / 3);
+ assertTrue(String.format("%d <= 2 * %d / 3?", scannedRows, numRows),
+ scannedRows <= 2 * numRows / 3);
}
/** Test that scanRequestTimeout makes it from the scan token to the underlying Scanner class. */
@@ -415,7 +417,9 @@ public class TestScanToken {
while (scanner.hasMoreRows()) {
for (RowResult rowResult : scanner.nextRows()) {
numMutations++;
- if (rowResult.isDeleted()) numDeletes++;
+ if (rowResult.isDeleted()) {
+ numDeletes++;
+ }
}
}
assertEquals(numExpectedMutations, numMutations);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
index ccdc965..e7fcda2 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.Type.STRING;
@@ -43,7 +44,7 @@ import org.apache.kudu.test.KuduTestHarness;
public class TestScannerMultiTablet {
// Generate a unique table name
private static final String TABLE_NAME =
- TestScannerMultiTablet.class.getName()+"-"+System.currentTimeMillis();
+ TestScannerMultiTablet.class.getName() + "-" + System.currentTimeMillis();
private static Schema schema = getSchema();
@@ -108,10 +109,10 @@ public class TestScannerMultiTablet {
}
private void validateResourceMetrics(ResourceMetrics resourceMetrics) {
- assertTrue("queue_duration_nanos > 0",
- resourceMetrics.getMetric("queue_duration_nanos") > 0L);
- assertTrue("total_duration_nanos > 0",
- resourceMetrics.getMetric("total_duration_nanos") > 0L);
+ assertTrue("queue_duration_nanos > 0",
+ resourceMetrics.getMetric("queue_duration_nanos") > 0L);
+ assertTrue("total_duration_nanos > 0",
+ resourceMetrics.getMetric("total_duration_nanos") > 0L);
}
// Test scanner resource metrics.
@@ -165,6 +166,7 @@ public class TestScannerMultiTablet {
// Test mixing start/end row keys with predicates.
@Test(timeout = 100000)
+ @SuppressWarnings("deprecation")
public void testKeysAndPredicates() throws Exception {
// Value that doesn't exist, predicates has primary column
ColumnRangePredicate predicate = new ColumnRangePredicate(schema.getColumnByIndex(1));
@@ -461,6 +463,7 @@ public class TestScannerMultiTablet {
exclusiveUpperBoundKeyOne, exclusiveUpperBoundKeyTwo, null);
}
+ @SuppressWarnings("deprecation")
private AsyncKuduScanner getScanner(String lowerBoundKeyOne,
String lowerBoundKeyTwo,
String exclusiveUpperBoundKeyOne,
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
index 37489a8..480fd13 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurity.java
@@ -11,6 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License. See accompanying LICENSE file.
*/
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createBasicSchemaInsert;
@@ -29,8 +30,8 @@ import java.util.concurrent.TimeUnit;
import javax.security.auth.Subject;
import com.google.common.base.Stopwatch;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.stumbleupon.async.Deferred;
import org.hamcrest.CoreMatchers;
import org.junit.After;
@@ -65,10 +66,11 @@ public class TestSecurity {
START_TSERVERS,
}
- static private class KeyValueMessage {
+ private static class KeyValueMessage {
final String key;
final String val;
final String msg;
+
KeyValueMessage(String k, String v, String m) {
key = k;
val = v;
@@ -193,9 +195,9 @@ public class TestSecurity {
* is to export credentials, that should trigger a connection to the
* cluster rather than returning empty credentials.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testExportCredentialsBeforeAnyOtherAccess() throws IOException {
- startCluster(ImmutableSet.<Option>of());
+ startCluster(ImmutableSet.of());
try (KuduClient c = createClient()) {
AuthenticationCredentialsPB pb = AuthenticationCredentialsPB.parseFrom(
c.exportAuthenticationCredentials());
@@ -263,7 +265,7 @@ public class TestSecurity {
public boolean get() throws Exception {
ConnectToCluster connector = new ConnectToCluster(miniCluster.getMasterServers());
List<Deferred<ConnectToMasterResponsePB>> deferreds =
- connector.connectToMasters(newClient.asyncClient.getMasterTable(), null,
+ connector.connectToMasters(newClient.asyncClient.getMasterTable(), null,
/* timeout = */50000,
Connection.CredentialsPolicy.ANY_CREDENTIALS);
// Wait for all Deferreds are called back.
@@ -273,7 +275,7 @@ public class TestSecurity {
List<Exception> s = connector.getExceptionsReceived();
return s.size() == 0;
}
- }, /* timeoutMillis = */50000);
+ }, /* timeoutMillis = */50000);
} finally {
System.setProperty(SecurityUtil.KUDU_TICKETCACHE_PROPERTY, oldTicketCache);
}
@@ -311,7 +313,7 @@ public class TestSecurity {
* Test that, if our Kerberos credentials expire, that we will automatically
* re-login from an available ticket cache.
*/
- @Test(timeout=300000)
+ @Test(timeout = 300000)
public void testRenewAndReacquireKeberosCredentials() throws Exception {
startCluster(ImmutableSet.of(Option.SHORT_TOKENS_AND_TICKETS));
Stopwatch timeSinceKinit = Stopwatch.createStarted();
@@ -343,7 +345,7 @@ public class TestSecurity {
* Test that, if the ticket cache is refreshed but contains a different principal
* from the original one, we will not accept it.
*/
- @Test(timeout=300000)
+ @Test(timeout = 300000)
public void testDoNotSwitchPrincipalsInExistingClient() throws Exception {
startCluster(ImmutableSet.of(Option.SHORT_TOKENS_AND_TICKETS));
// Switch the ticket cache to a different user.
@@ -381,7 +383,7 @@ public class TestSecurity {
}
return false;
}
- }, 60000);
+ }, 60000);
}
/**
@@ -389,7 +391,7 @@ public class TestSecurity {
* is created, the client will not attempt to refresh anything, and will
* eventually fail with appropriate warnings in the log.
*/
- @Test(timeout=300000)
+ @Test(timeout = 300000)
public void testExternallyProvidedSubjectExpires() throws Exception {
startCluster(ImmutableSet.of(Option.SHORT_TOKENS_AND_TICKETS));
Subject subject = SecurityUtil.getSubjectFromTicketCacheOrNull();
@@ -417,7 +419,7 @@ public class TestSecurity {
* the UserGroupInformation class from Hadoop, which spawns a thread to
* renew credentials from a keytab.
*/
- @Test(timeout=300000)
+ @Test(timeout = 300000)
public void testExternallyProvidedSubjectRefreshedExternally() throws Exception {
startCluster(ImmutableSet.of(Option.SHORT_TOKENS_AND_TICKETS));
@@ -452,7 +454,7 @@ public class TestSecurity {
* Test that if a Kudu server (in this case master) doesn't provide valid
* connection binding information, Java client fails to connect to the server.
*/
- @Test(timeout=60000)
+ @Test(timeout = 60000)
public void testNegotiationChannelBindings() throws Exception {
startCluster(ImmutableSet.of(Option.START_TSERVERS));
// Test precondition: all is well with masters -- the client is able
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurityContextRealUser.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurityContextRealUser.java
index 7910c31..c9b8151 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurityContextRealUser.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSecurityContextRealUser.java
@@ -39,7 +39,8 @@ import org.apache.kudu.test.cluster.MiniKuduCluster.MiniKuduClusterBuilder;
public class TestSecurityContextRealUser {
private String tableName;
- private static final MiniKuduClusterBuilder clusterBuilder = KuduTestHarness.getBaseClusterBuilder()
+ private static final MiniKuduClusterBuilder clusterBuilder =
+ KuduTestHarness.getBaseClusterBuilder()
// This test requires a delicate setup. We enable Kerberos, make
// authentication optional, and set the superuser ACL to test-admin so that
// the external mini-cluster is able to connect to the master while creating
@@ -90,7 +91,7 @@ public class TestSecurityContextRealUser {
// Smoke-test tserver connection by scanning a table.
KuduTable table = client.createTable(tableName, getBasicSchema(),
new CreateTableOptions().setRangePartitionColumns(
- new ArrayList<String>()));
+ new ArrayList<>()));
assertEquals(0, scanTableToStrings(table).size());
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestServerInfo.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestServerInfo.java
index e3e0644..41281d9 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestServerInfo.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestServerInfo.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import java.net.InetAddress;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSplitKeyRange.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSplitKeyRange.java
index 62f0ec9..fe053f8 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestSplitKeyRange.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestSplitKeyRange.java
@@ -20,6 +20,7 @@ package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createTableWithOneThousandRows;
import static org.apache.kudu.test.KuduTestHarness.DEFAULT_SLEEP;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
@@ -34,7 +35,7 @@ import org.apache.kudu.test.KuduTestHarness.TabletServerConfig;
public class TestSplitKeyRange {
// Generate a unique table name
private static final String TABLE_NAME =
- TestSplitKeyRange.class.getName()+"-"+System.currentTimeMillis();
+ TestSplitKeyRange.class.getName() + "-" + System.currentTimeMillis();
@Rule
public KuduTestHarness harness = new KuduTestHarness();
@@ -53,7 +54,7 @@ public class TestSplitKeyRange {
// Wait for mrs flushed
Thread.sleep(5 * 1000);
- Schema schema = table.getSchema();
+ final Schema schema = table.getSchema();
// 1. Don't split tablet's key range
// 1.1 Get all key range for table
@@ -61,10 +62,10 @@ public class TestSplitKeyRange {
table,null, null, null, null,
AsyncKuduClient.FETCH_TABLETS_PER_RANGE_LOOKUP, -1, DEFAULT_SLEEP).join();
assertEquals(4, keyRanges.size());
- LocatedTablet tablet0 = keyRanges.get(0).getTablet();
- LocatedTablet tablet1 = keyRanges.get(1).getTablet();
- LocatedTablet tablet2 = keyRanges.get(2).getTablet();
- LocatedTablet tablet3 = keyRanges.get(3).getTablet();
+ final LocatedTablet tablet0 = keyRanges.get(0).getTablet();
+ final LocatedTablet tablet1 = keyRanges.get(1).getTablet();
+ final LocatedTablet tablet2 = keyRanges.get(2).getTablet();
+ final LocatedTablet tablet3 = keyRanges.get(3).getTablet();
// 1.2 Get all key range for specified tablet
keyRanges = table.getAsyncClient().getTableKeyRanges(
table, null, null,
@@ -74,8 +75,8 @@ public class TestSplitKeyRange {
-1, DEFAULT_SLEEP).join();
assertEquals(1, keyRanges.size());
assertEquals(tablet1.toString(), keyRanges.get(0).getTablet().toString());
- assertEquals(null, keyRanges.get(0).getPrimaryKeyStart());
- assertEquals(null, keyRanges.get(0).getPrimaryKeyEnd());
+ assertNull(keyRanges.get(0).getPrimaryKeyStart());
+ assertNull(keyRanges.get(0).getPrimaryKeyEnd());
// 2. Don't set primary key range, and splitSizeBytes > tablet's size
keyRanges = table.getAsyncClient().getTableKeyRanges(
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
index 37a8ace..1224ed6 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatistics.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createBasicSchemaInsert;
@@ -33,8 +34,8 @@ import org.apache.kudu.test.KuduTestHarness;
public class TestStatistics {
- private static final String TABLE_NAME = TestStatistics.class.getName() + "-"
- + System.currentTimeMillis();
+ private static final String TABLE_NAME = TestStatistics.class.getName() + "-" +
+ System.currentTimeMillis();
private KuduTable table;
@Rule
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatus.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatus.java
index 0b51b68..753409d 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatus.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestStatus.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTableLocationsCache.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTableLocationsCache.java
index ff3213d..b232bd4 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTableLocationsCache.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTableLocationsCache.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
@@ -40,10 +41,13 @@ public class TestTableLocationsCache {
* Prevent time from advancing during the test by mocking the time.
*/
@Before
+ @SuppressWarnings("unstable")
public void mockTime() {
TableLocationsCache.ticker = Mockito.mock(Ticker.class);
}
+
@After
+ @SuppressWarnings("unstable")
public void unmockTime() {
TableLocationsCache.ticker = Ticker.systemTicker();
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeoutTracker.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeoutTracker.java
index 38618b1..bb1ee1d 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeoutTracker.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeoutTracker.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
index cfad30c..5e1289b 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTimeouts.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.client;
import static org.apache.kudu.test.ClientTestUtil.createBasicSchemaInsert;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestAsyncUtil.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestAsyncUtil.java
index 7c859e1..f920067 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestAsyncUtil.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestAsyncUtil.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
import static org.junit.Assert.assertEquals;
@@ -35,7 +36,7 @@ public class TestAsyncUtil {
@Test(expected = IllegalStateException.class)
public void testAddCallbacksDeferring() throws Exception {
- Deferred<String> d = new Deferred<String>();
+ Deferred<String> d = new Deferred<>();
TestCallback cb = new TestCallback();
TestErrback eb = new TestErrback();
@@ -45,25 +46,25 @@ public class TestAsyncUtil {
d.callback(testStr);
assertEquals(d.join(), "callback: " + testStr);
- d = new Deferred<String>();
+ d = new Deferred<>();
AsyncUtil.addCallbacksDeferring(d, cb, eb);
d.callback(new IllegalArgumentException());
assertEquals(d.join(), "illegal arg");
- d = new Deferred<String>();
+ d = new Deferred<>();
AsyncUtil.addCallbacksDeferring(d, cb, eb);
d.callback(new IllegalStateException());
d.join();
}
- final static class TestCallback implements Callback<Deferred<String>, String> {
+ static final class TestCallback implements Callback<Deferred<String>, String> {
@Override
public Deferred<String> call(String arg) throws Exception {
return Deferred.fromResult("callback: " + arg);
}
}
- final static class TestErrback implements Callback<Deferred<String>, Exception> {
+ static final class TestErrback implements Callback<Deferred<String>, Exception> {
@Override
public Deferred<String> call(Exception arg) {
if (arg instanceof IllegalArgumentException) {
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestByteVec.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestByteVec.java
index e99df2d..886abc9 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestByteVec.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestByteVec.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
import static org.junit.Assert.assertEquals;
@@ -37,7 +38,9 @@ public class TestByteVec {
public RetryRule retryRule = new RetryRule();
private void assertBytesEqual(byte a, byte b) {
- if (a != b) throw new AssertionError(String.format("%s != %s", a, b));
+ if (a != b) {
+ throw new AssertionError(String.format("%s != %s", a, b));
+ }
}
private List<Byte> random() {
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestMurmurHash.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestMurmurHash.java
index 19116f9..742e8e7 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestMurmurHash.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestMurmurHash.java
@@ -14,8 +14,10 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import com.google.common.primitives.UnsignedLongs;
@@ -40,13 +42,13 @@ public class TestMurmurHash {
public void testMurmur2Hash64() throws Exception {
long hash;
- hash = Murmur2.hash64("ab".getBytes("UTF-8"), 2, 0);
+ hash = Murmur2.hash64("ab".getBytes(UTF_8), 2, 0);
assertEquals(UnsignedLongs.parseUnsignedLong("7115271465109541368"), hash);
- hash = Murmur2.hash64("abcdefg".getBytes("UTF-8"), 7, 0);
+ hash = Murmur2.hash64("abcdefg".getBytes(UTF_8), 7, 0);
assertEquals(UnsignedLongs.parseUnsignedLong("2601573339036254301"), hash);
- hash = Murmur2.hash64("quick brown fox".getBytes("UTF-8"), 15, 42);
+ hash = Murmur2.hash64("quick brown fox".getBytes(UTF_8), 15, 42);
assertEquals(UnsignedLongs.parseUnsignedLong("3575930248840144026"), hash);
}
}
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestNetUtil.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestNetUtil.java
index 8af7d3c..20a5b06 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestNetUtil.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestNetUtil.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
import static org.junit.Assert.assertArrayEquals;
@@ -45,15 +46,15 @@ public class TestNetUtil {
*/
@Test
public void testParseString() {
- String aStringWithPort = "1.2.3.4:1234";
- HostAndPort hostAndPortForAStringWithPort = NetUtil.parseString(aStringWithPort, 0);
- assertEquals(hostAndPortForAStringWithPort.getHost(), "1.2.3.4");
- assertEquals(hostAndPortForAStringWithPort.getPort(), 1234);
+ String stringWithPort = "1.2.3.4:1234";
+ HostAndPort hostAndPortForStringWithPort = NetUtil.parseString(stringWithPort, 0);
+ assertEquals(hostAndPortForStringWithPort.getHost(), "1.2.3.4");
+ assertEquals(hostAndPortForStringWithPort.getPort(), 1234);
- String aStringWithoutPort = "1.2.3.4";
- HostAndPort hostAndPortForAStringWithoutPort = NetUtil.parseString(aStringWithoutPort, 12345);
- assertEquals(hostAndPortForAStringWithoutPort.getHost(), aStringWithoutPort);
- assertEquals(hostAndPortForAStringWithoutPort.getPort(), 12345);
+ String stringWithoutPort = "1.2.3.4";
+ HostAndPort hostAndPortForStringWithoutPort = NetUtil.parseString(stringWithoutPort, 12345);
+ assertEquals(hostAndPortForStringWithoutPort.getHost(), stringWithoutPort);
+ assertEquals(hostAndPortForStringWithoutPort.getPort(), 12345);
}
/**
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestStringUtil.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestStringUtil.java
index 1f6a8df..fc29af5 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestStringUtil.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestStringUtil.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
import static org.junit.Assert.assertEquals;
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java b/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
index 3731393..61e685b 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/util/TestTimestampUtil.java
@@ -14,6 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+
package org.apache.kudu.util;
import static org.junit.Assert.assertEquals;