Skip to content

Commit

Permalink
Fixed type erosion when adding properties to retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaro committed Dec 11, 2023
1 parent 7aa78fc commit bbb7c96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private val logger: KLogger = KotlinLogging.logger {}
internal class RetrievableReader(private val connection: CottontailConnection) : RetrievableReader {
/** The [Name.EntityName] for this [RetrievableInitializer]. */
private val entityName: Name.EntityName =
Name.EntityName(this.connection.schemaName, CottontailConnection.RETRIEVABLE_ENTITY_NAME)
Name.EntityName.create(this.connection.schemaName, CottontailConnection.RETRIEVABLE_ENTITY_NAME)

/** The [Name.EntityName] of the relationship entity. */
private val relationshipEntityName: Name.EntityName =
Name.EntityName(this.connection.schemaName, CottontailConnection.RELATIONSHIP_ENTITY_NAME)
Name.EntityName.create(this.connection.schemaName, CottontailConnection.RELATIONSHIP_ENTITY_NAME)

/**
* Returns the [Retrievable]s that matches the provided [RetrievableId]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ private val logger: KLogger = KotlinLogging.logger {}
internal class RetrievableWriter(private val connection: CottontailConnection) : RetrievableWriter {

/** The [Name.EntityName] of the retrievable entity. */
private val entityName: Name.EntityName = Name.EntityName(this.connection.schemaName, CottontailConnection.RETRIEVABLE_ENTITY_NAME)
private val entityName: Name.EntityName = Name.EntityName.create(this.connection.schemaName, CottontailConnection.RETRIEVABLE_ENTITY_NAME)

/** The [Name.EntityName] of the relationship entity. */
private val relationshipEntityName: Name.EntityName = Name.EntityName(this.connection.schemaName, CottontailConnection.RELATIONSHIP_ENTITY_NAME)
private val relationshipEntityName: Name.EntityName = Name.EntityName.create(this.connection.schemaName, CottontailConnection.RELATIONSHIP_ENTITY_NAME)

/**
* Adds a new [Retrievable] to the database using this [RetrievableWriter] instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ interface Retrieved : Retrievable {

fun PlusProperties(retrieved: Retrieved, properties: Map<String, String> = mutableMapOf()) = when(retrieved) {
is RetrievedWithProperties -> retrieved
is ScorePlusRelationship -> ScorePlusRelationshipPlusProperties(retrieved, properties)


//TODO other combinations

Expand All @@ -132,11 +134,16 @@ interface Retrieved : Retrievable {
override val relationships: Set<Relationship> = mutableSetOf()
) : Retrieved by retrieved, RetrievedWithRelationship

class ScorePlusRelationship(
open class ScorePlusRelationship(
retrieved: RetrievedWithScore,
override val relationships: Set<Relationship> = mutableSetOf()
) : RetrievedWithScore by retrieved, RetrievedWithRelationship

class ScorePlusRelationshipPlusProperties(
retrieved: ScorePlusRelationship,
override val properties: Map<String, String> = mutableMapOf()
) : ScorePlusRelationship(retrieved, retrieved.relationships), RetrievedWithProperties

class RetrievedPlusProperties(
retrieved: Retrieved,
override val properties: Map<String, String> = mutableMapOf()
Expand Down

0 comments on commit bbb7c96

Please sign in to comment.