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

remove unnecessary calls to toList() #37540

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ internal constructor(
) {
val currentThread = Thread.currentThread()

val runningThreads = ThreadUtils.getAllThreads().filter(::filterOrphanedThread).toList()
val runningThreads = ThreadUtils.getAllThreads().filter(::filterOrphanedThread)
if (runningThreads.isNotEmpty()) {
LOGGER.warn(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ open class StandardNameTransformer : NamingConventionTransformer {
return Jsons.jsonNode<Map<String, JsonNode>>(properties)
} else if (root.isArray) {
return Jsons.jsonNode(
MoreIterators.toList(root.elements())
.map { r: JsonNode -> formatJsonPath(r) }
.toList()
MoreIterators.toList(root.elements()).map { r: JsonNode -> formatJsonPath(r) }
)
} else {
return root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,18 @@ internal constructor(
streamDescriptor,
)
}
return streams
.sortedWith(
Comparator.comparing(
{ s: StreamDescriptor -> sdToQueueSize[s]!!.orElseThrow() },
Comparator.reverseOrder(),
) // if no time is present, it suggests the queue has no records. set MAX time
// as a sentinel value to
// represent no records.
.thenComparing { s: StreamDescriptor ->
sdToTimeOfLastRecord[s]!!.orElse(Instant.MAX)
}
.thenComparing { s: StreamDescriptor -> s.namespace + s.name },
)
.toList()
return streams.sortedWith(
Comparator.comparing(
{ s: StreamDescriptor -> sdToQueueSize[s]!!.orElseThrow() },
Comparator.reverseOrder(),
) // if no time is present, it suggests the queue has no records. set MAX time
// as a sentinel value to
// represent no records.
.thenComparing { s: StreamDescriptor ->
sdToTimeOfLastRecord[s]!!.orElse(Instant.MAX)
}
.thenComparing { s: StreamDescriptor -> s.namespace + s.name },
)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ class GlobalAsyncStateManager(private val memoryManager: GlobalMemoryManager) {
// into the non-STREAM world for correctness.
synchronized(lock) {
aliasIds.addAll(
descToStateIdQ.values
.flatMap { obj: LinkedBlockingDeque<Long> -> obj }
.toList(),
descToStateIdQ.values.flatMap { obj: LinkedBlockingDeque<Long> -> obj },
)
descToStateIdQ.clear()
retroactiveGlobalStateId = StateIdProvider.nextId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ object SentryExceptionHelper {
errorMessageAndType[ErrorMapKeys.ERROR_MAP_MESSAGE_KEY] =
String.format(
"%s",
stacktraceLines[
Arrays.stream(stacktraceLines)
.toList()
.indexOf(followingLine) + 1
]
stacktraceLines[stacktraceLines.indexOf(followingLine) + 1]
.trim { it <= ' ' }
)
errorMessageAndType[ErrorMapKeys.ERROR_MAP_TYPE_KEY] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class InMemoryRecordBufferingStrategy(
stream.name,
streamBuffer[stream]!!.size
)
recordWriter.accept(stream, streamBuffer[stream]!!.toList())
recordWriter.accept(stream, streamBuffer[stream]!!)
LOGGER.info("Flushing completed for {}", stream.name)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ object ConnectorExceptionUtil {
initialMessage: String,
eithers: List<Either<out T, Result>>
): List<Result> {
val throwables: List<T> = eithers.filter { it.isLeft() }.map { it.left!! }.toList()
val throwables: List<T> = eithers.filter { it.isLeft() }.map { it.left!! }
if (throwables.isNotEmpty()) {
logAllAndThrowFirst(initialMessage, throwables)
}
// No need to filter on isRight since isLeft will throw before reaching this line.
return eithers.map { obj: Either<out T, Result> -> obj.right!! }.toList()
return eithers.map { obj: Either<out T, Result> -> obj.right!! }
}

private fun isTransientErrorException(e: Throwable?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class ConcurrentStreamConsumer(
.map { runnable: ConcurrentStreamRunnable ->
CompletableFuture.runAsync(runnable, executorService)
}
.toList()

/*
* Wait for the submitted streams to complete before returning. This uses the join() method to allow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ internal class TestJdbcUtils {
val rs = connection.createStatement().executeQuery("SELECT * FROM id_and_name;")
val actual =
JdbcDatabase.toUnsafeStream(rs) { queryContext: ResultSet ->
sourceOperations.rowToJson(queryContext)
}
.toList()
Assertions.assertEquals(RECORDS_AS_JSON, actual)
sourceOperations.rowToJson(queryContext)
}

Assertions.assertEquals(RECORDS_AS_JSON, actual.toList())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ internal class TestStreamingJdbcDatabase {
// This check assumes that FetchSizeConstants.TARGET_BUFFER_BYTE_SIZE = 200 MB.
// Update this check if the buffer size constant is changed.
Assertions.assertEquals(2, fetchSizes.size)
val sortedSizes = fetchSizes.sorted().toList()
val sortedSizes = fetchSizes.sorted()
Assertions.assertTrue(sortedSizes[0] < FetchSizeConstants.INITIAL_SAMPLE_SIZE)
Assertions.assertEquals(FetchSizeConstants.INITIAL_SAMPLE_SIZE, sortedSizes[1])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,7 @@ class AsyncStreamConsumerTest {
)

// captures the output of all the workers, since our records could come out in any of them.
val actualRecords =
argumentCaptor.allValues
.stream() // flatten those results into a single list for the simplicity of
// comparison
.flatMap { s: Stream<*> -> s }
.toList()
val actualRecords = argumentCaptor.allValues.flatMap { it.toList() }

val expRecords =
allRecords.map { m: AirbyteMessage ->
Expand Down
Loading
Loading