Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor bad smell ToArrayCallWithZeroLengthArrayArgument #1580

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean next(List<Cell> results) throws IOException {
boolean next = super.next(dataTableResults);
addMutations(dataTableResults);
if (ServerUtil.readyToCommit(mutationList.size(), mutationList.byteSize(), maxBatchSize, maxBatchSizeBytes)||!next) {
region.batchMutate(mutationList.toArray(new Mutation[mutationList.size()]));
region.batchMutate(mutationList.toArray(new Mutation[0]));
mutationList.clear();
}
return next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void prepareExpectedIndexMutations(Result dataRow, Map<byte[], List<Mutat

protected void commitBatch(List<Mutation> indexUpdates) throws IOException, InterruptedException {
ungroupedAggregateRegionObserver.checkForRegionClosingOrSplitting();
region.batchMutate(indexUpdates.toArray(new Mutation[indexUpdates.size()]));
region.batchMutate(indexUpdates.toArray(new Mutation[0]));
}

protected void repairIndexRows(Map<byte[], List<Mutation>> indexMutationMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public InListExpression(List<Expression> keyExpressions, boolean rowKeyOrderOpti
}
this.fixedWidth = isFixedLength ? fixedWidth : -1;
// Sort values by byte value so we can get min/max easily
ImmutableBytesPtr[] valuesArray = values.toArray(new ImmutableBytesPtr[values.size()]);
ImmutableBytesPtr[] valuesArray = values.toArray(new ImmutableBytesPtr[0]);
Arrays.sort(valuesArray, ByteUtil.BYTES_PTR_COMPARATOR);
if (values.isEmpty()) {
this.minValue = ByteUtil.EMPTY_BYTE_ARRAY_PTR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static Aggregator[] getAggregators(List<SingleAggregateFunction> aggFunc
}

public ClientAggregators(List<SingleAggregateFunction> functions, int minNullableIndex) {
super(functions.toArray(new SingleAggregateFunction[functions.size()]), getAggregators(functions), minNullableIndex);
super(functions.toArray(new SingleAggregateFunction[0]), getAggregators(functions), minNullableIndex);
this.tempValueSet = ValueBitSet.newInstance(schema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public void preBatchMutateWithExceptions(ObserverContext<RegionCoprocessorEnviro
}
if (!localUpdates.isEmpty()) {
miniBatchOp.addOperationsFromCP(0,
localUpdates.toArray(new Mutation[localUpdates.size()]));
localUpdates.toArray(new Mutation[0]));
}
if (!indexUpdates.isEmpty()) {
context.indexUpdates = indexUpdates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void preBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c,
}
if (!localUpdates.isEmpty()) {
miniBatchOp.addOperationsFromCP(0,
localUpdates.toArray(new Mutation[localUpdates.size()]));
localUpdates.toArray(new Mutation[0]));
}
if (!indexUpdates.isEmpty()) {
context.indexUpdates = indexUpdates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public int compare(PDataType o1, PDataType o2) {
for (PDataType t : types) {
classToInstance.put(t.getClass(), t);
}
orderedTypes = types.toArray(new PDataType[types.size()]);
orderedTypes = types.toArray(new PDataType[0]);
}

public Set<PDataType> getTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private CSVFormat buildFormat() {
break;
case SUPPLIED_BY_USER:
// a populated string array supplied by the user
format = format.withHeader(columns.toArray(new String[columns.size()]));
format = format.withHeader(columns.toArray(new String[0]));
break;
default:
throw new RuntimeException("Header source was unable to be inferred.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ static String[] getAlphabetFromICU(Locale locale) {
if (alphabet.size() > 6) {
// Strip off first and last (which are ...)
List<String> alphabetWithoutEllipses = alphabet.subList(1, alphabet.size() - 1);
return alphabetWithoutEllipses.toArray(new String[alphabetWithoutEllipses.size()]);
return alphabetWithoutEllipses.toArray(new String[0]);
} else {
return new String[0];
}
Expand Down