Skip to content

Commit

Permalink
Prefer isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Jun 7, 2024
1 parent 8f87849 commit 5920537
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3769,7 +3769,7 @@ public void dropConstraint(ConnectorSession session, ConnectorTableHandle tableH
.orElse("")
.equals(columnName.get()))
.collect(toImmutableList());
if (notNullConstraints.size() == 0 || !notNullConstraints.get(0).getName().isPresent()) {
if (notNullConstraints.isEmpty() || !notNullConstraints.get(0).getName().isPresent()) {
throw new PrestoException(NOT_FOUND, format("Not Null constraint not found on column %s", columnName.get()));
}
constraintToDrop = notNullConstraints.get(0).getName().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static boolean areColumnsEquivalent(List<HiveColumnHandle> projectedColu
Set<String> projectedColumnNames = projectedColumns.stream().map(HiveColumnHandle::getName).collect(toImmutableSet());
Set<String> schemaColumnNames;
String columnNameProperty = schema.getProperty(LIST_COLUMNS);
if (columnNameProperty.length() == 0) {
if (columnNameProperty.isEmpty()) {
schemaColumnNames = ImmutableSet.of();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public AsyncQueue(int targetQueueSize, Executor executor)
*/
public synchronized boolean isFinished()
{
return finishing && borrowerCount == 0 && elements.size() == 0;
return finishing && borrowerCount == 0 && elements.isEmpty();
}

public synchronized void finish()
Expand All @@ -83,7 +83,7 @@ public synchronized void finish()
private synchronized void signalIfFinishing()
{
if (finishing && borrowerCount == 0) {
if (elements.size() == 0) {
if (elements.isEmpty()) {
// Reset elements queue after finishing to avoid holding on to the full sized empty array inside
elements = new ArrayDeque<>(0);
completeAsync(executor, notEmptySignal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected String getCreateTableStatement(String tableName, List<String> properti
" comment varchar(152), " +
" nationkey bigint, " +
" regionkey bigint) " +
(propertiesEntries.size() < 1 ? "" : propertiesEntries
(propertiesEntries.isEmpty() ? "" : propertiesEntries
.stream()
.collect(joining(",", "WITH (", ")"))),
tableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ private void testCachingDirectoryLister(CachingDirectoryLister cachingDirectoryL
assertEquals(future.get().size(), TEST_FILES.size());
}

if (fileStatusCacheTables.length() == 0) {
if (fileStatusCacheTables.isEmpty()) {
assertEquals(cachingDirectoryLister.getRequestCount(), 0);
assertEquals(cachingDirectoryLister.getHitCount(), 0);
assertEquals(cachingDirectoryLister.getMissCount(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private void writeMap(final Object value, final MapObjectInspector inspector, fi

recordConsumer.startGroup();
Map<?, ?> mapValues = inspector.getMap(value);
if (mapValues != null && mapValues.size() > 0) {
if (mapValues != null && !mapValues.isEmpty()) {
recordConsumer.startField(repeatedType.getName(), 0);

Type keyType = repeatedType.getType(0);
Expand Down

0 comments on commit 5920537

Please sign in to comment.