Skip to content

Commit

Permalink
Added Encoded Logic to Factory and getPartitionName
Browse files Browse the repository at this point in the history
{"fundingSource": "41203", "team": "FED.ICGSA.APPS.FUSION.ARCH", "fshGit": "a4f7446b", "fshDocker": "sha256:054bce20"}
  • Loading branch information
Devin Gundry committed Feb 3, 2025
1 parent e7c91bd commit df0c718
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ case class AttributeScheme(attribute: String, index: Int, binding: Class[_], def

override def getPartitionName(feature: SimpleFeature): String = {
val value = feature.getAttribute(index)
if (value == null) {
defaultPartition
} else if (allowedValues.nonEmpty) {
if (allowedValues.contains(value)) {
AttributeIndexKey.typeEncode(value)
} else {
defaultPartition
}
} else {
AttributeIndexKey.typeEncode(value)
if (value == null)
return defaultPartition
val encodedValue = AttributeIndexKey.typeEncode(value)
if (allowedValues.nonEmpty) {
if (allowedValues.contains(value))
return encodedValue
return defaultPartition
}
encodedValue
}

override def getSimplifiedFilters(filter: Filter, partition: Option[String]): Option[Seq[SimplifiedFilter]] = {
Expand Down Expand Up @@ -115,8 +113,8 @@ object AttributeScheme {
val binding = sft.getDescriptor(index).getType.getBinding
require(AttributeIndexKey.encodable(binding),
s"Invalid type binding '${binding.getName}' of attribute '$attribute'")
val allowedValues: Seq[String] = config.options.get(Config.AllowedListOpt).map(_.split(',').toSeq).getOrElse(Seq.empty)
val defaultPartition = config.options.getOrElse(Config.DefaultPartitionOpt, if (allowedValues.nonEmpty) allowedValues.head else "")
val allowedValues: Seq[String] = config.options.get(Config.AllowedListOpt).map(_.split(',').toSeq).getOrElse(Seq.empty).map(AttributeIndexKey.encodeForQuery(_,binding))
val defaultPartition = config.options.getOrElse(Config.DefaultPartitionOpt, AttributeIndexKey.encodeForQuery(if (allowedValues.nonEmpty) allowedValues.head else "", binding))
Some(AttributeScheme(attribute, index, binding, defaultPartition, allowedValues))
}
}
Expand Down

0 comments on commit df0c718

Please sign in to comment.