Skip to content

Commit

Permalink
Adds a generic merge method that allows the merger for parameter maps…
Browse files Browse the repository at this point in the history
…, with the parameters defined in an IndexConfig or QueryConfig taking precedence.

Signed-off-by: Ralph Gasser <[email protected]>
  • Loading branch information
ppanopticon committed Aug 8, 2024
1 parent 56444e9 commit fa24157
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.vitrivr.engine.core.model.metamodel

import org.vitrivr.engine.core.context.IndexContext
import org.vitrivr.engine.core.context.QueryContext
import org.vitrivr.engine.core.model.content.Content
import org.vitrivr.engine.core.model.content.element.ContentElement
Expand All @@ -20,6 +21,40 @@ import kotlin.reflect.KClass
* @version 1.4.0
*/
interface Analyser<C : ContentElement<*>, D : Descriptor> : ExtractorFactory<C, D> {


companion object {
/**
* Merges the parameters of a [Schema.Field] with the parameters of the [IndexContext].
*
* @param field The [Schema.Field] to merge parameters for.
* @param context The [IndexContext] to merge parameters with.
* @return Merged parameter map.
*/
fun merge(field: Schema.Field<*, *>, context: IndexContext): Map<String, String> {
val fieldParameters = field.parameters
val contextParameters = context.local[field.fieldName] ?: emptyMap()
val merged = HashMap<String, String>(contextParameters)
merged.putAll(fieldParameters)
return merged
}

/**
* Merges the parameters of a [Schema.Field] with the parameters of the [IndexContext].
*
* @param field The [Schema.Field] to merge parameters for.
* @param context The [QueryContext] to merge parameters with.
* @return Merged parameter map.
*/
fun merge(field: Schema.Field<*, *>, context: QueryContext): Map<String, String> {
val fieldParameters = field.parameters
val contextParameters = context.local[field.fieldName] ?: emptyMap()
val merged = HashMap<String, String>(contextParameters)
merged.putAll(fieldParameters)
return merged
}
}

/** The [KClass]es of the [ContentElement] accepted by this [Analyser]. */
val contentClasses: Set<KClass<out ContentElement<*>>>

Expand Down

0 comments on commit fa24157

Please sign in to comment.