Skip to content

Commit

Permalink
Use Vector instead of List in transform methods: part 2 (#66)
Browse files Browse the repository at this point in the history
In #62 the transform method was improved to avoid the expensive `:::`
operator.  But we were still converting a `List` to a `Vector` for every
single event.  That conversion can be eliminated fairly easily.
  • Loading branch information
istreeter committed Mar 24, 2024
1 parent 2b490df commit f9d74d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object NonAtomicFields {
* details of schemas that were present in the batch but could not be looked up by the Iglu
* resolver.
*/
case class Result(fields: List[TypedTabledEntity], igluFailures: List[ColumnFailure])
case class Result(fields: Vector[TypedTabledEntity], igluFailures: List[ColumnFailure])

/**
* Describes a failure to lookup a series of Iglu schemas
Expand All @@ -51,7 +51,7 @@ object NonAtomicFields {
entities: Map[TabledEntity, Set[SchemaSubVersion]],
filterCriteria: List[SchemaCriterion]
): F[Result] =
entities.toList
entities.toVector
.map { case (tabledEntity, subVersions) =>
// First phase of entity filtering, before we fetch schemas from Iglu and create `TypedTabledEntity`.
// If all sub-versions are filtered out, whole family is removed.
Expand All @@ -78,7 +78,7 @@ object NonAtomicFields {
}
.map { eithers =>
val (failures, good) = eithers.separate
Result(good, failures)
Result(good, failures.toList)
}

private def filterSubVersions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object Transform {
batchInfo: NonAtomicFields.Result
): Either[BadRow, Vector[Caster.NamedValue[A]]] =
failForResolverErrors(processor, event, batchInfo.igluFailures) *>
(forAtomic(caster, event), forEntities(caster, event, batchInfo.fields.toVector))
(forAtomic(caster, event), forEntities(caster, event, batchInfo.fields))
.mapN { case (atomic, nonAtomic) =>
atomic ++ nonAtomic
}
Expand Down

0 comments on commit f9d74d8

Please sign in to comment.