Skip to content

Commit

Permalink
deleted cashed FullPath concept
Browse files Browse the repository at this point in the history
  • Loading branch information
googley42 committed Sep 26, 2023
1 parent 79626ba commit 94881ea
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 110 deletions.
7 changes: 2 additions & 5 deletions dynamodb/src/main/scala/zio/dynamodb/AliasMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ private[dynamodb] final case class AliasMap private[dynamodb] (map: Map[AliasMap
case ProjectionExpression.MapElement(ProjectionExpression.Root, found) =>
val name = stripLeadingAndTrailingBackticks(found)
val nameAlias = s"#n${acc._1.index}"
val mapTmp = acc._1.map + ((AliasMap.PathSegment(ProjectionExpression.Root, name), nameAlias))
val map = acc._1.map + ((AliasMap.PathSegment(ProjectionExpression.Root, name), nameAlias))
val xs = acc._2 :+ nameAlias
val map = mapTmp + ((AliasMap.FullPath(entry), xs.reverse.mkString)) // cache final result
val t = (AliasMap(map, acc._1.index + 1), xs)
val t2 = // do not overwite an existing alias
val t2 = // do not overwite an existing alias
if (acc._1.map.get(AliasMap.PathSegment(ProjectionExpression.Root, name)).isDefined)
acc
else
Expand Down Expand Up @@ -71,8 +70,6 @@ private[dynamodb] object AliasMap {
final case class AttributeValueKey(av: AttributeValue) extends Key
// we include parent to disambiguate PathSegment as a Map key for cases where the same segment name is used multiple times
final case class PathSegment[From, To](parent: ProjectionExpression[From, To], segment: String) extends Key
// used to cache the final substituted path
final case class FullPath[From, To](path: ProjectionExpression[From, To]) extends Key

def empty: AliasMap = AliasMap(Map.empty, 0)
}
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ case object DynamoDBExecutorImpl {
awsAttributeValue(attrVal).map(a => (ZIOAwsExpressionAttributeValueVariable(str), a))
case (AliasMap.PathSegment(_, _), _) =>
None
case (AliasMap.FullPath(_), _) =>
None
}
if (map.isEmpty) None else Some(map)
}
Expand All @@ -616,8 +614,6 @@ case object DynamoDBExecutorImpl {
val map = aliasMap.map.flatMap {
case (AliasMap.AttributeValueKey(_), _) =>
None
case (AliasMap.FullPath(_), _) =>
None
case (AliasMap.PathSegment(_, segment), str) =>
Some((ExpressionAttributeNameVariable(str), ZIOAwsAttributeName(segment)))
}
Expand Down
Loading

0 comments on commit 94881ea

Please sign in to comment.