diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQuery.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQuery.java index 6288de644..19b188433 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQuery.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQuery.java @@ -2,11 +2,8 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; import java.util.List; -import kotlin.collections.ArrayDeque; import org.vitrivr.cineast.api.messages.interfaces.MessageType; -import org.vitrivr.cineast.core.config.QueryConfig; import org.vitrivr.cineast.core.db.dao.MetadataAccessSpecification; /** @@ -19,16 +16,6 @@ public class TemporalQuery extends Query { */ private final List queries; - /** - * List of time distances as floats that can be part of this {@link TemporalQuery}. - */ - private final List timeDistances; - - /** - * The max length of the temporal sequences as float that can be part of this {@link TemporalQuery}. - */ - private final Float maxLength; - /** * Provide an empty list to fetch no metadata at all. If the field is not filled (i.e. null), all metadata is provided for backwards-compatibility */ @@ -37,15 +24,11 @@ public class TemporalQuery extends Query { @JsonCreator public TemporalQuery( @JsonProperty(value = "queries", required = true) List queries, - @JsonProperty(value = "config", required = false) QueryConfig config, - @JsonProperty(value = "timeDistances", required = false) List timeDistances, - @JsonProperty(value = "maxLength", required = false) Float maxLength, + @JsonProperty(value = "config", required = false) TemporalQueryConfig config, @JsonProperty(value = "metadataAccessSpec", required = false) List metadataAccessSpec ) { super(config); this.queries = queries; - this.timeDistances = timeDistances == null ? new ArrayList<>() : timeDistances; - this.maxLength = maxLength == null ? Float.MAX_VALUE : maxLength; this.metadataAccessSpec = metadataAccessSpec; } @@ -64,7 +47,7 @@ public List getQueries() { * @return List */ public List getTimeDistances() { - return timeDistances; + return getTemporalQueryConfig().timeDistances; } /** @@ -73,7 +56,11 @@ public List getTimeDistances() { * @return Float */ public Float getMaxLength() { - return maxLength; + return getTemporalQueryConfig().maxLength; + } + + public TemporalQueryConfig getTemporalQueryConfig() { + return (TemporalQueryConfig) this.config; } public List getMetadataAccessSpec() { diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQueryConfig.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQueryConfig.java new file mode 100644 index 000000000..1f338cabb --- /dev/null +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/TemporalQueryConfig.java @@ -0,0 +1,37 @@ +package org.vitrivr.cineast.api.messages.query; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; +import org.vitrivr.cineast.core.config.QueryConfig; + +public class TemporalQueryConfig extends QueryConfig { + + /** + * List of time distances as floats that can be part of this {@link TemporalQuery}. + */ + public final List timeDistances; + + /** + * The max length of the temporal sequences as float that can be part of this {@link TemporalQuery}. + */ + public final Float maxLength; + + /** + * If set explicitly to false, there will be no temporal aggregation for the temporal queries. This is mainly done for testing or evaluation purposes. + */ + public final boolean computeTemporalObjects; + + + public TemporalQueryConfig(@JsonProperty(value = "queryId", required = false) String queryId, + @JsonProperty(value = "hints", required = false) List hints, + @JsonProperty(value = "timeDistances", required = false) List timeDistances, + @JsonProperty(value = "maxLength", required = false) Float maxLength, + @JsonProperty(value = "computeTemporalObjects", required = false) Boolean computeTemporalObjects + ) { + super(queryId, hints); + this.timeDistances = timeDistances == null ? new ArrayList<>() : timeDistances; + this.maxLength = maxLength == null ? Float.MAX_VALUE : maxLength; + this.computeTemporalObjects = computeTemporalObjects == null || computeTemporalObjects; + } +} diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/TemporalQueryMessageHandler.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/TemporalQueryMessageHandler.java index 4afed8c98..862f0cf7f 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/TemporalQueryMessageHandler.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/TemporalQueryMessageHandler.java @@ -212,6 +212,13 @@ public void execute(Session session, QueryConfig qconf, TemporalQuery message, S ssqThread.join(); } + /* You can skip the computation of temporal objects in the config if you wish simply to execute all queries independently (e.g. for evaluation)*/ + if (!message.getTemporalQueryConfig().computeTemporalObjects) { + LOGGER.debug("Not computing temporal objects due to query config"); + finish(metadataRetrievalThreads, cleanupThreads); + return; + } + LOGGER.debug("Starting fusion for temporal context"); long start = System.currentTimeMillis(); /* Retrieve the MediaSegmentDescriptors needed for the temporal scoring retrieval */ @@ -256,6 +263,10 @@ public void execute(Session session, QueryConfig qconf, TemporalQuery message, S futures.forEach(CompletableFuture::join); } + finish(metadataRetrievalThreads, cleanupThreads); + } + + private void finish(List metadataRetrievalThreads, List cleanupThreads) throws InterruptedException { for (Thread cleanupThread : cleanupThreads) { cleanupThread.join(); }