Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codestyle/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ 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);
OssUtils.retry(() -> {
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 = Utils.objToCompressedBigDecimal(obj, strictNumberParse);
CompressedBigDecimal compressedBigDecimal = 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(PeonPhase.values())
private static final Map<String, PeonPhase> PHASE_MAP = Arrays.stream(values())
.collect(Collectors.toMap(
PeonPhase::getPhase,
Function.identity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ public Duration getShutdownTimeout()
public Duration getRepartitionTransitionDuration()
{
// just return a default for now.
return SeekableStreamSupervisorTuningConfig.defaultDuration(
null,
SeekableStreamSupervisorTuningConfig.DEFAULT_REPARTITION_TRANSITION_DURATION);
return SeekableStreamSupervisorTuningConfig.defaultDuration(null, 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 HllSketchHolder.of((HllSketch) obj);
return of((HllSketch) obj);
} else if (obj instanceof Union) {
return HllSketchHolder.of((Union) obj);
return of((Union) obj);
} else if (obj instanceof byte[]) {
return HllSketchHolder.of(HllSketch.heapify((byte[]) obj));
return of(HllSketch.heapify((byte[]) obj));
} else if (obj instanceof Memory) {
return HllSketchHolder.of(HllSketch.wrap((Memory) obj));
return of(HllSketch.wrap((Memory) obj));
} else if (obj instanceof String) {
return HllSketchHolder.of(HllSketch.heapify(StringUtils.decodeBase64(StringUtils.toUtf8((String) obj))));
return 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 = SketchHolder.of(
public static final SketchHolder EMPTY = 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 SketchHolder.of(union);
return of(union);
}
}

Expand All @@ -208,15 +208,15 @@ void invalidateCache()
public static SketchHolder deserialize(Object serializedSketch)
{
if (serializedSketch instanceof String) {
return SketchHolder.of(deserializeFromBase64EncodedString((String) serializedSketch));
return of(deserializeFromBase64EncodedString((String) serializedSketch));
} else if (serializedSketch instanceof byte[]) {
return SketchHolder.of(deserializeFromByteArray((byte[]) serializedSketch));
return of(deserializeFromByteArray((byte[]) serializedSketch));
} else if (serializedSketch instanceof SketchHolder) {
return (SketchHolder) serializedSketch;
} else if (serializedSketch instanceof Sketch
|| serializedSketch instanceof Union
|| serializedSketch instanceof Memory) {
return SketchHolder.of(serializedSketch);
return 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 SketchHolder.of(deserializeFromBase64EncodedStringSafe((String) serializedSketch));
return of(deserializeFromBase64EncodedStringSafe((String) serializedSketch));
} else if (serializedSketch instanceof byte[]) {
return SketchHolder.of(deserializeFromByteArraySafe((byte[]) serializedSketch));
return 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 SketchHolder.of(union);
return of(union);
case INTERSECT:
Intersection intersection = (Intersection) SetOperation.builder().setNominalEntries(sketchSize).build(Family.INTERSECTION);
for (Object o : holders) {
intersection.intersect(((SketchHolder) o).getSketch());
}
return SketchHolder.of(intersection.getResult(false, null));
return 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 SketchHolder.of(result);
return of(result);
default:
throw new IllegalArgumentException("Unknown sketch operation " + func);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static Map<String, BasicAuthorizerUser> deserializeAuthorizerUserMap(
userMap = new HashMap<>();
} else {
try {
userMap = objectMapper.readValue(userMapBytes, BasicAuthUtils.AUTHORIZER_USER_MAP_TYPE_REFERENCE);
userMap = objectMapper.readValue(userMapBytes, AUTHORIZER_USER_MAP_TYPE_REFERENCE);
}
catch (IOException ioe) {
throw new RuntimeException("Couldn't deserialize authorizer userMap!", ioe);
Expand Down Expand Up @@ -201,7 +201,7 @@ public static Map<String, BasicAuthorizerGroupMapping> deserializeAuthorizerGrou
groupMappingMap = new HashMap<>();
} else {
try {
groupMappingMap = objectMapper.readValue(groupMappingMapBytes, BasicAuthUtils.AUTHORIZER_GROUP_MAPPING_MAP_TYPE_REFERENCE);
groupMappingMap = objectMapper.readValue(groupMappingMapBytes, AUTHORIZER_GROUP_MAPPING_MAP_TYPE_REFERENCE);
}
catch (IOException ioe) {
throw new RuntimeException("Couldn't deserialize authorizer groupMappingMap!", ioe);
Expand Down Expand Up @@ -230,7 +230,7 @@ public static Map<String, BasicAuthorizerRole> deserializeAuthorizerRoleMap(
roleMap = new HashMap<>();
} else {
try {
roleMap = objectMapper.readValue(roleMapBytes, BasicAuthUtils.AUTHORIZER_ROLE_MAP_TYPE_REFERENCE);
roleMap = objectMapper.readValue(roleMapBytes, 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(
CatalogException.INVALID_ERROR,
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, HdfsStorageDruidModule.SCHEME),
new NamedType(HdfsInputSource.class, HdfsStorageDruidModule.SCHEME),
new NamedType(HdfsInputSourceFactory.class, HdfsStorageDruidModule.SCHEME)
new NamedType(HdfsLoadSpec.class, SCHEME),
new NamedType(HdfsInputSource.class, SCHEME),
new NamedType(HdfsInputSourceFactory.class, 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,
SeekableStreamSupervisorTuningConfig.DEFAULT_REPARTITION_TRANSITION_DURATION
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 && !item.type.equals(WatchResult.BOOKMARK)) {
if (item != null && item.type != null && !BOOKMARK.equals(item.type)) {
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 && item.type.equals(WatchResult.BOOKMARK)) {
} else if (item != null && item.type != null && BOOKMARK.equals(item.type)) {
// 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(),
K8sDruidNodeAnnouncer.getRoleAnnouncementLabel(nodeRole),
K8sDruidNodeAnnouncer.ANNOUNCEMENT_DONE
getRoleAnnouncementLabel(nodeRole),
ANNOUNCEMENT_DONE
);
}

Expand All @@ -219,9 +219,9 @@ public static String getLabelSelectorForNode(K8sDiscoveryConfig discoveryConfig,
"%s=%s,%s=%s,%s=%s",
getClusterIdentifierAnnouncementLabel(),
discoveryConfig.getClusterIdentifier(),
K8sDruidNodeAnnouncer.getRoleAnnouncementLabel(nodeRole),
K8sDruidNodeAnnouncer.ANNOUNCEMENT_DONE,
K8sDruidNodeAnnouncer.getIdHashAnnouncementLabel(),
getRoleAnnouncementLabel(nodeRole),
ANNOUNCEMENT_DONE,
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 TuningConfig.DEFAULT_APPENDABLE_INDEX;
return DEFAULT_APPENDABLE_INDEX;
}

@Override
Expand Down Expand Up @@ -346,7 +346,7 @@ public int getMaxPendingPersists()
@Override
public boolean isSkipBytesInMemoryOverheadCheck()
{
return TuningConfig.DEFAULT_SKIP_BYTES_IN_MEMORY_OVERHEAD_CHECK;
return 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(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN, KeyOrder.ASCENDING));
newColumns.add(new KeyColumn(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(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));
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));
}
}

Expand All @@ -144,7 +144,7 @@ public static RowSignature signatureWithSegmentGranularity(
} else {
return RowSignature.builder()
.addAll(signature)
.add(QueryKitUtils.SEGMENT_GRANULARITY_COLUMN, ColumnType.LONG)
.add(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 =
QueryKitUtils.getSegmentGranularityFromContext(jsonMapper, queryContext.asMap());
final String timeColumnName = queryContext.getString(QueryKitUtils.CTX_TIME_COLUMN_NAME);
getSegmentGranularityFromContext(jsonMapper, queryContext.asMap());
final String timeColumnName = queryContext.getString(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(
QueryKitUtils.SEGMENT_GRANULARITY_COLUMN,
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 : MSQMode.values()) {
for (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 = MSQMode.fromString(modeStr);
MSQMode mode = fromString(modeStr);
if (mode == null) {
throw new ISE(
"%s is an unknown multi stage query mode. Acceptable modes: %s",
modeStr,
Arrays.stream(MSQMode.values()).map(m -> m.value).collect(Collectors.toList())
Arrays.stream(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);
S3Utils.retryS3Operation(() -> {
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(S3Utils.grantFullControlToBucketOwner(service, bucket));
putObjectRequest.setAccessControlList(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 @@ -958,7 +958,7 @@ public void close(TaskAttemptContext context)
@Override
public void checkOutputSpecs(JobContext job) throws IOException
{
Path outDir = FileOutputFormat.getOutputPath(job);
Path outDir = getOutputPath(job);
if (outDir == null) {
throw new InvalidJobConfException("Output directory not set.");
}
Expand Down
Loading