filesToAdd);
}
diff --git a/api/src/main/java/org/apache/iceberg/TableScan.java b/api/src/main/java/org/apache/iceberg/TableScan.java
index 4f189aab9137..3a9c60f9f792 100644
--- a/api/src/main/java/org/apache/iceberg/TableScan.java
+++ b/api/src/main/java/org/apache/iceberg/TableScan.java
@@ -105,6 +105,13 @@ default TableScan select(String... columns) {
*/
TableScan filter(Expression expr);
+ /**
+ * Returns this scan's filter {@link Expression}.
+ *
+ * @return this scan's filter expression
+ */
+ Expression filter();
+
/**
* Plan the {@link FileScanTask files} that will be read by this scan.
*
@@ -139,13 +146,6 @@ default TableScan select(String... columns) {
*/
Schema schema();
- /**
- * Returns this scan's filter {@link Expression}.
- *
- * @return this scan's filter expression
- */
- Expression filter();
-
/**
* Returns whether this scan should apply column name case sensitiveness as per {@link #caseSensitive(boolean)}.
* @return true if case sensitive, false otherwise.
diff --git a/api/src/main/java/org/apache/iceberg/UpdateSchema.java b/api/src/main/java/org/apache/iceberg/UpdateSchema.java
index 8d9b17943d0a..7fe6becc21d5 100644
--- a/api/src/main/java/org/apache/iceberg/UpdateSchema.java
+++ b/api/src/main/java/org/apache/iceberg/UpdateSchema.java
@@ -152,37 +152,37 @@ default UpdateSchema addColumn(String parent, String name, Type type) {
*
* The name is used to find the column to update using {@link Schema#findField(String)}.
*
+ * Only updates that widen types are allowed.
+ *
* Columns may be updated and renamed in the same schema update.
*
* @param name name of the column to rename
+ * @param newType replacement type for the column
* @param newDoc replacement documentation string for the column
* @return this for method chaining
* @throws IllegalArgumentException If name doesn't identify a column in the schema or if this
* change introduces a type incompatibility or if it conflicts
* with other additions, renames, or updates.
*/
- UpdateSchema updateColumnDoc(String name, String newDoc);
+ default UpdateSchema updateColumn(String name, Type.PrimitiveType newType, String newDoc) {
+ return updateColumn(name, newType).updateColumnDoc(name, newDoc);
+ }
/**
* Update a column in the schema to a new primitive type.
*
* The name is used to find the column to update using {@link Schema#findField(String)}.
*
- * Only updates that widen types are allowed.
- *
* Columns may be updated and renamed in the same schema update.
*
* @param name name of the column to rename
- * @param newType replacement type for the column
* @param newDoc replacement documentation string for the column
* @return this for method chaining
* @throws IllegalArgumentException If name doesn't identify a column in the schema or if this
* change introduces a type incompatibility or if it conflicts
* with other additions, renames, or updates.
*/
- default UpdateSchema updateColumn(String name, Type.PrimitiveType newType, String newDoc) {
- return updateColumn(name, newType).updateColumnDoc(name, newDoc);
- }
+ UpdateSchema updateColumnDoc(String name, String newDoc);
/**
* Delete a column in the schema.
diff --git a/api/src/main/java/org/apache/iceberg/exceptions/RuntimeIOException.java b/api/src/main/java/org/apache/iceberg/exceptions/RuntimeIOException.java
index 62fc8f18be05..daa42d483575 100644
--- a/api/src/main/java/org/apache/iceberg/exceptions/RuntimeIOException.java
+++ b/api/src/main/java/org/apache/iceberg/exceptions/RuntimeIOException.java
@@ -25,12 +25,12 @@
* Exception used to wrap {@link IOException} as a {@link RuntimeException} and add context.
*/
public class RuntimeIOException extends RuntimeException {
- public RuntimeIOException(IOException e) {
- super(e);
+ public RuntimeIOException(IOException cause) {
+ super(cause);
}
- public RuntimeIOException(IOException e, String message, Object... args) {
- super(String.format(message, args), e);
+ public RuntimeIOException(IOException cause, String message, Object... args) {
+ super(String.format(message, args), cause);
}
public RuntimeIOException(String message, Object...args) {
diff --git a/api/src/main/java/org/apache/iceberg/expressions/BoundReference.java b/api/src/main/java/org/apache/iceberg/expressions/BoundReference.java
index 1e076d41fbb2..192d365e1700 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/BoundReference.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/BoundReference.java
@@ -36,15 +36,15 @@ public class BoundReference implements Reference {
this.type = struct.fields().get(pos).type();
}
- private int find(int fieldId, Types.StructType struct) {
+ private int find(int id, Types.StructType struct) {
List fields = struct.fields();
for (int i = 0; i < fields.size(); i += 1) {
- if (fields.get(i).fieldId() == fieldId) {
+ if (fields.get(i).fieldId() == id) {
return i;
}
}
throw new ValidationException(
- "Cannot find top-level field id %d in struct: %s", fieldId, struct);
+ "Cannot find top-level field id %d in struct: %s", id, struct);
}
public Type type() {
diff --git a/api/src/main/java/org/apache/iceberg/expressions/Expression.java b/api/src/main/java/org/apache/iceberg/expressions/Expression.java
index 2c7534b6d20d..124e61225596 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/Expression.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/Expression.java
@@ -75,6 +75,8 @@ public Operation negate() {
/**
* @return the equivalent operation when the left and right operands are exchanged
*/
+ // Allow flipLR as a name because it's a public API
+ @SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public Operation flipLR() {
switch (this) {
case LT:
diff --git a/api/src/main/java/org/apache/iceberg/expressions/ExpressionVisitors.java b/api/src/main/java/org/apache/iceberg/expressions/ExpressionVisitors.java
index 9df28f3ea7ac..3e6b7916ca73 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/ExpressionVisitors.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/ExpressionVisitors.java
@@ -23,6 +23,9 @@
* Utils for traversing {@link Expression expressions}.
*/
public class ExpressionVisitors {
+
+ private ExpressionVisitors() {}
+
public abstract static class ExpressionVisitor {
public R alwaysTrue() {
return null;
diff --git a/api/src/main/java/org/apache/iceberg/expressions/Literals.java b/api/src/main/java/org/apache/iceberg/expressions/Literals.java
index 4e2d4a4dcbae..3216e0ea0b02 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/Literals.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/Literals.java
@@ -116,7 +116,7 @@ private abstract static class ComparableLiteral> extends
private static final Comparator extends Comparable> CMP =
Comparators.nullsFirst().thenComparing(Comparator.naturalOrder());
- public ComparableLiteral(C value) {
+ ComparableLiteral(C value) {
super(value);
}
@@ -340,7 +340,7 @@ static class TimeLiteral extends ComparableLiteral {
@SuppressWarnings("unchecked")
public Literal to(Type type) {
if (type.typeId() == Type.TypeID.TIME) {
- return (Literal) this ;
+ return (Literal) this;
}
return null;
}
diff --git a/api/src/main/java/org/apache/iceberg/expressions/NamedReference.java b/api/src/main/java/org/apache/iceberg/expressions/NamedReference.java
index f5fcc8ebc471..8a88ce31d66e 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/NamedReference.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/NamedReference.java
@@ -22,7 +22,7 @@
import com.google.common.base.Preconditions;
public class NamedReference implements Reference {
- public final String name;
+ private final String name;
NamedReference(String name) {
Preconditions.checkNotNull(name, "Name cannot be null");
diff --git a/api/src/main/java/org/apache/iceberg/expressions/Projections.java b/api/src/main/java/org/apache/iceberg/expressions/Projections.java
index 9ebfae96090b..d27f75cb7327 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/Projections.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/Projections.java
@@ -43,7 +43,7 @@ private Projections() {
* A strict projection guarantees that if a partition matches a projected expression, then all
* rows in that partition will match the original expression.
*/
- public static abstract class ProjectionEvaluator extends ExpressionVisitor {
+ public abstract static class ProjectionEvaluator extends ExpressionVisitor {
/**
* Project the given row expression to a partition expression.
*
@@ -134,8 +134,8 @@ public static ProjectionEvaluator strict(PartitionSpec spec, boolean caseSensiti
}
private static class BaseProjectionEvaluator extends ProjectionEvaluator {
- final PartitionSpec spec;
- final boolean caseSensitive;
+ private final PartitionSpec spec;
+ private final boolean caseSensitive;
private BaseProjectionEvaluator(PartitionSpec spec, boolean caseSensitive) {
this.spec = spec;
@@ -187,6 +187,14 @@ public Expression predicate(UnboundPredicate pred) {
return bound;
}
+
+ PartitionSpec spec() {
+ return spec;
+ }
+
+ boolean isCaseSensitive() {
+ return caseSensitive;
+ }
}
private static class InclusiveProjection extends BaseProjectionEvaluator {
@@ -197,7 +205,7 @@ private InclusiveProjection(PartitionSpec spec, boolean caseSensitive) {
@Override
@SuppressWarnings("unchecked")
public Expression predicate(BoundPredicate pred) {
- PartitionField part = spec.getFieldBySourceId(pred.ref().fieldId());
+ PartitionField part = spec().getFieldBySourceId(pred.ref().fieldId());
if (part == null) {
// the predicate has no partition column
return alwaysTrue();
@@ -222,7 +230,7 @@ private StrictProjection(PartitionSpec spec, boolean caseSensitive) {
@Override
@SuppressWarnings("unchecked")
public Expression predicate(BoundPredicate pred) {
- PartitionField part = spec.getFieldBySourceId(pred.ref().fieldId());
+ PartitionField part = spec().getFieldBySourceId(pred.ref().fieldId());
if (part == null) {
// the predicate has no partition column
return alwaysFalse();
diff --git a/api/src/main/java/org/apache/iceberg/expressions/ResidualEvaluator.java b/api/src/main/java/org/apache/iceberg/expressions/ResidualEvaluator.java
index 459d20785fb6..867c7a897bff 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/ResidualEvaluator.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/ResidualEvaluator.java
@@ -78,8 +78,8 @@ public Expression residualFor(StructLike partitionData) {
private class ResidualVisitor extends ExpressionVisitors.BoundExpressionVisitor {
private StructLike struct;
- private Expression eval(StructLike struct) {
- this.struct = struct;
+ private Expression eval(StructLike structLike) {
+ this.struct = structLike;
return ExpressionVisitors.visit(expr, this);
}
diff --git a/api/src/main/java/org/apache/iceberg/expressions/SerializationProxies.java b/api/src/main/java/org/apache/iceberg/expressions/SerializationProxies.java
index 78da881608fd..6fd74163a8db 100644
--- a/api/src/main/java/org/apache/iceberg/expressions/SerializationProxies.java
+++ b/api/src/main/java/org/apache/iceberg/expressions/SerializationProxies.java
@@ -35,10 +35,10 @@ static class ConstantExpressionProxy implements Serializable {
/**
* Constructor for Java serialization.
*/
- public ConstantExpressionProxy() {
+ ConstantExpressionProxy() {
}
- public ConstantExpressionProxy(boolean trueOrFalse) {
+ ConstantExpressionProxy(boolean trueOrFalse) {
this.trueOrFalse = trueOrFalse;
}
@@ -63,7 +63,7 @@ static class BinaryLiteralProxy extends FixedLiteralProxy {
}
Object readResolve() throws ObjectStreamException {
- return new Literals.BinaryLiteral(ByteBuffer.wrap(bytes));
+ return new Literals.BinaryLiteral(ByteBuffer.wrap(bytes()));
}
}
@@ -71,7 +71,7 @@ Object readResolve() throws ObjectStreamException {
* Replacement for FixedLiteral in Java Serialization.
*/
static class FixedLiteralProxy implements Serializable {
- protected byte[] bytes;
+ private byte[] bytes;
/**
* Constructor for Java serialization.
@@ -87,5 +87,9 @@ static class FixedLiteralProxy implements Serializable {
Object readResolve() throws ObjectStreamException {
return new Literals.FixedLiteral(ByteBuffer.wrap(bytes));
}
+
+ protected byte[] bytes() {
+ return bytes;
+ }
}
}
diff --git a/api/src/main/java/org/apache/iceberg/io/CloseableGroup.java b/api/src/main/java/org/apache/iceberg/io/CloseableGroup.java
index 8b5a977db7b7..4eeab7b456e4 100644
--- a/api/src/main/java/org/apache/iceberg/io/CloseableGroup.java
+++ b/api/src/main/java/org/apache/iceberg/io/CloseableGroup.java
@@ -22,11 +22,11 @@
import com.google.common.collect.Lists;
import java.io.Closeable;
import java.io.IOException;
+import java.util.Deque;
import java.util.Iterator;
-import java.util.LinkedList;
public abstract class CloseableGroup implements Closeable {
- private final LinkedList closeables = Lists.newLinkedList();
+ private final Deque closeables = Lists.newLinkedList();
protected void addCloseable(Closeable closeable) {
closeables.add(closeable);
@@ -45,7 +45,7 @@ public void close() throws IOException {
static class ClosingIterable extends CloseableGroup implements CloseableIterable {
private final Iterable iterable;
- public ClosingIterable(Iterable iterable, Iterable closeables) {
+ ClosingIterable(Iterable iterable, Iterable closeables) {
this.iterable = iterable;
if (iterable instanceof Closeable) {
addCloseable((Closeable) iterable);
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Bucket.java b/api/src/main/java/org/apache/iceberg/transforms/Bucket.java
index b3dc4225768c..af62a9836684 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Bucket.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Bucket.java
@@ -20,7 +20,6 @@
package org.apache.iceberg.transforms;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
import com.google.common.hash.HashFunction;
@@ -28,6 +27,7 @@
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.UUID;
import org.apache.iceberg.expressions.BoundPredicate;
@@ -42,37 +42,37 @@ abstract class Bucket implements Transform {
private static final HashFunction MURMUR3 = Hashing.murmur3_32();
@SuppressWarnings("unchecked")
- static Bucket get(Type type, int N) {
+ static Bucket get(Type type, int numBuckets) {
switch (type.typeId()) {
case DATE:
case INTEGER:
- return (Bucket) new BucketInteger(N);
+ return (Bucket) new BucketInteger(numBuckets);
case TIME:
case TIMESTAMP:
case LONG:
- return (Bucket) new BucketLong(N);
+ return (Bucket) new BucketLong(numBuckets);
case DECIMAL:
- return (Bucket) new BucketDecimal(N);
+ return (Bucket) new BucketDecimal(numBuckets);
case STRING:
- return (Bucket) new BucketString(N);
+ return (Bucket) new BucketString(numBuckets);
case FIXED:
case BINARY:
- return (Bucket) new BucketByteBuffer(N);
+ return (Bucket) new BucketByteBuffer(numBuckets);
case UUID:
- return (Bucket) new BucketUUID(N);
+ return (Bucket) new BucketUUID(numBuckets);
default:
throw new IllegalArgumentException("Cannot bucket by type: " + type);
}
}
- private final int N;
+ private final int numBuckets;
- private Bucket(int N) {
- this.N = N;
+ private Bucket(int numBuckets) {
+ this.numBuckets = numBuckets;
}
public Integer numBuckets() {
- return N;
+ return numBuckets;
}
@VisibleForTesting
@@ -80,7 +80,7 @@ public Integer numBuckets() {
@Override
public Integer apply(T value) {
- return (hash(value) & Integer.MAX_VALUE) % N;
+ return (hash(value) & Integer.MAX_VALUE) % numBuckets;
}
@Override
@@ -93,17 +93,17 @@ public boolean equals(Object o) {
}
Bucket> bucket = (Bucket>) o;
- return N == bucket.N;
+ return numBuckets == bucket.numBuckets;
}
@Override
public int hashCode() {
- return Objects.hashCode(N);
+ return Objects.hashCode(numBuckets);
}
@Override
public String toString() {
- return "bucket[" + N + "]";
+ return "bucket[" + numBuckets + "]";
}
@Override
@@ -141,8 +141,8 @@ public Type getResultType(Type sourceType) {
}
private static class BucketInteger extends Bucket {
- private BucketInteger(int N) {
- super(N);
+ private BucketInteger(int numBuckets) {
+ super(numBuckets);
}
public int hash(Integer value) {
@@ -156,8 +156,8 @@ public boolean canTransform(Type type) {
}
private static class BucketLong extends Bucket {
- private BucketLong(int N) {
- super(N);
+ private BucketLong(int numBuckets) {
+ super(numBuckets);
}
public int hash(Long value) {
@@ -166,19 +166,18 @@ public int hash(Long value) {
@Override
public boolean canTransform(Type type) {
- return (
- type.typeId() == TypeID.LONG ||
+ return type.typeId() == TypeID.LONG ||
type.typeId() == TypeID.TIME ||
- type.typeId() == TypeID.TIMESTAMP
- );
+ type.typeId() == TypeID.TIMESTAMP;
+
}
}
// bucketing by Double is not allowed by the spec, but this has the float hash implementation
static class BucketFloat extends Bucket {
// used by tests because the factory method will not instantiate a bucket function for floats
- BucketFloat(int N) {
- super(N);
+ BucketFloat(int numBuckets) {
+ super(numBuckets);
}
public int hash(Float value) {
@@ -194,8 +193,8 @@ public boolean canTransform(Type type) {
// bucketing by Double is not allowed by the spec, but this has the double hash implementation
static class BucketDouble extends Bucket {
// used by tests because the factory method will not instantiate a bucket function for doubles
- BucketDouble(int N) {
- super(N);
+ BucketDouble(int numBuckets) {
+ super(numBuckets);
}
public int hash(Double value) {
@@ -209,12 +208,12 @@ public boolean canTransform(Type type) {
}
private static class BucketString extends Bucket {
- private BucketString(int N) {
- super(N);
+ private BucketString(int numBuckets) {
+ super(numBuckets);
}
public int hash(CharSequence value) {
- return MURMUR3.hashString(value, Charsets.UTF_8).asInt();
+ return MURMUR3.hashString(value, StandardCharsets.UTF_8).asInt();
}
@Override
@@ -227,8 +226,8 @@ private static class BucketBytes extends Bucket {
private static final Set SUPPORTED_TYPES = Sets.newHashSet(
TypeID.BINARY, TypeID.FIXED);
- private BucketBytes(int N) {
- super(N);
+ private BucketBytes(int numBuckets) {
+ super(numBuckets);
}
public int hash(byte[] value) {
@@ -245,8 +244,8 @@ private static class BucketByteBuffer extends Bucket {
private static final Set SUPPORTED_TYPES = Sets.newHashSet(
TypeID.BINARY, TypeID.FIXED);
- private BucketByteBuffer(int N) {
- super(N);
+ private BucketByteBuffer(int numBuckets) {
+ super(numBuckets);
}
public int hash(ByteBuffer value) {
@@ -280,8 +279,8 @@ private static class BucketUUID extends Bucket {
return buffer;
});
- private BucketUUID(int N) {
- super(N);
+ private BucketUUID(int numBuckets) {
+ super(numBuckets);
}
public int hash(UUID value) {
@@ -299,8 +298,8 @@ public boolean canTransform(Type type) {
}
private static class BucketDecimal extends Bucket {
- private BucketDecimal(int N) {
- super(N);
+ private BucketDecimal(int numBuckets) {
+ super(numBuckets);
}
public int hash(BigDecimal value) {
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Dates.java b/api/src/main/java/org/apache/iceberg/transforms/Dates.java
index f8296374af10..a57d6d95eaa4 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Dates.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Dates.java
@@ -65,15 +65,15 @@ public Type getResultType(Type sourceType) {
}
@Override
- public UnboundPredicate project(String name, BoundPredicate pred) {
+ public UnboundPredicate project(String fieldName, BoundPredicate pred) {
if (pred.op() == NOT_NULL || pred.op() == IS_NULL) {
- return Expressions.predicate(pred.op(), name);
+ return Expressions.predicate(pred.op(), fieldName);
}
- return ProjectionUtil.truncateInteger(name, pred, this);
+ return ProjectionUtil.truncateInteger(fieldName, pred, this);
}
@Override
- public UnboundPredicate projectStrict(String name, BoundPredicate predicate) {
+ public UnboundPredicate projectStrict(String fieldName, BoundPredicate predicate) {
return null;
}
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Identity.java b/api/src/main/java/org/apache/iceberg/transforms/Identity.java
index 2f1ffa8e2e90..ef1037ba9c8f 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Identity.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Identity.java
@@ -45,8 +45,8 @@ public T apply(T value) {
}
@Override
- public boolean canTransform(Type type) {
- return type.isPrimitiveType();
+ public boolean canTransform(Type maybePrimitive) {
+ return maybePrimitive.isPrimitiveType();
}
@Override
diff --git a/api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java b/api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java
index c5fd461f046c..04da036e1637 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/ProjectionUtil.java
@@ -28,6 +28,9 @@
import static org.apache.iceberg.expressions.Expressions.predicate;
class ProjectionUtil {
+
+ private ProjectionUtil() {}
+
static UnboundPredicate truncateInteger(
String name, BoundPredicate pred, Transform transform) {
int boundary = pred.literal().value();
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java b/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
index b50b31369f9e..1b5fc1dba72b 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
@@ -67,15 +67,15 @@ public Type getResultType(Type sourceType) {
}
@Override
- public UnboundPredicate project(String name, BoundPredicate pred) {
+ public UnboundPredicate project(String fieldName, BoundPredicate pred) {
if (pred.op() == NOT_NULL || pred.op() == IS_NULL) {
- return Expressions.predicate(pred.op(), name);
+ return Expressions.predicate(pred.op(), fieldName);
}
- return ProjectionUtil.truncateLong(name, pred, this);
+ return ProjectionUtil.truncateLong(fieldName, pred, this);
}
@Override
- public UnboundPredicate projectStrict(String name, BoundPredicate predicate) {
+ public UnboundPredicate projectStrict(String fieldName, BoundPredicate predicate) {
return null;
}
diff --git a/api/src/main/java/org/apache/iceberg/transforms/TransformUtil.java b/api/src/main/java/org/apache/iceberg/transforms/TransformUtil.java
index cd6f21c41d28..e3ac439d4d1e 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/TransformUtil.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/TransformUtil.java
@@ -19,8 +19,8 @@
package org.apache.iceberg.transforms;
-import com.google.common.base.Charsets;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalTime;
import java.time.OffsetDateTime;
@@ -29,6 +29,9 @@
import java.util.Base64;
class TransformUtil {
+
+ private TransformUtil() {}
+
private static final OffsetDateTime EPOCH = Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
private static final int EPOCH_YEAR = EPOCH.getYear();
@@ -66,6 +69,6 @@ static String humanHour(int hourOrdinal) {
static String base64encode(ByteBuffer buffer) {
// use direct encoding because all of the encoded bytes are in ASCII
- return Charsets.ISO_8859_1.decode(Base64.getEncoder().encode(buffer)).toString();
+ return StandardCharsets.ISO_8859_1.decode(Base64.getEncoder().encode(buffer)).toString();
}
}
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Transforms.java b/api/src/main/java/org/apache/iceberg/transforms/Transforms.java
index 1881d255d304..d94b410bdaf2 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Transforms.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Transforms.java
@@ -42,14 +42,14 @@ private Transforms() {
private static final Pattern HAS_WIDTH = Pattern.compile("(\\w+)\\[(\\d+)\\]");
public static Transform, ?> fromString(Type type, String transform) {
- Matcher width = HAS_WIDTH.matcher(transform);
- if (width.matches()) {
- String name = width.group(1);
- int w = Integer.parseInt(width.group(2));
+ Matcher widthMatcher = HAS_WIDTH.matcher(transform);
+ if (widthMatcher.matches()) {
+ String name = widthMatcher.group(1);
+ int parsedWidth = Integer.parseInt(widthMatcher.group(2));
if (name.equalsIgnoreCase("truncate")) {
- return Truncate.get(type, w);
+ return Truncate.get(type, parsedWidth);
} else if (name.equals("bucket")) {
- return Bucket.get(type, w);
+ return Bucket.get(type, parsedWidth);
}
}
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Truncate.java b/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
index acf0df00a457..d65d6462c918 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
@@ -53,10 +53,10 @@ static Truncate get(Type type, int width) {
}
}
- abstract public Integer width();
+ public abstract Integer width();
@Override
- abstract public T apply(T value);
+ public abstract T apply(T value);
@Override
public Type getResultType(Type sourceType) {
@@ -64,20 +64,20 @@ public Type getResultType(Type sourceType) {
}
private static class TruncateInteger extends Truncate {
- private final int W;
+ private final int width;
private TruncateInteger(int width) {
- this.W = width;
+ this.width = width;
}
@Override
public Integer width() {
- return W;
+ return width;
}
@Override
public Integer apply(Integer value) {
- return value - (((value % W) + W) % W);
+ return value - (((value % width) + width) % width);
}
@Override
@@ -146,35 +146,35 @@ public boolean equals(Object o) {
}
TruncateInteger that = (TruncateInteger) o;
- return W == that.W;
+ return width == that.width;
}
@Override
public int hashCode() {
- return Objects.hashCode(W);
+ return Objects.hashCode(width);
}
@Override
public String toString() {
- return "truncate[" + W + "]";
+ return "truncate[" + width + "]";
}
}
private static class TruncateLong extends Truncate {
- private final int W;
+ private final int width;
private TruncateLong(int width) {
- this.W = width;
+ this.width = width;
}
@Override
public Integer width() {
- return W;
+ return width;
}
@Override
public Long apply(Long value) {
- return value - (((value % W) + W) % W);
+ return value - (((value % width) + width) % width);
}
@Override
@@ -205,35 +205,35 @@ public boolean equals(Object o) {
}
TruncateLong that = (TruncateLong) o;
- return W == that.W;
+ return width == that.width;
}
@Override
public int hashCode() {
- return Objects.hashCode(W);
+ return Objects.hashCode(width);
}
@Override
public String toString() {
- return "truncate[" + W + "]";
+ return "truncate[" + width + "]";
}
}
private static class TruncateString extends Truncate {
- private final int L;
+ private final int length;
private TruncateString(int length) {
- this.L = length;
+ this.length = length;
}
@Override
public Integer width() {
- return L;
+ return length;
}
@Override
public CharSequence apply(CharSequence value) {
- return value.subSequence(0, Math.min(value.length(), L));
+ return value.subSequence(0, Math.min(value.length(), length));
}
@Override
@@ -266,36 +266,36 @@ public boolean equals(Object o) {
}
TruncateString that = (TruncateString) o;
- return L == that.L;
+ return length == that.length;
}
@Override
public int hashCode() {
- return Objects.hashCode(L);
+ return Objects.hashCode(length);
}
@Override
public String toString() {
- return "truncate[" + L + "]";
+ return "truncate[" + length + "]";
}
}
private static class TruncateByteBuffer extends Truncate {
- private final int L;
+ private final int length;
private TruncateByteBuffer(int length) {
- this.L = length;
+ this.length = length;
}
@Override
public Integer width() {
- return L;
+ return length;
}
@Override
public ByteBuffer apply(ByteBuffer value) {
ByteBuffer ret = value.duplicate();
- ret.limit(Math.min(value.limit(), value.position() + L));
+ ret.limit(Math.min(value.limit(), value.position() + length));
return ret;
}
@@ -329,12 +329,12 @@ public boolean equals(Object o) {
}
TruncateByteBuffer that = (TruncateByteBuffer) o;
- return L == that.L;
+ return length == that.length;
}
@Override
public int hashCode() {
- return Objects.hashCode(L);
+ return Objects.hashCode(length);
}
@Override
@@ -344,7 +344,7 @@ public String toHumanString(ByteBuffer value) {
@Override
public String toString() {
- return "truncate[" + L + "]";
+ return "truncate[" + length + "]";
}
}
diff --git a/api/src/main/java/org/apache/iceberg/types/CheckCompatibility.java b/api/src/main/java/org/apache/iceberg/types/CheckCompatibility.java
index 9c65850dfa92..3888d393b30d 100644
--- a/api/src/main/java/org/apache/iceberg/types/CheckCompatibility.java
+++ b/api/src/main/java/org/apache/iceberg/types/CheckCompatibility.java
@@ -29,8 +29,6 @@
import java.util.function.Supplier;
import org.apache.iceberg.Schema;
-import static org.apache.iceberg.types.TypeUtil.isPromotionAllowed;
-
public class CheckCompatibility extends TypeUtil.CustomOrderSchemaVisitor> {
/**
* Returns a list of compatibility errors for writing with the given write schema.
@@ -217,7 +215,7 @@ public List primitive(Type.PrimitiveType readPrimitive) {
currentType.typeId().toString().toLowerCase(Locale.ENGLISH), readPrimitive));
}
- if (!isPromotionAllowed(currentType.asPrimitiveType(), readPrimitive)) {
+ if (!TypeUtil.isPromotionAllowed(currentType.asPrimitiveType(), readPrimitive)) {
return ImmutableList.of(String.format(": %s cannot be promoted to %s",
currentType, readPrimitive));
}
diff --git a/api/src/main/java/org/apache/iceberg/types/Comparators.java b/api/src/main/java/org/apache/iceberg/types/Comparators.java
index d885f9adcffa..57cfc28ae9cf 100644
--- a/api/src/main/java/org/apache/iceberg/types/Comparators.java
+++ b/api/src/main/java/org/apache/iceberg/types/Comparators.java
@@ -24,6 +24,9 @@
import java.util.Comparator;
public class Comparators {
+
+ private Comparators() {}
+
private static final ImmutableMap> COMPARATORS = ImmutableMap
.>builder()
.put(Types.BooleanType.get(), Comparator.naturalOrder())
@@ -130,7 +133,7 @@ private static class NullSafeChainedComparator implements Comparator {
private final Comparator first;
private final Comparator super T> second;
- public NullSafeChainedComparator(Comparator first, Comparator super T> second) {
+ NullSafeChainedComparator(Comparator first, Comparator super T> second) {
this.first = first;
this.second = second;
}
diff --git a/api/src/main/java/org/apache/iceberg/types/Conversions.java b/api/src/main/java/org/apache/iceberg/types/Conversions.java
index 8fe8055d96cc..86f57f0298b6 100644
--- a/api/src/main/java/org/apache/iceberg/types/Conversions.java
+++ b/api/src/main/java/org/apache/iceberg/types/Conversions.java
@@ -19,7 +19,6 @@
package org.apache.iceberg.types;
-import com.google.common.base.Charsets;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
@@ -28,11 +27,15 @@
import java.nio.charset.CharacterCodingException;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.UUID;
import org.apache.iceberg.exceptions.RuntimeIOException;
public class Conversions {
+
+ private Conversions() {}
+
private static final String HIVE_NULL = "__HIVE_DEFAULT_PARTITION__";
public static Object fromPartitionString(Type type, String asString) {
@@ -58,9 +61,9 @@ public static Object fromPartitionString(Type type, String asString) {
case FIXED:
Types.FixedType fixed = (Types.FixedType) type;
return Arrays.copyOf(
- asString.getBytes(Charsets.UTF_8), fixed.length());
+ asString.getBytes(StandardCharsets.UTF_8), fixed.length());
case BINARY:
- return asString.getBytes(Charsets.UTF_8);
+ return asString.getBytes(StandardCharsets.UTF_8);
case DECIMAL:
return new BigDecimal(asString);
default:
@@ -70,9 +73,9 @@ public static Object fromPartitionString(Type type, String asString) {
}
private static final ThreadLocal ENCODER =
- ThreadLocal.withInitial(Charsets.UTF_8::newEncoder);
+ ThreadLocal.withInitial(StandardCharsets.UTF_8::newEncoder);
private static final ThreadLocal DECODER =
- ThreadLocal.withInitial(Charsets.UTF_8::newDecoder);
+ ThreadLocal.withInitial(StandardCharsets.UTF_8::newDecoder);
public static ByteBuffer toByteBuffer(Type type, Object value) {
switch (type.typeId()) {
@@ -120,7 +123,7 @@ private static Object internalFromByteBuffer(Type type, ByteBuffer buffer) {
ByteBuffer tmp = buffer.duplicate().order(ByteOrder.LITTLE_ENDIAN);
switch (type.typeId()) {
case BOOLEAN:
- return (tmp.get() != 0x00);
+ return tmp.get() != 0x00;
case INTEGER:
case DATE:
return tmp.getInt();
diff --git a/api/src/main/java/org/apache/iceberg/types/IndexById.java b/api/src/main/java/org/apache/iceberg/types/IndexById.java
index 0f368362af38..d1bed5df046f 100644
--- a/api/src/main/java/org/apache/iceberg/types/IndexById.java
+++ b/api/src/main/java/org/apache/iceberg/types/IndexById.java
@@ -33,12 +33,14 @@ public Map schema(Schema schema, Map struct(Types.StructType struct, List