Skip to content

Commit

Permalink
Cleanup in existing Descriptors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Gasser committed Mar 27, 2024
1 parent 541f2c1 commit 854ffdd
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FileSourceMetadata : Analyser<ContentElement<*>, FileSourceMetadataDescrip
* @param field The [Schema.Field] to create the prototype for.
* @return [FileSourceMetadataDescriptor]
*/
override fun prototype(field: Schema.Field<*, *>) = FileSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), "", 0, true)
override fun prototype(field: Schema.Field<*, *>) = FileSourceMetadataDescriptor.PROTOTYPE

/**
* Generates and returns a new [FileSourceMetadataExtractor] for the provided [Schema.Field].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.vitrivr.engine.core.model.metamodel.Schema
import org.vitrivr.engine.core.model.retrievable.Ingested
import org.vitrivr.engine.core.model.retrievable.Retrievable
import org.vitrivr.engine.core.model.retrievable.attributes.SourceAttribute
import org.vitrivr.engine.core.model.types.Value
import org.vitrivr.engine.core.operators.Operator
import org.vitrivr.engine.core.operators.ingest.Extractor
import org.vitrivr.engine.core.source.file.FileSource
Expand Down Expand Up @@ -44,16 +45,14 @@ class FileSourceMetadataExtractor(
* @return List of resulting [Descriptor]s.
*/
override fun extract(retrievable: Retrievable): List<FileSourceMetadataDescriptor> {
// check(retrievable is RetrievableWithSource) { "Incoming retrievable is not a retrievable with source. This is a programmer's error!" }
// check(retrievable.source is FileSource) { "Incoming retrievable is not a retrievable with file source. This is a programmer's error!" }
val source = retrievable.filteredAttribute(SourceAttribute::class.java)?.source as? FileSource
?: throw IllegalArgumentException("Incoming retrievable is not a retrievable with file source. This is a programmer's error!")
return listOf(
FileSourceMetadataDescriptor(
id = UUID.randomUUID(),
retrievableId = retrievable.id,
path = source.path.absolutePathString(),
size = Files.size(source.path),
path = Value.String(source.path.absolutePathString()),
size = Value.Long(Files.size(source.path)),
transient = !persisting
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.vitrivr.engine.core.model.descriptor.struct.metadata.source.VideoSour
import org.vitrivr.engine.core.model.metamodel.Schema
import org.vitrivr.engine.core.model.retrievable.Retrievable
import org.vitrivr.engine.core.model.retrievable.attributes.SourceAttribute
import org.vitrivr.engine.core.model.types.Value
import org.vitrivr.engine.core.operators.Operator
import org.vitrivr.engine.core.operators.ingest.Extractor
import org.vitrivr.engine.core.source.MediaType
Expand Down Expand Up @@ -48,12 +49,12 @@ class VideoSourceMetadataExtractor(
VideoSourceMetadataDescriptor(
id = UUID.randomUUID(),
retrievableId = retrievable.id,
width = source.width() ?: 0,
height = source.height() ?: 0,
fps = source.fps() ?: 0.0,
channels = source.channels() ?: 0,
sampleRate = source.sampleRate() ?: 0,
sampleSize = source.sampleSize() ?: 0,
width = Value.Int(source.width() ?: 0),
height = Value.Int(source.height() ?: 0),
fps = Value.Double(source.fps() ?: 0.0),
channels = Value.Int(source.channels() ?: 0),
sampleRate = Value.Int(source.sampleRate() ?: 0),
sampleSize = Value.Int(source.sampleSize() ?: 0),
transient = !persisting
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TemporalMetadata : Analyser<ContentElement<*>, TemporalMetadataDescriptor>
* @param field The [Schema.Field] to create the prototype for.
* @return [FloatVectorDescriptor]
*/
override fun prototype(field: Schema.Field<*, *>) = TemporalMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)
override fun prototype(field: Schema.Field<*, *>) = TemporalMetadataDescriptor.PROTOTYPE

/**
* Generates and returns a new [FileSourceMetadataExtractor] for the provided [Schema.Field].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.vitrivr.engine.core.model.metamodel.Schema
import org.vitrivr.engine.core.model.retrievable.Ingested
import org.vitrivr.engine.core.model.retrievable.Retrievable
import org.vitrivr.engine.core.model.retrievable.attributes.ContentAttribute
import org.vitrivr.engine.core.model.types.Value
import org.vitrivr.engine.core.operators.Operator
import org.vitrivr.engine.core.operators.ingest.Extractor
import java.util.*
Expand All @@ -34,8 +35,8 @@ class TemporalMetadataExtractor(input: Operator<Retrievable>, field: Schema.Fiel
val content = retrievable.filteredAttributes(ContentAttribute::class.java).map { it.content }
val descriptors = content.filterIsInstance<TemporalContent>().map { c ->
when (c) {
is TemporalContent.Timepoint -> TemporalMetadataDescriptor(UUID.randomUUID(), retrievable.id, c.timepointNs, c.timepointNs, !persisting)
is TemporalContent.TimeSpan -> TemporalMetadataDescriptor(UUID.randomUUID(), retrievable.id, c.startNs, c.endNs, !persisting)
is TemporalContent.Timepoint -> TemporalMetadataDescriptor(UUID.randomUUID(), retrievable.id, Value.Long(c.timepointNs), Value.Long(c.timepointNs), !persisting)
is TemporalContent.TimeSpan -> TemporalMetadataDescriptor(UUID.randomUUID(), retrievable.id, Value.Long(c.startNs), Value.Long(c.endNs), !persisting)
}
}
return descriptors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.util.*
class MediaDimensions : Analyser<ContentElement<*>, MediaDimensionsDescriptor> {
override val contentClasses = setOf(ContentElement::class)
override val descriptorClass = MediaDimensionsDescriptor::class
override fun prototype(field: Schema.Field<*,*>) = MediaDimensionsDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)
override fun prototype(field: Schema.Field<*,*>) = MediaDimensionsDescriptor.PROTOTYPE
override fun newRetrieverForContent(field: Schema.Field<ContentElement<*>, MediaDimensionsDescriptor>, content: Collection<ContentElement<*>>, context: QueryContext): Retriever<ContentElement<*>, MediaDimensionsDescriptor> {
TODO("Not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.vitrivr.engine.core.model.types.Value
data class SkeletonDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val person: Int,
val person: Value.Int,
val skeleton: List<Value.Float>,
val weights: List<Value.Float>,
override val transient: Boolean = false
Expand All @@ -27,8 +27,8 @@ data class SkeletonDescriptor(
)

override fun values(): List<Pair<String, Any?>> = listOf(
"person" to this.person,
"skeleton" to this.skeleton,
"weights" to this.weights
"person" to this.person,
"skeleton" to this.skeleton,
"weights" to this.weights
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,36 @@ package org.vitrivr.engine.core.model.descriptor.struct.metadata
import org.vitrivr.engine.core.model.descriptor.DescriptorId
import org.vitrivr.engine.core.model.descriptor.FieldSchema
import org.vitrivr.engine.core.model.descriptor.struct.StructDescriptor
import org.vitrivr.engine.core.model.descriptor.struct.metadata.source.FileSourceMetadataDescriptor
import org.vitrivr.engine.core.model.descriptor.struct.metadata.source.VideoSourceMetadataDescriptor
import org.vitrivr.engine.core.model.retrievable.RetrievableId
import org.vitrivr.engine.core.model.types.Type
import org.vitrivr.engine.core.model.types.Value
import java.util.*

/**
* A [StructDescriptor] used to store metadata about a 2D raster graphic.
*
* @author Ralph Gasser
* @version 1.0.0
*/
data class MediaDimensionsDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val width: Int,
val height: Int,
override val transient: Boolean = false
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val width: Value.Int,
val height: Value.Int,
override val transient: Boolean = false
) : StructDescriptor {

companion object {
/** The field schema associated with a [VideoSourceMetadataDescriptor]. */
private val SCHEMA = listOf(
FieldSchema("width", Type.INT),
FieldSchema("height", Type.INT),
)

/** The prototype [MediaDimensionsDescriptor]. */
val PROTOTYPE = MediaDimensionsDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.Int(0), Value.Int(0))
}

/**
Expand All @@ -34,7 +48,7 @@ data class MediaDimensionsDescriptor(
* @return A [Map] of this [MediaDimensionsDescriptor]'s fields (without the IDs).
*/
override fun values(): List<Pair<String, Any?>> = listOf(
"width" to this.width,
"height" to this.height
"width" to this.width,
"height" to this.height
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,39 @@ package org.vitrivr.engine.core.model.descriptor.struct.metadata
import org.vitrivr.engine.core.model.descriptor.DescriptorId
import org.vitrivr.engine.core.model.descriptor.FieldSchema
import org.vitrivr.engine.core.model.descriptor.struct.StructDescriptor
import org.vitrivr.engine.core.model.descriptor.struct.metadata.source.VideoSourceMetadataDescriptor
import org.vitrivr.engine.core.model.retrievable.RetrievableId
import org.vitrivr.engine.core.model.types.Type
import org.vitrivr.engine.core.model.types.Value
import java.util.*

/**
* A [StructDescriptor] used to store temporal metadata.
* A [StructDescriptor] used to store spatial metadata in a 2D raster graphic.
*
* @author Ralph Gasser
* @version 1.0.0
*/
data class Rectangle2DMetadataDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val leftX: Int,
val leftY: Int,
val width: Int,
val height: Int,
val leftX: Value.Int,
val leftY: Value.Int,
val width: Value.Int,
val height: Value.Int,
override val transient: Boolean = false
) : StructDescriptor {

companion object {
/** The field schema associated with a [Rectangle2DMetadataDescriptor]. */
private val SCHEMA = listOf(
FieldSchema("leftX", Type.INT),
FieldSchema("leftY", Type.INT),
FieldSchema("width", Type.INT),
FieldSchema("height", Type.INT),
)

)
/** The prototype [Rectangle2DMetadataDescriptor]. */
val PROTOTYPE = Rectangle2DMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.Int(0), Value.Int(0), Value.Int(0), Value.Int(0))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package org.vitrivr.engine.core.model.descriptor.struct.metadata
import org.vitrivr.engine.core.model.descriptor.DescriptorId
import org.vitrivr.engine.core.model.descriptor.FieldSchema
import org.vitrivr.engine.core.model.descriptor.struct.StructDescriptor
import org.vitrivr.engine.core.model.descriptor.struct.metadata.source.VideoSourceMetadataDescriptor
import org.vitrivr.engine.core.model.retrievable.RetrievableId
import org.vitrivr.engine.core.model.types.Type
import org.vitrivr.engine.core.model.types.Value
import java.util.*

/**
* A [StructDescriptor] used to store temporal metadata.
Expand All @@ -15,16 +18,20 @@ import org.vitrivr.engine.core.model.types.Type
data class TemporalMetadataDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId, //retrievable Id must come first, due to reflection
val startNs: Long,
val endNs: Long,
val startNs: Value.Long,
val endNs: Value.Long,
override val transient: Boolean = false
) : StructDescriptor {

companion object {
/** The field schema associated with a [TemporalMetadataDescriptor]. */
private val SCHEMA = listOf(
FieldSchema("start", Type.LONG),
FieldSchema("end", Type.LONG),
)

/** The prototype [TemporalMetadataDescriptor]. */
val PROTOTYPE = TemporalMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.Long(0L), Value.Long(0L))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.vitrivr.engine.core.model.descriptor.FieldSchema
import org.vitrivr.engine.core.model.descriptor.struct.StructDescriptor
import org.vitrivr.engine.core.model.retrievable.RetrievableId
import org.vitrivr.engine.core.model.types.Type
import org.vitrivr.engine.core.model.types.Value
import java.util.*

/**
* A [StructDescriptor] used to store metadata about a file.
Expand All @@ -15,16 +17,20 @@ import org.vitrivr.engine.core.model.types.Type
data class FileSourceMetadataDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val path: String,
val size: Long,
val path: Value.String,
val size: Value.Long,
override val transient: Boolean = false
) : StructDescriptor {

companion object {
/** The field schema associated with a [FileSourceMetadataDescriptor]. */
private val SCHEMA = listOf(
FieldSchema("path", Type.STRING),
FieldSchema("size", Type.LONG),
)

/** The prototype [FileSourceMetadataDescriptor]. */
val PROTOTYPE = FileSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.String(""), Value.Long(0L))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.vitrivr.engine.core.model.descriptor.FieldSchema
import org.vitrivr.engine.core.model.descriptor.struct.StructDescriptor
import org.vitrivr.engine.core.model.retrievable.RetrievableId
import org.vitrivr.engine.core.model.types.Type
import org.vitrivr.engine.core.model.types.Value
import java.util.*

/**
Expand All @@ -16,12 +17,12 @@ import java.util.*
class VideoSourceMetadataDescriptor(
override val id: DescriptorId,
override val retrievableId: RetrievableId,
val width: Int,
val height: Int,
val fps: Double,
val channels: Int,
val sampleRate: Int,
val sampleSize: Int,
val width: Value.Int,
val height: Value.Int,
val fps: Value.Double,
val channels: Value.Int,
val sampleRate: Value.Int,
val sampleSize: Value.Int,
override val transient: Boolean = false
) : StructDescriptor {

Expand All @@ -37,7 +38,7 @@ class VideoSourceMetadataDescriptor(
)

/** The prototype [VideoSourceMetadataDescriptor]. */
val PROTOTYPE = VideoSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, 0.0, 0, 0, 0)
val PROTOTYPE = VideoSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), Value.Int(0), Value.Int(0), Value.Double(0.0), Value.Int(0), Value.Int(0), Value.Int(0))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SkeletonPose : Analyser<ContentElement<*>, SkeletonDescriptor> {
override fun prototype(field: Schema.Field<*, *>): SkeletonDescriptor = SkeletonDescriptor(
id = java.util.UUID.randomUUID(),
retrievableId = java.util.UUID.randomUUID(),
person = 0,
person = Value.Int(0),
skeleton = List(12) { Value.Float(0.0f) },
weights = List(12) { Value.Float(0.0f) },
transient = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ data class CineastSkeletonPoseFeature(
return SkeletonDescriptor(
id = DescriptorId.randomUUID(),
retrievableId = RetrievableId.fromString(idmap[id]),
person = person,
person = Value.Int(person),
skeleton = skeleton.map { Value.Float(it) },
weights = weights.map { Value.Float(it) },
transient = false
Expand Down Expand Up @@ -332,8 +332,8 @@ class CineastMigrationTool(val migrationconfigpath: String, val schemaconfigpath
val fileMetadataDescriptor = FileSourceMetadataDescriptor(
id = DescriptorId.randomUUID(),
retrievableId = objectRetrievable.id,
path = mobject.path,
size = size,
path = Value.String(mobject.path),
size = Value.Long(size),
)
filemetadatawriter.add(fileMetadataDescriptor)
retrievableWriter.add(objectRetrievable)
Expand Down Expand Up @@ -384,8 +384,8 @@ class CineastMigrationTool(val migrationconfigpath: String, val schemaconfigpath
id = DescriptorId.randomUUID(),
retrievableId = RetrievableId.fromString(retrievableId)
?: throw IllegalArgumentException("Could not find retrievable id for object ${mobjectmetadata.objectid}"),
width = width,
height = height,
width = Value.Int(width),
height = Value.Int(height),
transient = false
)
mediadimensionswriter.add(dimensionsDescriptor)
Expand Down Expand Up @@ -448,8 +448,8 @@ class CineastMigrationTool(val migrationconfigpath: String, val schemaconfigpath
val temporalMetadataDescriptor = TemporalMetadataDescriptor(
id = DescriptorId.randomUUID(),
retrievableId = ingested.id,
startNs = segment.segmentstartabs.toLong() * 1000 * 1000 * 1000,
endNs = segment.segmentendabs.toLong() * 1000 * 1000 * 1000,
startNs = Value.Long(segment.segmentstartabs.toLong() * 1000 * 1000 * 1000),
endNs = Value.Long(segment.segmentendabs.toLong() * 1000 * 1000 * 1000),
)

ingestedList.add(ingested)
Expand Down

0 comments on commit 854ffdd

Please sign in to comment.