Skip to content

Commit 4ee5d4f

Browse files
committed
Small optimizations
1 parent c2af4d5 commit 4ee5d4f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/integrationTest/java/org/radarbase/output/RestructureS3IntegrationTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,15 @@ class RestructureS3IntegrationTest {
100100
assertEquals(csvContents, targetContent.toString(UTF_8))
101101
}
102102

103-
withContext(Dispatchers.IO) {
103+
return@coroutineScope withContext(Dispatchers.IO) {
104104
targetClient.listObjects(
105105
ListObjectsArgs.Builder().bucketBuild(targetConfig.bucket) {
106106
prefix("output")
107107
recursive(true)
108108
useUrlEncodingType(false)
109109
}
110110
)
111-
.map { it.get().objectName() }
112-
.toHashSet()
111+
.mapTo(HashSet()) { it.get().objectName() }
113112
}
114113
}
115114

src/main/java/org/radarbase/output/format/CsvAvroConverterFactory.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ class CsvAvroConverterFactory : RecordConverterFactory {
3838
if (header == null) return false
3939
val fields = fieldIndexes(header, distinctFields, ignoreFields)
4040
var count = 0
41-
val lineMap = lines
42-
.onEach { count += 1 }
43-
.mapIndexed { idx, line -> Pair(ArrayWrapper(line.byIndex(fields)), idx) }
44-
.toMap(HashMap())
41+
val lineMap = buildMap {
42+
lines.forEachIndexed { idx, line ->
43+
count += 1
44+
put(ArrayWrapper(line.byIndex(fields)), idx)
45+
}
46+
}
4547

4648
if (lineMap.size == count) {
4749
logger.debug("File {} is already deduplicated. Skipping.", fileName)

src/main/java/org/radarbase/output/path/PathFormatter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class PathFormatter(
2929
init {
3030
val foundParameters = "\\$\\{([^}]*)}".toRegex()
3131
.findAll(format)
32-
.map { it.groupValues[1] }
33-
.toSet()
32+
.mapTo(HashSet()) { it.groupValues[1] }
3433

3534
parameterLookups = buildMap {
3635
plugins.forEach { plugin ->

0 commit comments

Comments
 (0)