Skip to content

Commit

Permalink
Revert "Add back UnnecessaryFullyQualifiedName rule in pmd ruleset (#…
Browse files Browse the repository at this point in the history
…17570)" (#17584)

This reverts commit cd6083f.
  • Loading branch information
Akshat-Jain authored Dec 18, 2024
1 parent d5eb94d commit 6fad11f
Show file tree
Hide file tree
Showing 154 changed files with 374 additions and 362 deletions.
1 change: 0 additions & 1 deletion codestyle/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ This ruleset defines the PMD rules for the Apache Druid project.

<rule ref="category/java/codestyle.xml/UnnecessaryImport" />
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
</ruleset>
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static void deleteBucketKeys(
throws Exception
{
DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(bucket).withKeys(keysToDelete);
retry(() -> {
OssUtils.retry(() -> {
client.deleteObjects(deleteRequest);
return null;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static CompressedBigDecimal objToCompressedBigDecimalWithScale(
boolean strictNumberParse
)
{
CompressedBigDecimal compressedBigDecimal = objToCompressedBigDecimal(obj, strictNumberParse);
CompressedBigDecimal compressedBigDecimal = Utils.objToCompressedBigDecimal(obj, strictNumberParse);

if (compressedBigDecimal != null) {
return scaleIfNeeded(compressedBigDecimal, scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum PeonPhase
UNKNOWN("Unknown"),
RUNNING("Running");

private static final Map<String, PeonPhase> PHASE_MAP = Arrays.stream(values())
private static final Map<String, PeonPhase> PHASE_MAP = Arrays.stream(PeonPhase.values())
.collect(Collectors.toMap(
PeonPhase::getPhase,
Function.identity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ public Duration getShutdownTimeout()
public Duration getRepartitionTransitionDuration()
{
// just return a default for now.
return SeekableStreamSupervisorTuningConfig.defaultDuration(null, DEFAULT_REPARTITION_TRANSITION_DURATION);
return SeekableStreamSupervisorTuningConfig.defaultDuration(
null,
SeekableStreamSupervisorTuningConfig.DEFAULT_REPARTITION_TRANSITION_DURATION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public static HllSketchHolder fromObj(Object obj)
if (obj instanceof HllSketchHolder) {
return (HllSketchHolder) obj;
} else if (obj instanceof HllSketch) {
return of((HllSketch) obj);
return HllSketchHolder.of((HllSketch) obj);
} else if (obj instanceof Union) {
return of((Union) obj);
return HllSketchHolder.of((Union) obj);
} else if (obj instanceof byte[]) {
return of(HllSketch.heapify((byte[]) obj));
return HllSketchHolder.of(HllSketch.heapify((byte[]) obj));
} else if (obj instanceof Memory) {
return of(HllSketch.wrap((Memory) obj));
return HllSketchHolder.of(HllSketch.wrap((Memory) obj));
} else if (obj instanceof String) {
return of(HllSketch.heapify(StringUtils.decodeBase64(StringUtils.toUtf8((String) obj))));
return HllSketchHolder.of(HllSketch.heapify(StringUtils.decodeBase64(StringUtils.toUtf8((String) obj))));
}

throw new ISE("Object is not of a type[%s] that can be deserialized to sketch.", obj.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public class SketchHolder
{
public static final SketchHolder EMPTY = of(
public static final SketchHolder EMPTY = SketchHolder.of(
Sketches.updateSketchBuilder()
.build()
.compact(true, null)
Expand Down Expand Up @@ -195,7 +195,7 @@ public static SketchHolder combine(Object o1, Object o2, int nomEntries)
Union union = (Union) SetOperation.builder().setNominalEntries(nomEntries).build(Family.UNION);
holder1.updateUnion(union);
holder2.updateUnion(union);
return of(union);
return SketchHolder.of(union);
}
}

Expand All @@ -208,15 +208,15 @@ void invalidateCache()
public static SketchHolder deserialize(Object serializedSketch)
{
if (serializedSketch instanceof String) {
return of(deserializeFromBase64EncodedString((String) serializedSketch));
return SketchHolder.of(deserializeFromBase64EncodedString((String) serializedSketch));
} else if (serializedSketch instanceof byte[]) {
return of(deserializeFromByteArray((byte[]) serializedSketch));
return SketchHolder.of(deserializeFromByteArray((byte[]) serializedSketch));
} else if (serializedSketch instanceof SketchHolder) {
return (SketchHolder) serializedSketch;
} else if (serializedSketch instanceof Sketch
|| serializedSketch instanceof Union
|| serializedSketch instanceof Memory) {
return of(serializedSketch);
return SketchHolder.of(serializedSketch);
}

throw new ISE(
Expand All @@ -228,9 +228,9 @@ public static SketchHolder deserialize(Object serializedSketch)
public static SketchHolder deserializeSafe(Object serializedSketch)
{
if (serializedSketch instanceof String) {
return of(deserializeFromBase64EncodedStringSafe((String) serializedSketch));
return SketchHolder.of(deserializeFromBase64EncodedStringSafe((String) serializedSketch));
} else if (serializedSketch instanceof byte[]) {
return of(deserializeFromByteArraySafe((byte[]) serializedSketch));
return SketchHolder.of(deserializeFromByteArraySafe((byte[]) serializedSketch));
}

return deserialize(serializedSketch);
Expand Down Expand Up @@ -285,13 +285,13 @@ public static SketchHolder sketchSetOperation(Func func, int sketchSize, Object.
for (Object o : holders) {
((SketchHolder) o).updateUnion(union);
}
return of(union);
return SketchHolder.of(union);
case INTERSECT:
Intersection intersection = (Intersection) SetOperation.builder().setNominalEntries(sketchSize).build(Family.INTERSECTION);
for (Object o : holders) {
intersection.intersect(((SketchHolder) o).getSketch());
}
return of(intersection.getResult(false, null));
return SketchHolder.of(intersection.getResult(false, null));
case NOT:
if (holders.length < 1) {
throw new IllegalArgumentException("A-Not-B requires at least 1 sketch");
Expand All @@ -306,7 +306,7 @@ public static SketchHolder sketchSetOperation(Func func, int sketchSize, Object.
AnotB anotb = (AnotB) SetOperation.builder().setNominalEntries(sketchSize).build(Family.A_NOT_B);
result = anotb.aNotB(result, ((SketchHolder) holders[i]).getSketch());
}
return of(result);
return SketchHolder.of(result);
default:
throw new IllegalArgumentException("Unknown sketch operation " + func);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static Map<String, BasicAuthorizerUser> deserializeAuthorizerUserMap(
userMap = new HashMap<>();
} else {
try {
userMap = objectMapper.readValue(userMapBytes, AUTHORIZER_USER_MAP_TYPE_REFERENCE);
userMap = objectMapper.readValue(userMapBytes, BasicAuthUtils.AUTHORIZER_USER_MAP_TYPE_REFERENCE);
}
catch (IOException ioe) {
throw new RuntimeException("Couldn't deserialize authorizer userMap!", ioe);
Expand Down Expand Up @@ -189,7 +189,7 @@ public static Map<String, BasicAuthorizerGroupMapping> deserializeAuthorizerGrou
groupMappingMap = new HashMap<>();
} else {
try {
groupMappingMap = objectMapper.readValue(groupMappingMapBytes, AUTHORIZER_GROUP_MAPPING_MAP_TYPE_REFERENCE);
groupMappingMap = objectMapper.readValue(groupMappingMapBytes, BasicAuthUtils.AUTHORIZER_GROUP_MAPPING_MAP_TYPE_REFERENCE);
}
catch (IOException ioe) {
throw new RuntimeException("Couldn't deserialize authorizer groupMappingMap!", ioe);
Expand Down Expand Up @@ -218,7 +218,7 @@ public static Map<String, BasicAuthorizerRole> deserializeAuthorizerRoleMap(
roleMap = new HashMap<>();
} else {
try {
roleMap = objectMapper.readValue(roleMapBytes, AUTHORIZER_ROLE_MAP_TYPE_REFERENCE);
roleMap = objectMapper.readValue(roleMapBytes, BasicAuthUtils.AUTHORIZER_ROLE_MAP_TYPE_REFERENCE);
}
catch (IOException ioe) {
throw new RuntimeException("Couldn't deserialize authorizer roleMap!", ioe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public CatalogException(
public static CatalogException badRequest(String msg, Object...args)
{
return new CatalogException(
INVALID_ERROR,
CatalogException.INVALID_ERROR,
Response.Status.BAD_REQUEST,
msg,
args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public List<? extends Module> getJacksonModules()
{
return Collections.singletonList(
new SimpleModule().registerSubtypes(
new NamedType(HdfsLoadSpec.class, SCHEME),
new NamedType(HdfsInputSource.class, SCHEME),
new NamedType(HdfsInputSourceFactory.class, SCHEME)
new NamedType(HdfsLoadSpec.class, HdfsStorageDruidModule.SCHEME),
new NamedType(HdfsInputSource.class, HdfsStorageDruidModule.SCHEME),
new NamedType(HdfsInputSourceFactory.class, HdfsStorageDruidModule.SCHEME)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Duration getRepartitionTransitionDuration()
// just return a default for now.
return SeekableStreamSupervisorTuningConfig.defaultDuration(
null,
DEFAULT_REPARTITION_TRANSITION_DURATION
SeekableStreamSupervisorTuningConfig.DEFAULT_REPARTITION_TRANSITION_DURATION
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public boolean hasNext() throws SocketTimeoutException
try {
while (watch.hasNext()) {
Watch.Response<V1Pod> item = watch.next();
if (item != null && item.type != null && !BOOKMARK.equals(item.type)) {
if (item != null && item.type != null && !item.type.equals(WatchResult.BOOKMARK)) {
DiscoveryDruidNodeAndResourceVersion result = null;
if (item.object != null) {
result = new DiscoveryDruidNodeAndResourceVersion(
Expand All @@ -150,7 +150,7 @@ public boolean hasNext() throws SocketTimeoutException
result
);
return true;
} else if (item != null && item.type != null && BOOKMARK.equals(item.type)) {
} else if (item != null && item.type != null && item.type.equals(WatchResult.BOOKMARK)) {
// Events with type BOOKMARK will only contain resourceVersion and no metadata. See
// Kubernetes API documentation for details.
LOGGER.debug("BOOKMARK event fired, no nothing, only update resourceVersion");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public static String getLabelSelectorForNodeRole(K8sDiscoveryConfig discoveryCon
"%s=%s,%s=%s",
getClusterIdentifierAnnouncementLabel(),
discoveryConfig.getClusterIdentifier(),
getRoleAnnouncementLabel(nodeRole),
ANNOUNCEMENT_DONE
K8sDruidNodeAnnouncer.getRoleAnnouncementLabel(nodeRole),
K8sDruidNodeAnnouncer.ANNOUNCEMENT_DONE
);
}

Expand All @@ -219,9 +219,9 @@ public static String getLabelSelectorForNode(K8sDiscoveryConfig discoveryConfig,
"%s=%s,%s=%s,%s=%s",
getClusterIdentifierAnnouncementLabel(),
discoveryConfig.getClusterIdentifier(),
getRoleAnnouncementLabel(nodeRole),
ANNOUNCEMENT_DONE,
getIdHashAnnouncementLabel(),
K8sDruidNodeAnnouncer.getRoleAnnouncementLabel(nodeRole),
K8sDruidNodeAnnouncer.ANNOUNCEMENT_DONE,
K8sDruidNodeAnnouncer.getIdHashAnnouncementLabel(),
hashEncodeStringForLabelValue(node.getHostAndPortToUse())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private static AppenderatorConfig makeAppenderatorConfig(
@Override
public AppendableIndexSpec getAppendableIndexSpec()
{
return DEFAULT_APPENDABLE_INDEX;
return TuningConfig.DEFAULT_APPENDABLE_INDEX;
}

@Override
Expand Down Expand Up @@ -346,7 +346,7 @@ public int getMaxPendingPersists()
@Override
public boolean isSkipBytesInMemoryOverheadCheck()
{
return DEFAULT_SKIP_BYTES_IN_MEMORY_OVERHEAD_CHECK;
return TuningConfig.DEFAULT_SKIP_BYTES_IN_MEMORY_OVERHEAD_CHECK;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static ClusterBy clusterByWithSegmentGranularity(
return clusterBy;
} else {
final List<KeyColumn> newColumns = new ArrayList<>(clusterBy.getColumns().size() + 1);
newColumns.add(new KeyColumn(SEGMENT_GRANULARITY_COLUMN, KeyOrder.ASCENDING));
newColumns.add(new KeyColumn(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN, KeyOrder.ASCENDING));
newColumns.addAll(clusterBy.getColumns());
return new ClusterBy(newColumns, 1);
}
Expand All @@ -123,10 +123,10 @@ public static ClusterBy clusterByWithSegmentGranularity(
*/
public static void verifyRowSignature(final RowSignature signature)
{
if (signature.contains(PARTITION_BOOST_COLUMN)) {
throw new MSQException(new ColumnNameRestrictedFault(PARTITION_BOOST_COLUMN));
} else if (signature.contains(SEGMENT_GRANULARITY_COLUMN)) {
throw new MSQException(new ColumnNameRestrictedFault(SEGMENT_GRANULARITY_COLUMN));
if (signature.contains(QueryKitUtils.PARTITION_BOOST_COLUMN)) {
throw new MSQException(new ColumnNameRestrictedFault(QueryKitUtils.PARTITION_BOOST_COLUMN));
} else if (signature.contains(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN)) {
throw new MSQException(new ColumnNameRestrictedFault(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN));
}
}

Expand All @@ -144,7 +144,7 @@ public static RowSignature signatureWithSegmentGranularity(
} else {
return RowSignature.builder()
.addAll(signature)
.add(SEGMENT_GRANULARITY_COLUMN, ColumnType.LONG)
.add(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN, ColumnType.LONG)
.build();
}
}
Expand Down Expand Up @@ -194,8 +194,8 @@ public static RowSignature sortableSignature(
public static VirtualColumn makeSegmentGranularityVirtualColumn(final ObjectMapper jsonMapper, final QueryContext queryContext)
{
final Granularity segmentGranularity =
getSegmentGranularityFromContext(jsonMapper, queryContext.asMap());
final String timeColumnName = queryContext.getString(CTX_TIME_COLUMN_NAME);
QueryKitUtils.getSegmentGranularityFromContext(jsonMapper, queryContext.asMap());
final String timeColumnName = queryContext.getString(QueryKitUtils.CTX_TIME_COLUMN_NAME);

if (timeColumnName == null || Granularities.ALL.equals(segmentGranularity)) {
return null;
Expand All @@ -213,7 +213,7 @@ public static VirtualColumn makeSegmentGranularityVirtualColumn(final ObjectMapp
}

return new ExpressionVirtualColumn(
SEGMENT_GRANULARITY_COLUMN,
QueryKitUtils.SEGMENT_GRANULARITY_COLUMN,
StringUtils.format(
"timestamp_floor(%s, %s)",
CalciteSqlDialect.DEFAULT.quoteIdentifier(timeColumnName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum MSQMode
@Nullable
public static MSQMode fromString(String str)
{
for (MSQMode msqMode : values()) {
for (MSQMode msqMode : MSQMode.values()) {
if (msqMode.value.equalsIgnoreCase(str)) {
return msqMode;
}
Expand All @@ -66,12 +66,12 @@ public String toString()

public static void populateDefaultQueryContext(final String modeStr, final Map<String, Object> originalQueryContext)
{
MSQMode mode = fromString(modeStr);
MSQMode mode = MSQMode.fromString(modeStr);
if (mode == null) {
throw new ISE(
"%s is an unknown multi stage query mode. Acceptable modes: %s",
modeStr,
Arrays.stream(values()).map(m -> m.value).collect(Collectors.toList())
Arrays.stream(MSQMode.values()).map(m -> m.value).collect(Collectors.toList())
);
}
log.debug("Populating default query context with %s for the %s multi stage query mode", mode.defaultQueryContext, mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public static void deleteBucketKeys(
log.debug("Deleting keys from bucket: [%s], keys: [%s]", bucket, keys);
}
DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(bucket).withKeys(keysToDelete);
retryS3Operation(() -> {
S3Utils.retryS3Operation(() -> {
s3Client.deleteObjects(deleteRequest);
return null;
}, retries);
Expand All @@ -353,7 +353,7 @@ static void uploadFileIfPossible(
final PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, file);

if (!disableAcl) {
putObjectRequest.setAccessControlList(grantFullControlToBucketOwner(service, bucket));
putObjectRequest.setAccessControlList(S3Utils.grantFullControlToBucketOwner(service, bucket));
}
log.info("Pushing [%s] to bucket[%s] and key[%s].", file, bucket, key);
service.putObject(putObjectRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ public void close(TaskAttemptContext context)
@Override
public void checkOutputSpecs(JobContext job) throws IOException
{
Path outDir = getOutputPath(job);
Path outDir = FileOutputFormat.getOutputPath(job);
if (outDir == null) {
throw new InvalidJobConfException("Output directory not set.");
}
Expand Down
Loading

0 comments on commit 6fad11f

Please sign in to comment.