diff --git a/build.gradle b/build.gradle index ad149e99c..e065c97df 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ allprojects { group = 'org.vitrivr' /* Our current version */ - version = '3.2.0-SNAPSHOT' + version = '3.3.0' apply plugin: 'java-library' apply plugin: 'maven-publish' diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/CineastQueryService.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/CineastQueryService.java index 979667cc4..a5ddd4b7c 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/CineastQueryService.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/CineastQueryService.java @@ -2,7 +2,6 @@ import io.grpc.stub.StreamObserver; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.time.StopWatch; @@ -13,7 +12,6 @@ import org.vitrivr.cineast.api.grpc.util.MediaObjectUtil; import org.vitrivr.cineast.api.grpc.util.MediaSegmentUtil; import org.vitrivr.cineast.api.grpc.util.QueryContainerUtil; -import org.vitrivr.cineast.api.messages.query.StagedSimilarityQuery; import org.vitrivr.cineast.api.util.QueryUtil; import org.vitrivr.cineast.core.config.QueryConfig; import org.vitrivr.cineast.core.config.ReadableQueryConfig; @@ -22,7 +20,7 @@ import org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor; import org.vitrivr.cineast.core.data.entities.MediaSegmentDescriptor; import org.vitrivr.cineast.core.data.entities.MediaSegmentMetadataDescriptor; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.db.dao.reader.MediaObjectMetadataReader; import org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader; @@ -190,12 +188,11 @@ public void getSimilar(CineastGrpc.TemporalQuery query, StreamObserver categoryThreads = new ArrayList<>(); diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/data/QueryTerm.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/data/QueryTerm.java index 5f0dfd38f..892adaf91 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/data/QueryTerm.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/data/QueryTerm.java @@ -1,7 +1,7 @@ package org.vitrivr.cineast.api.grpc.data; import org.vitrivr.cineast.core.config.ReadableQueryConfig; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import java.util.ArrayList; import java.util.Collection; @@ -9,19 +9,19 @@ public class QueryTerm { - private final QueryContainer container; + private final AbstractQueryTermContainer container; private final ReadableQueryConfig queryConfig; private final float weight; private final List categories = new ArrayList<>(); - public QueryTerm(QueryContainer container, ReadableQueryConfig queryConfig, float weight, Collection categories){ + public QueryTerm(AbstractQueryTermContainer container, ReadableQueryConfig queryConfig, float weight, Collection categories){ this.container = container; this.queryConfig = queryConfig; this.weight = weight; this.categories.addAll(categories); } - public QueryContainer getContainer() { + public AbstractQueryTermContainer getContainer() { return container; } diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/util/QueryContainerUtil.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/util/QueryContainerUtil.java index 651ff9f5f..200e40c56 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/util/QueryContainerUtil.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/grpc/util/QueryContainerUtil.java @@ -35,8 +35,8 @@ public class QueryContainerUtil { private static final Logger LOGGER = LogManager.getLogger(); - public static AudioQueryContainer audioQueryContainer(CineastGrpc.AudioQueryContainer container) { - return new AudioQueryContainer(container.getAudioFramesList().stream().map(QueryContainerUtil::audioFrame).collect(Collectors.toList())); + public static AudioQueryTermContainer audioQueryContainer(CineastGrpc.AudioQueryContainer container) { + return new AudioQueryTermContainer(container.getAudioFramesList().stream().map(QueryContainerUtil::audioFrame).collect(Collectors.toList())); } public static AudioFrame audioFrame(CineastGrpc.AudioFrame frame) { @@ -44,9 +44,9 @@ public static AudioFrame audioFrame(CineastGrpc.AudioFrame frame) { return new AudioFrame(frame.getIdx(), frame.getTimestamp(), frame.getData().toByteArray(), descriptor); } - public static BooleanQueryContainer booleanQueryContainer(CineastGrpc.BooleanQueryContainer container) { + public static BooleanQueryTermContainer booleanQueryContainer(CineastGrpc.BooleanQueryContainer container) { - return new BooleanQueryContainer( + return new BooleanQueryTermContainer( container.getExpressionsList().stream().map(QueryContainerUtil::booleanExpression).collect(Collectors.toList()) ); @@ -94,13 +94,13 @@ public static PrimitiveTypeProvider primitiveTypeProvider(CineastGrpc.PrimitiveT return new NothingProvider(); } - public static IdQueryContainer idQueryContainer(CineastGrpc.IdQueryContainer container) { - return new IdQueryContainer(container.getSegmentId().getId()); + public static IdQueryTermContainer idQueryContainer(CineastGrpc.IdQueryContainer container) { + return new IdQueryTermContainer(container.getSegmentId().getId()); } - public static ImageQueryContainer imageQueryContainer(CineastGrpc.ImageQueryContainer container) { + public static ImageQueryTermContainer imageQueryContainer(CineastGrpc.ImageQueryContainer container) { try { - return new ImageQueryContainer( + return new ImageQueryTermContainer( ImageIO.read(new ByteArrayInputStream(container.getImage().toByteArray())) ); } catch (IOException e) { @@ -109,21 +109,21 @@ public static ImageQueryContainer imageQueryContainer(CineastGrpc.ImageQueryCont return null; } - public static InstantQueryContainer instantQueryContainer(CineastGrpc.InstantQueryContainer container) { - return new InstantQueryContainer(container.getInstant()); + public static InstantQueryTermContainer instantQueryContainer(CineastGrpc.InstantQueryContainer container) { + return new InstantQueryTermContainer(container.getInstant()); } - public static LocationQueryContainer locationQueryContainer(CineastGrpc.LocationQueryContainer container) { - return new LocationQueryContainer(Location.of(container.getLongitude(), container.getLatitude())); + public static LocationQueryTermContainer locationQueryContainer(CineastGrpc.LocationQueryContainer container) { + return new LocationQueryTermContainer(Location.of(container.getLongitude(), container.getLatitude())); } - public static ModelQueryContainer modelQueryContainer(CineastGrpc.ModelQueryContainer container) { + public static ModelQueryTermContainer modelQueryContainer(CineastGrpc.ModelQueryContainer container) { //TODO figure out better mesh representation return null; } - public static MotionQueryContainer motionQueryContainer(CineastGrpc.MotionQueryContainer container) { - MotionQueryContainer motionQueryContainer = new MotionQueryContainer(); + public static MotionQueryTermContainer motionQueryContainer(CineastGrpc.MotionQueryContainer container) { + MotionQueryTermContainer motionQueryContainer = new MotionQueryTermContainer(); container.getBackgroundPathList().stream().forEach(path -> motionQueryContainer.addBgPath(motionPath(path))); container.getForegroundPathList().stream().forEach(path -> motionQueryContainer.addPath(motionPath(path))); return motionQueryContainer; @@ -139,9 +139,9 @@ public static Point2D_F32 point(CineastGrpc.MotionQueryContainer.MotionPath.Poin return new Point2D_F32(point.getX(), point.getY()); } - public static SemanticMapQueryContainer semanticMapQueryContainer(CineastGrpc.SemanticMapQueryContainer container) { + public static SemanticMapQueryTermContainer semanticMapQueryContainer(CineastGrpc.SemanticMapQueryContainer container) { try { - return new SemanticMapQueryContainer(new SemanticMap( + return new SemanticMapQueryTermContainer(new SemanticMap( ImageIO.read(new ByteArrayInputStream(container.getImage().toByteArray())), container.getConceptsMap()) ); @@ -151,16 +151,16 @@ public static SemanticMapQueryContainer semanticMapQueryContainer(CineastGrpc.Se return null; } - public static TagQueryContainer tagQueryContainer(CineastGrpc.TagQueryContainer container) { + public static TagQueryTermContainer tagQueryContainer(CineastGrpc.TagQueryContainer container) { return null; //TODO do we even still need that one? } - public static TextQueryContainer textQueryContainer(CineastGrpc.TextQueryContainer container) { - return new TextQueryContainer(container.getText()); + public static TextQueryTermContainer textQueryContainer(CineastGrpc.TextQueryContainer container) { + return new TextQueryTermContainer(container.getText()); } - public static QueryContainer queryTermContainer(CineastGrpc.QueryTerm term) { + public static AbstractQueryTermContainer queryTermContainer(CineastGrpc.QueryTerm term) { switch(term.getContainerCase()){ case AUDIOQUERYCONTAINER: return audioQueryContainer(term.getAudioQueryContainer()); diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryComponent.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryComponent.java index db3656e6e..53ddcd2cf 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryComponent.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryComponent.java @@ -10,14 +10,14 @@ import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; /** - * The wording is suboptimal. A {@link QueryComponent} has only one containerID, but multiple {@link QueryContainer}s are created out of it. + * The wording is suboptimal. A {@link QueryComponent} has only one containerID, but multiple {@link AbstractQueryTermContainer}s are created out of it. *

* These all have the {@link QueryComponent#containerId} of their parent. * - * @deprecated use {@link TemporalQuery} instead + * @deprecated use {@link TemporalQuery} instead, which uses {@link StagedSimilarityQuery} which contains {@link QueryStage} which in turn contains {@link QueryTerm} */ @Deprecated public class QueryComponent { @@ -47,69 +47,6 @@ public List getTerms() { return this.terms; } - /** - * Converts the provided collection of QueryComponent objects to a map that maps feature categories defined in the query-terms to @{@link QueryContainer} derived from the {@link QueryTerm}. - * - * @return Category map. - */ - public static HashMap> toCategoryMap(Collection components) { - final HashMap> categoryMap = new HashMap<>(); - if (components.isEmpty()) { - LOGGER.warn("Empty components collection, returning empty map"); - return categoryMap; - } - for (QueryComponent component : components) { - if (component.getTerms().isEmpty()) { - LOGGER.warn("No terms for component {}", component); - continue; - } - for (QueryTerm term : component.getTerms()) { - if (term.getCategories().isEmpty()) { - LOGGER.warn("No categories for term {}", term); - } - for (String category : term.getCategories()) { - if (!categoryMap.containsKey(category)) { - categoryMap.put(category, new ArrayList<>()); - } - final QueryContainer container = term.toContainer(); - if (container != null) { - container.setContainerId(component.containerId); - categoryMap.get(category).add(container); - } else { - LOGGER.warn("Null container generated for term {}", term); - } - } - } - } - return categoryMap; - } - - /** - * Converts the provided collection of {@link QueryComponent} object to a map of {@link QueryContainer} and their categories. - * - * @return A map of querycontainers with their associated categories - */ - public static HashMap> toContainerMap(Collection components) { - final HashMap> map = new HashMap<>(); - if (components.isEmpty()) { - LOGGER.warn("Empty components collection, returning empty list of containers"); - return map; - } - for (QueryComponent component : components) { - for (QueryTerm qt : component.getTerms()) { - if (qt == null) { - /* FIXME in rare instances, it is possible to have null as query component*/ - LOGGER.warn("QueryTerm was null for component {}", component); - continue; - } - QueryContainer qc = qt.toContainer(); - qc.setContainerId(component.containerId); - map.put(qc, qt.getCategories()); - } - } - return map; - } - @Override public String toString() { return ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE); diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTerm.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTerm.java index 2b3292bd7..90a74024c 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTerm.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTerm.java @@ -6,7 +6,7 @@ import java.util.List; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; /** * Contains the data of a particular {@link QueryTerm}. @@ -30,9 +30,9 @@ public class QueryTerm { private final String data; /** - * Cached version of the {@link QueryContainer} representation of this {@link QueryTerm}. + * Cached version of the {@link AbstractQueryTermContainer} representation of this {@link QueryTerm}. */ - private QueryContainer cachedQueryContainer; + private AbstractQueryTermContainer cachedQueryTermContainer; @Override public String toString() { @@ -75,18 +75,18 @@ public QueryTermType getType() { /** - * Converts the {@link QueryTerm} to a {@link QueryContainer} that can be processed by the retrieval pipeline. This includes conversion of query-objects from the Base64 encoded representation. + * Converts the {@link QueryTerm} to a {@link AbstractQueryTermContainer} that can be processed by the retrieval pipeline. This includes conversion of query-objects from the Base64 encoded representation. * - * IMPORTANT: Subsequent calls to this method return a cached version of the original {@link QueryContainer}. + * IMPORTANT: Subsequent calls to this method return a cached version of the original {@link AbstractQueryTermContainer}. * - * @return {@link QueryContainer} representation of the {@link QueryTerm}. + * @return {@link AbstractQueryTermContainer} representation of the {@link QueryTerm}. */ - public QueryContainer toContainer() { - if (this.cachedQueryContainer == null) { + public AbstractQueryTermContainer toContainer() { + if (this.cachedQueryTermContainer == null) { if (this.data != null) { - this.cachedQueryContainer = this.type.getQueryContainer(this.data).orElse(null); + this.cachedQueryTermContainer = this.type.getQueryContainer(this.data).orElse(null); } } - return this.cachedQueryContainer; + return this.cachedQueryTermContainer; } } diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTermType.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTermType.java index 47e27f5f9..67be8fa37 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTermType.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/messages/query/QueryTermType.java @@ -5,63 +5,63 @@ import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.vitrivr.cineast.core.data.query.containers.AudioQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.BooleanQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.IdQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.ImageQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.InstantQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.LocationQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.ModelQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.MotionQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; -import org.vitrivr.cineast.core.data.query.containers.SemanticMapQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.TagQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.TextQueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AudioQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.BooleanQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.IdQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.ImageQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.InstantQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.LocationQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.ModelQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.MotionQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.SemanticMapQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.TagQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.TextQueryTermContainer; /** * A {@link QueryTermType} represents the types of query terms used. */ public enum QueryTermType { - IMAGE(ImageQueryContainer.class), - AUDIO(AudioQueryContainer.class), - MOTION(MotionQueryContainer.class), - MODEL3D(ModelQueryContainer.class), - LOCATION(LocationQueryContainer.class), - TIME(InstantQueryContainer.class), - TEXT(TextQueryContainer.class), - TAG(TagQueryContainer.class), - SEMANTIC(SemanticMapQueryContainer.class), + IMAGE(ImageQueryTermContainer.class), + AUDIO(AudioQueryTermContainer.class), + MOTION(MotionQueryTermContainer.class), + MODEL3D(ModelQueryTermContainer.class), + LOCATION(LocationQueryTermContainer.class), + TIME(InstantQueryTermContainer.class), + TEXT(TextQueryTermContainer.class), + TAG(TagQueryTermContainer.class), + SEMANTIC(SemanticMapQueryTermContainer.class), /** * Denotes a {@link QueryTerm} containing an Id for a 'More-Like-This' query. This is used over the @link {@link MoreLikeThisQuery} in REST calls. */ - ID(IdQueryContainer.class), - BOOLEAN(BooleanQueryContainer.class); + ID(IdQueryTermContainer.class), + BOOLEAN(BooleanQueryTermContainer.class); private static final Logger LOGGER = LogManager.getLogger(); /** - * Instance of the {@link QueryContainer} class that represents this {@link QueryTermType}. + * Instance of the {@link AbstractQueryTermContainer} class that represents this {@link QueryTermType}. */ - private final Class c; + private final Class c; - QueryTermType(Class clazz) { + QueryTermType(Class clazz) { this.c = clazz; } - public Class getContainerClass() { + public Class getContainerClass() { return this.c; } /** - * Constructs a new instance of the {@link QueryContainer} associated with the current {@link QueryTermType} using the provided raw data (usually base 64 encoded). + * Constructs a new instance of the {@link AbstractQueryTermContainer} associated with the current {@link QueryTermType} using the provided raw data (usually base 64 encoded). * - * @param data Data from which to construct a {@link QueryContainer} + * @param data Data from which to construct a {@link AbstractQueryTermContainer} */ - public Optional getQueryContainer(String data) { + public Optional getQueryContainer(String data) { try { - Constructor constructor = this.c.getConstructor(String.class); + Constructor constructor = this.c.getConstructor(String.class); return Optional.of(constructor.newInstance(data)); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { LOGGER.error("Error while constructing query container", e); diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/rest/handlers/actions/segment/FindSegmentSimilarPostHandler.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/rest/handlers/actions/segment/FindSegmentSimilarPostHandler.java index 277590e3a..d8e901d71 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/rest/handlers/actions/segment/FindSegmentSimilarPostHandler.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/rest/handlers/actions/segment/FindSegmentSimilarPostHandler.java @@ -15,7 +15,7 @@ import org.vitrivr.cineast.core.config.ReadableQueryConfig; import org.vitrivr.cineast.core.data.Pair; import org.vitrivr.cineast.core.data.StringDoublePair; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.standalone.config.Config; import org.vitrivr.cineast.standalone.config.ConstrainedQueryConfig; import org.vitrivr.cineast.standalone.util.ContinuousRetrievalLogic; @@ -36,7 +36,7 @@ public SimilarityQueryResultBatch performPost(SimilarityQuery query, Context ctx /* * Prepare map that maps categories to QueryTerm components. */ - HashMap> categoryMap = QueryUtil.groupComponentsByCategory(query.getComponents()); + HashMap> categoryMap = QueryUtil.groupComponentsByCategory(query.getComponents()); QueryConfig config = query.getQueryConfig(); ConstrainedQueryConfig qconf = new ConstrainedQueryConfig(config); @@ -48,7 +48,7 @@ public SimilarityQueryResultBatch performPost(SimilarityQuery query, Context ctx } for (String category : categoryMap.keySet()) { - List> containerList = categoryMap.get(category).stream().map(x -> new Pair<>(x, (ReadableQueryConfig) qconf)).collect(Collectors.toList()); + List> containerList = categoryMap.get(category).stream().map(x -> new Pair<>(x, (ReadableQueryConfig) qconf)).collect(Collectors.toList()); returnMap.put(category, QueryUtil.retrieveCategory(continuousRetrievalLogic, containerList, category)); } diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/util/QueryUtil.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/util/QueryUtil.java index 6647108cb..f3cbf8259 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/util/QueryUtil.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/util/QueryUtil.java @@ -18,7 +18,7 @@ import org.vitrivr.cineast.core.data.StringDoublePair; import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider; import org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.data.tag.Tag; import org.vitrivr.cineast.core.db.DBSelector; @@ -32,9 +32,9 @@ //TODO maybe this should be moved to core? public class QueryUtil { - public static HashMap> groupComponentsByCategory( + public static HashMap> groupComponentsByCategory( List queryComponents) { - HashMap> categoryMap = new HashMap<>(); + HashMap> categoryMap = new HashMap<>(); for (QueryComponent component : queryComponents) { for (QueryTerm term : component.getTerms()) { if (term.getCategories() == null) { @@ -51,9 +51,9 @@ public static HashMap> groupComponentsByCatego return categoryMap; } - public static HashMap>> groupTermsByCategory( + public static HashMap>> groupTermsByCategory( List terms) { - HashMap>> categoryMap = new HashMap<>(); + HashMap>> categoryMap = new HashMap<>(); for (org.vitrivr.cineast.api.grpc.data.QueryTerm term : terms) { if (term.getCategories().isEmpty()) { continue; @@ -71,15 +71,15 @@ public static HashMap retrieveCategory( ContinuousRetrievalLogic continuousRetrievalLogic, - List> queryContainers, String category) { + List> queryContainers, String category) { TObjectDoubleHashMap scoreBySegmentId = new TObjectDoubleHashMap<>(); - for (Pair pair : queryContainers) { + for (Pair pair : queryContainers) { if (pair == null) { continue; } - QueryContainer qc = pair.first; + AbstractQueryTermContainer qc = pair.first; ReadableQueryConfig qconf = pair.second; float weight = MathHelper.limit(qc.getWeight(), -1f, 1f); @@ -122,15 +122,15 @@ public static List retrieveCategory( } public static List retrieve(ContinuousRetrievalLogic continuousRetrievalLogic, - QueryContainer queryContainer, ReadableQueryConfig config, String category) { - float weight = MathHelper.limit(queryContainer.getWeight(), -1f, 1f); + AbstractQueryTermContainer queryTermContainer, ReadableQueryConfig config, String category) { + float weight = MathHelper.limit(queryTermContainer.getWeight(), -1f, 1f); TObjectDoubleHashMap scoreBySegmentId = new TObjectDoubleHashMap<>(); List scoreResults; - if (queryContainer.hasId()) { - scoreResults = continuousRetrievalLogic.retrieve(queryContainer.getId(), category, config); + if (queryTermContainer.hasId()) { + scoreResults = continuousRetrievalLogic.retrieve(queryTermContainer.getId(), category, config); } else { - scoreResults = continuousRetrievalLogic.retrieve(queryContainer, category, config); + scoreResults = continuousRetrievalLogic.retrieve(queryTermContainer, category, config); } for (SegmentScoreElement element : scoreResults) { diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/WebsocketAPI.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/WebsocketAPI.java index b5427f3bd..a355139c4 100644 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/WebsocketAPI.java +++ b/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/WebsocketAPI.java @@ -26,7 +26,6 @@ import org.vitrivr.cineast.api.websocket.handlers.queries.MoreLikeThisQueryMessageHandler; import org.vitrivr.cineast.api.websocket.handlers.queries.NeighbouringQueryMessageHandler; import org.vitrivr.cineast.api.websocket.handlers.queries.SegmentQueryMessageHandler; -import org.vitrivr.cineast.api.websocket.handlers.queries.SimilarityQueryMessageHandler; import org.vitrivr.cineast.api.websocket.handlers.queries.TemporalQueryMessageHandler; import org.vitrivr.cineast.core.util.LogHelper; import org.vitrivr.cineast.core.util.json.JacksonJsonProvider; @@ -60,7 +59,6 @@ public class WebsocketAPI { private static final HashMap> STATELESS_HANDLERS = new HashMap<>(); static { - STATELESS_HANDLERS.put(MessageType.Q_SIM, new SimilarityQueryMessageHandler(APIEndpoint.retrievalLogic)); STATELESS_HANDLERS.put(MessageType.Q_TEMPORAL, new TemporalQueryMessageHandler(APIEndpoint.retrievalLogic)); STATELESS_HANDLERS.put(MessageType.Q_MLT, new MoreLikeThisQueryMessageHandler(APIEndpoint.retrievalLogic)); STATELESS_HANDLERS.put(MessageType.Q_NESEG, new NeighbouringQueryMessageHandler()); diff --git a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/SimilarityQueryMessageHandler.java b/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/SimilarityQueryMessageHandler.java deleted file mode 100644 index b214bef4b..000000000 --- a/cineast-api/src/main/java/org/vitrivr/cineast/api/websocket/handlers/queries/SimilarityQueryMessageHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.vitrivr.cineast.api.websocket.handlers.queries; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.eclipse.jetty.websocket.api.Session; -import org.vitrivr.cineast.api.messages.query.QueryComponent; -import org.vitrivr.cineast.api.messages.query.SimilarityQuery; -import org.vitrivr.cineast.core.config.QueryConfig; -import org.vitrivr.cineast.core.data.StringDoublePair; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; -import org.vitrivr.cineast.core.data.score.SegmentScoreElement; -import org.vitrivr.cineast.standalone.config.Config; -import org.vitrivr.cineast.standalone.util.ContinuousRetrievalLogic; - -/** - * This class extends the {@link AbstractQueryMessageHandler} abstract class and handles messages of type {@link SimilarityQuery}. - */ -public class SimilarityQueryMessageHandler extends AbstractQueryMessageHandler { - - private static final Logger LOGGER = LogManager.getLogger(); - - private final ContinuousRetrievalLogic continuousRetrievalLogic; - - public SimilarityQueryMessageHandler(ContinuousRetrievalLogic retrievalLogic) { - this.continuousRetrievalLogic = retrievalLogic; - } - - /** - * Executes a {@link SimilarityQuery}. Performs the similarity query based on the {@link QueryContainer} objects provided in the {@link SimilarityQuery}. - * - * @param session WebSocket session the invocation is associated with. - * @param qconf The {@link QueryConfig} that contains additional specifications. - * @param message Instance of {@link SimilarityQuery} - * @param segmentIdsForWhichMetadataIsFetched Segment IDs for which metadata is fetched - * @param objectIdsForWhichMetadataIsFetched Object IDs for which metadata is fetched - */ - @Override - public void execute(Session session, QueryConfig qconf, SimilarityQuery message, Set segmentIdsForWhichMetadataIsFetched, Set objectIdsForWhichMetadataIsFetched) { - - /* Prepare QueryConfig (so as to obtain a QueryId). */ - final String uuid = qconf.getQueryId().toString(); - final int max = qconf.getMaxResults().orElse(Config.sharedConfig().getRetriever().getMaxResults()); - - /* Prepare map that maps QueryTerms (as QueryContainer, ready for retrieval) and their associated categories */ - final HashMap> containerCategoryMap = QueryComponent.toContainerMap(message.getComponents()); - - List threads = new ArrayList<>(); - List> futures = new ArrayList<>(); - /* Execute similarity queries for all QueryContainer -> Category combinations in the map */ - for (QueryContainer qc : containerCategoryMap.keySet()) { - for (String category : containerCategoryMap.get(qc)) { - /* Merge partial results with score-map */ - List scores = continuousRetrievalLogic.retrieve(qc, category, qconf); - - /* Transform raw results into list of StringDoublePairs (segmentId -> score) */ - final List results = scores.stream() - .map(elem -> new StringDoublePair(elem.getSegmentId(), elem.getScore())) - .filter(p -> p.value > 0d) - .sorted(StringDoublePair.COMPARATOR) - .limit(max) - .collect(Collectors.toList()); - - /* Finalize and submit per-container results */ - List segmentIds = results.stream().map(el -> el.key).collect(Collectors.toList()); - List objectIds = this.submitSegmentAndObjectInformation(session, uuid, segmentIds); - futures.addAll(this.finalizeAndSubmitResults(session, uuid, category, qc.getContainerId(), results)); - List _threads = this.submitMetadata(session, uuid, segmentIds, objectIds, segmentIdsForWhichMetadataIsFetched, objectIdsForWhichMetadataIsFetched); - threads.addAll(_threads); - } - } - futures.forEach(CompletableFuture::join); - for (Thread thread : threads) { - try { - thread.join(); - } catch (InterruptedException e) { - LOGGER.error(e); - } - } - - } - -} 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 8e543fd3b..31a1c3691 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 @@ -21,7 +21,7 @@ import org.vitrivr.cineast.core.data.StringDoublePair; import org.vitrivr.cineast.core.data.TemporalObject; import org.vitrivr.cineast.core.data.entities.MediaSegmentDescriptor; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.temporal.TemporalScoring; import org.vitrivr.cineast.standalone.config.Config; @@ -100,13 +100,12 @@ public void execute(Session session, QueryConfig qconf, TemporalQuery message, S LOGGER.warn("QueryTerm was null for stage {}", stage); return; } - QueryContainer qc = qt.toContainer(); + AbstractQueryTermContainer qc = qt.toContainer(); if (qc == null) { LOGGER.warn( "Likely an empty query, as it could not be converted to a query container. Ignoring it"); return; } - qc.setContainerId(containerIdx); /* We retrieve the results for each category of a QueryTerm independently. The relevant ids will not yet be changed after this call as we are still in the same stage. */ for (String category : qt.getCategories()) { @@ -155,7 +154,7 @@ public void execute(Session session, QueryConfig qconf, TemporalQuery message, S sentSegmentIds.addAll(limitedSegmentIds); List limitedObjectIds = this.submitSegmentAndObjectInformation(session, uuid, limitedSegmentIds); sentObjectIds.addAll(limitedObjectIds); - futures.addAll(this.finalizeAndSubmitResults(session, uuid, category, qc.getContainerId(), limitedResults)); + futures.addAll(this.finalizeAndSubmitResults(session, uuid, category, containerIdx, limitedResults)); List _threads = this.submitMetadata(session, uuid, limitedSegmentIds, limitedObjectIds, segmentIdsForWhichMetadataIsFetched, objectIdsForWhichMetadataIsFetched); metadataRetrievalThreads.addAll(_threads); } diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/QueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AbstractQueryTermContainer.java similarity index 83% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/QueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AbstractQueryTermContainer.java index 083f1818a..5966b7dd5 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/QueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AbstractQueryTermContainer.java @@ -7,10 +7,16 @@ import org.vitrivr.cineast.core.data.segments.SegmentContainer; import org.vitrivr.cineast.core.util.MathHelper; -public abstract class QueryContainer implements SegmentContainer { +/** + * An {@link AbstractQueryTermContainer} is the implementation of a {@link SegmentContainer} which is used in the online-phase (during retrieval). + * + * On a system perspective, it is generally created based on an API request from a Query Term (e.g. a color sketch, a text query). + */ +public abstract class AbstractQueryTermContainer implements SegmentContainer { private float weight = 1f; private String id = null, superId = null; + private int containerId = -1; /** @@ -31,14 +37,6 @@ public void setWeight(float weight) { this.weight = MathHelper.limit(weight, -1f, 1f); } - public int getContainerId() { - return containerId; - } - - public void setContainerId(int containerId) { - this.containerId = containerId; - } - /** * Online: If this is set, it is assumed to be the id of a {@link MediaSegmentDescriptor} * diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryTermContainer.java similarity index 91% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryTermContainer.java index 0c8ccf9a3..6af04ef60 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/AudioQueryTermContainer.java @@ -9,7 +9,7 @@ import java.util.List; -public class AudioQueryContainer extends QueryContainer { +public class AudioQueryTermContainer extends AbstractQueryTermContainer { /** List of {@link AudioFrame}s. */ private final List frames; @@ -24,12 +24,12 @@ public class AudioQueryContainer extends QueryContainer { private AudioDescriptor descriptor; /** - * Constructs an {@link AudioQueryContainer} from base 64 encoded wave audio data. The constructor assumes + * Constructs an {@link AudioQueryTermContainer} from base 64 encoded wave audio data. The constructor assumes * the following audio settings: 22050Hz, 1 Channel, 16bit PCM * * @param data The audio data that should be converted. */ - public AudioQueryContainer(String data) { + public AudioQueryTermContainer(String data) { this(AudioParser.parseWaveAudio(data, 22050.0f, 1)); } @@ -39,7 +39,7 @@ public AudioQueryContainer(String data) { * * @return List auf audio-frames in the audio-segment. */ - public AudioQueryContainer(List frames) { + public AudioQueryTermContainer(List frames) { this.frames = frames; for (AudioFrame frame : this.frames) { if (this.descriptor == null) { diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryTermContainer.java similarity index 91% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryTermContainer.java index d6cfc7ae6..b3109388e 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/BooleanQueryTermContainer.java @@ -13,7 +13,7 @@ import java.util.Iterator; import java.util.List; -public class BooleanQueryContainer extends QueryContainer { +public class BooleanQueryTermContainer extends AbstractQueryTermContainer { private static final String ATTRIBUTE_FIELD_NAME = "attribute"; private static final String OPERATOR_FIELD_NAME = "operator"; @@ -23,15 +23,15 @@ public class BooleanQueryContainer extends QueryContainer { private ArrayList expressions = new ArrayList<>(); - public BooleanQueryContainer(Collection expressions) { + public BooleanQueryTermContainer(Collection expressions) { this.expressions.addAll(expressions); } - public BooleanQueryContainer(String data) { + public BooleanQueryTermContainer(String data) { this(DataURLParser.dataURLtoJsonNode(data).orElseThrow(() -> new IllegalArgumentException("Failed to parse the provided Boolean expression data."))); } - public BooleanQueryContainer(JsonNode json) { + public BooleanQueryTermContainer(JsonNode json) { if (!json.isArray()) { throw new IllegalArgumentException("Boolean expression data is not a list"); } diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryContainer.java deleted file mode 100644 index 13654a235..000000000 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryContainer.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.vitrivr.cineast.core.data.query.containers; - -public class IdQueryContainer extends QueryContainer { - - public IdQueryContainer(String id){ - setId(id); - } - -} diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryTermContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryTermContainer.java new file mode 100644 index 000000000..a90aa3a10 --- /dev/null +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/IdQueryTermContainer.java @@ -0,0 +1,9 @@ +package org.vitrivr.cineast.core.data.query.containers; + +public class IdQueryTermContainer extends AbstractQueryTermContainer { + + public IdQueryTermContainer(String id){ + setId(id); + } + +} diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryTermContainer.java similarity index 86% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryTermContainer.java index 0708a5554..986f6662a 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ImageQueryTermContainer.java @@ -14,7 +14,7 @@ import java.util.LinkedList; import java.util.List; -public class ImageQueryContainer extends QueryContainer { +public class ImageQueryTermContainer extends AbstractQueryTermContainer { private MultiImage img; private VideoFrame videoFrame; @@ -24,28 +24,28 @@ public class ImageQueryContainer extends QueryContainer { private float relativeStart = 0, relativeEnd = 0; /** - * Constructs an {@link ImageQueryContainer} from base 64 encoded image data. + * Constructs an {@link ImageQueryTermContainer} from base 64 encoded image data. * * @param data The image data that should be converted. * @param factory The {@link CachedDataFactory} that should be used to generate the {@link MultiImage}. */ - public ImageQueryContainer(String data, CachedDataFactory factory) { + public ImageQueryTermContainer(String data, CachedDataFactory factory) { this(ImageParser.dataURLtoBufferedImage(data), factory); } - public ImageQueryContainer(BufferedImage image, CachedDataFactory factory) { + public ImageQueryTermContainer(BufferedImage image, CachedDataFactory factory) { this.img = factory.newInMemoryMultiImage(image); } - public ImageQueryContainer(BufferedImage image) { + public ImageQueryTermContainer(BufferedImage image) { this(image, CachedDataFactory.getDefault()); } - public ImageQueryContainer(String data){ + public ImageQueryTermContainer(String data){ this(data, CachedDataFactory.getDefault()); } - public ImageQueryContainer(MultiImage img){ + public ImageQueryTermContainer(MultiImage img){ this.img = img; } diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryTermContainer.java similarity index 65% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryTermContainer.java index 4da756902..4664c0e03 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/InstantQueryTermContainer.java @@ -8,30 +8,30 @@ /** * A query based on similarity to an {@link Instant} in time. */ -public class InstantQueryContainer extends QueryContainer { +public class InstantQueryTermContainer extends AbstractQueryTermContainer { private final Instant instant; /** - * Constructs an {@link InstantQueryContainer} from string data + * Constructs an {@link InstantQueryTermContainer} from string data * * @param data The string data that should be converted. */ - public InstantQueryContainer(String data) { + public InstantQueryTermContainer(String data) { this(GpsData.parseInstant(data).orElseThrow(() -> new IllegalArgumentException("The provided JSON data did not contain valid GPS information."))); } /** - * Constructs an {@link InstantQueryContainer} from an {@link Instant} + * Constructs an {@link InstantQueryTermContainer} from an {@link Instant} * - * @param instant {@link Instant} from which to construct the {@link InstantQueryContainer} + * @param instant {@link Instant} from which to construct the {@link InstantQueryTermContainer} */ - public InstantQueryContainer(Instant instant) { + public InstantQueryTermContainer(Instant instant) { this.instant = instant; } - public static InstantQueryContainer of(Instant instant) { - return new InstantQueryContainer(instant); + public static InstantQueryTermContainer of(Instant instant) { + return new InstantQueryTermContainer(instant); } @Override diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryTermContainer.java similarity index 73% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryTermContainer.java index 163ae0bae..a35aee3d4 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/LocationQueryTermContainer.java @@ -8,17 +8,17 @@ import java.util.Optional; -public class LocationQueryContainer extends QueryContainer { +public class LocationQueryTermContainer extends AbstractQueryTermContainer { - /** The {@link Location} object contained in this {@link LocationQueryContainer}. */ + /** The {@link Location} object contained in this {@link LocationQueryTermContainer}. */ private final Location location; /** - * Constructs an {@link LocationQueryContainer} from JSON data. + * Constructs an {@link LocationQueryTermContainer} from JSON data. * * @param json The JSON data that should be converted. */ - public LocationQueryContainer(String json) { + public LocationQueryTermContainer(String json) { final JacksonJsonProvider jsonProvider = new JacksonJsonProvider(); final JsonNode jsonNode = jsonProvider.toJsonNode(json); if (jsonNode != null) { @@ -29,16 +29,16 @@ public LocationQueryContainer(String json) { } /** - * Constructs an {@link LocationQueryContainer} from a {@link Location} object. + * Constructs an {@link LocationQueryTermContainer} from a {@link Location} object. * * @param location The JSON data that should be converted. */ - public LocationQueryContainer(Location location) { + public LocationQueryTermContainer(Location location) { this.location = location; } - public static LocationQueryContainer of(Location location) { - return new LocationQueryContainer(location); + public static LocationQueryTermContainer of(Location location) { + return new LocationQueryTermContainer(location); } @Override diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryTermContainer.java similarity index 73% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryTermContainer.java index 83090aae5..80f35c4f9 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/ModelQueryTermContainer.java @@ -10,7 +10,7 @@ import java.awt.image.BufferedImage; -public class ModelQueryContainer extends QueryContainer { +public class ModelQueryTermContainer extends AbstractQueryTermContainer { /** Original Mesh as transferred by the client. */ private final Mesh mesh; @@ -22,13 +22,13 @@ public class ModelQueryContainer extends QueryContainer { private final MultiImage image; /** - * Constructs an {@link ModelQueryContainer} from base 64 encoded JSON data. The constructor assumes either the JSV4 JSON format + * Constructs an {@link ModelQueryTermContainer} from base 64 encoded JSON data. The constructor assumes either the JSV4 JSON format * for Meshes OR a valid image (for 2D sketch to 3D model lookup). * * @param data The 3D model data that should be converted. * @param factory The {@link CachedDataFactory} used to create images. */ - public ModelQueryContainer(String data, CachedDataFactory factory) { + public ModelQueryTermContainer(String data, CachedDataFactory factory) { if (MeshParser.isValidThreeJSV4Geometry(data)) { this.mesh = MeshParser.parseThreeJSV4Geometry(data); this.normalizedMesh = MeshTransformUtil.khlTransform(mesh, 1.0f); @@ -43,39 +43,39 @@ public ModelQueryContainer(String data, CachedDataFactory factory) { } } - public ModelQueryContainer(String data){ + public ModelQueryTermContainer(String data){ this(data, CachedDataFactory.getDefault()); } /** - * Constructor for {@link ModelQueryContainer} with a Mesh. Used for Query-by-Example. + * Constructor for {@link ModelQueryTermContainer} with a Mesh. Used for Query-by-Example. * - * @param mesh Mesh for which to create a {@link ModelQueryContainer}. + * @param mesh Mesh for which to create a {@link ModelQueryTermContainer}. */ - public ModelQueryContainer(Mesh mesh) { + public ModelQueryTermContainer(Mesh mesh) { this.mesh = new Mesh(mesh); this.normalizedMesh = MeshTransformUtil.khlTransform(mesh, 1.0f); this.image = MultiImage.EMPTY_MULTIIMAGE; } /** - * Constructor for {@link ModelQueryContainer} with ab image. Used for Query-by-Sketch (2d sketch to 3d model). + * Constructor for {@link ModelQueryTermContainer} with ab image. Used for Query-by-Sketch (2d sketch to 3d model). * - * @param image BufferedImage for which to create a {@link ModelQueryContainer}. + * @param image BufferedImage for which to create a {@link ModelQueryTermContainer}. * @param factory The {@link CachedDataFactory} to create the {@link MultiImage} with. */ - public ModelQueryContainer(BufferedImage image, CachedDataFactory factory) { + public ModelQueryTermContainer(BufferedImage image, CachedDataFactory factory) { this.image = factory.newMultiImage(image); this.mesh = Mesh.EMPTY; this.normalizedMesh = Mesh.EMPTY; } /** - * Constructor for {@link ModelQueryContainer} constructor with an image (treated as 2D sketch). Used for Query-by-2D-Sketch. + * Constructor for {@link ModelQueryTermContainer} constructor with an image (treated as 2D sketch). Used for Query-by-2D-Sketch. * - * @param image Image for which to create a {@link ModelQueryContainer}. + * @param image Image for which to create a {@link ModelQueryTermContainer}. */ - public ModelQueryContainer(MultiImage image) { + public ModelQueryTermContainer(MultiImage image) { this.image = image; this.mesh = Mesh.EMPTY; this.normalizedMesh = Mesh.EMPTY; diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryTermContainer.java similarity index 84% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryTermContainer.java index 9bea7529d..77cff58be 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/MotionQueryTermContainer.java @@ -10,30 +10,30 @@ import java.util.List; //FIXME integer in pair is never used -public class MotionQueryContainer extends QueryContainer { +public class MotionQueryTermContainer extends AbstractQueryTermContainer { private List>> paths = new ArrayList>>(); private List>> bgPaths = new ArrayList>>(); - public MotionQueryContainer(){ + public MotionQueryTermContainer(){ //empty container } /** - * Constructs an {@link MotionQueryContainer} from base 64 encoded JSON data. + * Constructs an {@link MotionQueryTermContainer} from base 64 encoded JSON data. * * @param data The 3D model data that should be converted. */ - public MotionQueryContainer(String data) { + public MotionQueryTermContainer(String data) { this(DataURLParser.dataURLtoJsonNode(data).orElseThrow(() -> new IllegalArgumentException("Failed to parse the provided motion data."))); } /** - * Constructs an {@link MotionQueryContainer} from a JsonNode object. + * Constructs an {@link MotionQueryTermContainer} from a JsonNode object. * * @param jsonNode The JsonNode representing the motion data. */ - public MotionQueryContainer(JsonNode jsonNode) { + public MotionQueryTermContainer(JsonNode jsonNode) { final JsonNode foreground = jsonNode.get("foreground"); ArrayList> list = nodeToList(foreground); for (LinkedList path : list) { @@ -65,8 +65,8 @@ public void addBgPath(LinkedList path) { this.bgPaths.add(new Pair>(0, path)); } - public static QueryContainer fromJson(JsonNode jsonNode) { - return new MotionQueryContainer(jsonNode); + public static AbstractQueryTermContainer fromJson(JsonNode jsonNode) { + return new MotionQueryTermContainer(jsonNode); } private static ArrayList> nodeToList(JsonNode jsonNode) { diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryTermContainer.java similarity index 79% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryTermContainer.java index 099ce6eae..f0e0f153e 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/SemanticMapQueryTermContainer.java @@ -11,14 +11,14 @@ import java.util.Optional; /** - * A {@link QueryContainer} for queries using semantic maps. The class expects a JSON of the following form: + * A {@link AbstractQueryTermContainer} for queries using semantic maps. The class expects a JSON of the following form: * * { * image: , * map: List of objects mapping the class to the color (as used in the image. * } */ -public class SemanticMapQueryContainer extends QueryContainer { +public class SemanticMapQueryTermContainer extends AbstractQueryTermContainer { /** Field name of the image portion of the JSON. */ private static final String IMAGE_FIELD_NAME = "image"; @@ -29,25 +29,25 @@ public class SemanticMapQueryContainer extends QueryContainer { /** The {@link SemanticMap} that is used internally. */ private final SemanticMap map; - public SemanticMapQueryContainer(SemanticMap map){ + public SemanticMapQueryTermContainer(SemanticMap map){ this.map = map; } /** - * Constructor for {@link SemanticMapQueryContainer} + * Constructor for {@link SemanticMapQueryTermContainer} * * @param data Base64 encoded representation of the JSON. */ - public SemanticMapQueryContainer(String data){ + public SemanticMapQueryTermContainer(String data){ this(DataURLParser.dataURLtoJsonNode(data).orElseThrow(() -> new IllegalArgumentException("Failed to parse the provided semantic map data."))); } /** - * Constructor for {@link SemanticMapQueryContainer} + * Constructor for {@link SemanticMapQueryTermContainer} * - * @param jsonNode JsonObject as expected by {@link SemanticMapQueryContainer} + * @param jsonNode JsonObject as expected by {@link SemanticMapQueryTermContainer} */ - public SemanticMapQueryContainer(JsonNode jsonNode){ + public SemanticMapQueryTermContainer(JsonNode jsonNode){ if (!jsonNode.has(IMAGE_FIELD_NAME)) throw new IllegalArgumentException("The provided data structure does not contain the required field 'image' (semantic map)."); if (!jsonNode.has(MAP_FIELD_NAME)) throw new IllegalArgumentException("The provided data structure does not contain the required field 'map' (category to color map)."); @@ -67,7 +67,7 @@ public SemanticMapQueryContainer(JsonNode jsonNode){ } /** - * Getter for {@link SemanticMapQueryContainer#map}. + * Getter for {@link SemanticMapQueryTermContainer#map}. * * @return {@link SemanticMap} */ diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryTermContainer.java similarity index 77% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryTermContainer.java index 942a740bc..4554ca23e 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TagQueryTermContainer.java @@ -12,19 +12,19 @@ import org.vitrivr.cineast.core.util.web.DataURLParser; -public class TagQueryContainer extends QueryContainer { // vitrivr pendant: TagQueryTerm +public class TagQueryTermContainer extends AbstractQueryTermContainer { // vitrivr pendant: TagQueryTerm /** - * List of {@link Tag}s contained in this {@link TagQueryContainer}. + * List of {@link Tag}s contained in this {@link TagQueryTermContainer}. */ private final List tags; /** - * Constructs an {@link TagQueryContainer} from base 64 encoded JSON data. + * Constructs an {@link TagQueryTermContainer} from base 64 encoded JSON data. * * @param data The tag data that should be converted. */ - public TagQueryContainer(String data) { + public TagQueryTermContainer(String data) { final JacksonJsonProvider jsonProvider = new JacksonJsonProvider(); final String converted = DataURLParser.dataURLtoString(data, "application/json"); final WeightedTag[] tags = jsonProvider.toObject(converted, IncompleteTag[].class); @@ -35,7 +35,7 @@ public TagQueryContainer(String data) { } } - public TagQueryContainer(Collection tags) { + public TagQueryTermContainer(Collection tags) { ArrayList tmp = new ArrayList<>(tags != null ? tags.size() : 0); if (tags != null) { tmp.addAll(tags); diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryTermContainer.java similarity index 53% rename from cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryContainer.java rename to cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryTermContainer.java index b412474f8..73019412a 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/query/containers/TextQueryTermContainer.java @@ -1,18 +1,18 @@ package org.vitrivr.cineast.core.data.query.containers; -public class TextQueryContainer extends QueryContainer { +public class TextQueryTermContainer extends AbstractQueryTermContainer { /** - * Text contained in this {@link TextQueryContainer}. + * Text contained in this {@link TextQueryTermContainer}. */ private final String text; /** - * Constructs a new {@link TextQueryContainer} from the provided text. + * Constructs a new {@link TextQueryTermContainer} from the provided text. * - * @param text Text for which to construct a {@link TextQueryContainer}. + * @param text Text for which to construct a {@link TextQueryTermContainer}. */ - public TextQueryContainer(String text) { + public TextQueryTermContainer(String text) { this.text = (text == null ? "" : text); } diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/score/SegmentScoreElement.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/score/SegmentScoreElement.java index e2bb5b0c8..7f8f17a3d 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/score/SegmentScoreElement.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/score/SegmentScoreElement.java @@ -1,6 +1,7 @@ package org.vitrivr.cineast.core.data.score; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; @JsonIgnoreProperties(ignoreUnknown = true) public class SegmentScoreElement extends AbstractScoreElement { @@ -13,21 +14,21 @@ public String getSegmentId() { } /** - * An id to map this {@link SegmentScoreElement} to a {@link org.vitrivr.cineast.core.data.query.containers.QueryContainer}. + * An id to map this {@link SegmentScoreElement} to a {@link AbstractQueryTermContainer}. */ private String queryContainerId; /** - * Getter for the {@link org.vitrivr.cineast.core.data.query.containers.QueryContainer}'s ID, this {@link SegmentScoreElement} relates to - * @return The {@link org.vitrivr.cineast.core.data.query.containers.QueryContainer}'s ID, to which this {@link SegmentScoreElement} relates to. + * Getter for the {@link AbstractQueryTermContainer}'s ID, this {@link SegmentScoreElement} relates to + * @return The {@link AbstractQueryTermContainer}'s ID, to which this {@link SegmentScoreElement} relates to. */ public String getQueryContainerId(){ return queryContainerId; } /** - * Setter for the {@link org.vitrivr.cineast.core.data.query.containers.QueryContainer}'s ID, this {@link SegmentScoreElement} relates to - * @param queryContainerId The ID of the {@link org.vitrivr.cineast.core.data.query.containers.QueryContainer} this {@link SegmentScoreElement} relates to + * Setter for the {@link AbstractQueryTermContainer}'s ID, this {@link SegmentScoreElement} relates to + * @param queryContainerId The ID of the {@link AbstractQueryTermContainer} this {@link SegmentScoreElement} relates to */ public void setQueryContainerId(String queryContainerId){ this.queryContainerId = queryContainerId; diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/segments/SegmentContainer.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/segments/SegmentContainer.java index a494db300..608368b56 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/data/segments/SegmentContainer.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/data/segments/SegmentContainer.java @@ -1,7 +1,14 @@ package org.vitrivr.cineast.core.data.segments; import org.vitrivr.cineast.core.data.providers.*; +import org.vitrivr.cineast.core.features.extractor.Extractor; +import org.vitrivr.cineast.core.features.retriever.Retriever; +/** + * A {@link SegmentContainer} mainly serves two purposes: + * + * During the offline phase, it is passed to an {@link Extractor}, and during the online phase, it is passed to a {@link Retriever}. + */ public interface SegmentContainer extends IdProvider, AvgImgProvider, diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/general/Converter.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/general/Converter.java index 0d3c9b926..493132ee8 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/general/Converter.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/general/Converter.java @@ -1,7 +1,7 @@ package org.vitrivr.cineast.core.extraction.decode.general; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import java.nio.file.Path; import java.util.Set; @@ -14,7 +14,7 @@ public interface Converter { * @param path Path the file that should be converted. * @return QueryContainer for the specified file. */ - QueryContainer convert(Path path); + AbstractQueryTermContainer convert(Path path); /** * Returns a set of the mime/types of supported files. diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/m3d/ModularMeshDecoder.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/m3d/ModularMeshDecoder.java index 45c12d944..58bc414a9 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/m3d/ModularMeshDecoder.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/extraction/decode/m3d/ModularMeshDecoder.java @@ -6,8 +6,8 @@ import org.vitrivr.cineast.core.config.CacheConfig; import org.vitrivr.cineast.core.data.m3d.Mesh; -import org.vitrivr.cineast.core.data.query.containers.ModelQueryContainer; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.ModelQueryTermContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.extraction.decode.general.Converter; import org.vitrivr.cineast.core.extraction.decode.general.Decoder; import org.vitrivr.cineast.core.util.MimeTypeHelper; @@ -115,7 +115,7 @@ public Mesh getNext() { * @return QueryContainer for the specified file. */ @Override - public QueryContainer convert(Path path) { + public AbstractQueryTermContainer convert(Path path) { final String contenttype = MimeTypeHelper.getContentType(path.toFile()); /* Try to detach decoder from the list of cached decoders. */ @@ -137,7 +137,7 @@ public QueryContainer convert(Path path) { /* Initialize the decoder and return the decoded mesh. */ decoder.init(path, null, null); Mesh mesh = decoder.getNext(); - return new ModelQueryContainer(mesh); + return new ModelQueryTermContainer(mesh); } /** diff --git a/cineast-core/src/test/java/org/vitrivr/cineast/core/features/abstracts/AbstractTextRetrieverTest.java b/cineast-core/src/test/java/org/vitrivr/cineast/core/features/abstracts/AbstractTextRetrieverTest.java index d1a291e7b..aba92bf63 100644 --- a/cineast-core/src/test/java/org/vitrivr/cineast/core/features/abstracts/AbstractTextRetrieverTest.java +++ b/cineast-core/src/test/java/org/vitrivr/cineast/core/features/abstracts/AbstractTextRetrieverTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.vitrivr.cineast.core.config.QueryConfig; -import org.vitrivr.cineast.core.data.query.containers.TextQueryContainer; +import org.vitrivr.cineast.core.data.query.containers.TextQueryTermContainer; import org.vitrivr.cineast.core.data.segments.SegmentContainer; public class AbstractTextRetrieverTest { @@ -30,11 +30,11 @@ public void testNonQuotedStringSplit() { } public void testMatch(String input, String... output) { - org.junit.jupiter.api.Assertions.assertArrayEquals(output, retriever.generateQuery(new TextQueryContainer(input), new QueryConfig(null))); + org.junit.jupiter.api.Assertions.assertArrayEquals(output, retriever.generateQuery(new TextQueryTermContainer(input), new QueryConfig(null))); } public SegmentContainer generateSegmentContainerFromText(String text) { - return new TextQueryContainer(text); + return new TextQueryTermContainer(text); } } diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/CliUtils.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/CliUtils.java index bd497278c..9e5997ae0 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/CliUtils.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/CliUtils.java @@ -8,7 +8,7 @@ import org.vitrivr.cineast.core.data.entities.MediaSegmentDescriptor; import org.vitrivr.cineast.core.data.providers.primitive.PrimitiveTypeProvider; import org.vitrivr.cineast.core.data.providers.primitive.StringTypeProvider; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.db.DBSelector; import org.vitrivr.cineast.core.db.dao.reader.MediaObjectMetadataReader; @@ -84,7 +84,7 @@ public static void printInfoForSegment(String segmentId, DBSelector selector, St System.out.println("Done"); } - public static void retrieveAndLog(List retrievers, ContinuousRetrievalLogic retrieval, int limit, boolean printDetail, QueryContainer qc) { + public static void retrieveAndLog(List retrievers, ContinuousRetrievalLogic retrieval, int limit, boolean printDetail, AbstractQueryTermContainer qc) { System.out.println("Only printing the first " + limit + " results, change with --limit parameter"); DBSelector selector = Config.sharedConfig().getDatabase().getSelectorSupplier().get(); retrievers.forEach(retriever -> { diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TagRetrievalCommand.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TagRetrievalCommand.java index bb13d8f3d..5a74167bd 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TagRetrievalCommand.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TagRetrievalCommand.java @@ -4,14 +4,10 @@ import com.github.rvesse.airline.annotations.Option; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import org.vitrivr.cineast.core.data.query.containers.TagQueryContainer; -import org.vitrivr.cineast.core.data.score.SegmentScoreElement; -import org.vitrivr.cineast.core.db.DBSelector; +import org.vitrivr.cineast.core.data.query.containers.TagQueryTermContainer; import org.vitrivr.cineast.core.features.SegmentTags; import org.vitrivr.cineast.core.features.retriever.Retriever; import org.vitrivr.cineast.standalone.config.Config; -import org.vitrivr.cineast.standalone.config.ConstrainedQueryConfig; import org.vitrivr.cineast.standalone.util.ContinuousRetrievalLogic; @Command(name = "retrieve-tags", description = "Retrieves objects from the database using text as query input.") @@ -27,7 +23,7 @@ public class TagRetrievalCommand implements Runnable { public void run() { final ContinuousRetrievalLogic retrieval = new ContinuousRetrievalLogic(Config.sharedConfig().getDatabase()); - TagQueryContainer qc = new TagQueryContainer(data); + TagQueryTermContainer qc = new TagQueryTermContainer(data); List retrievers = new ArrayList<>(); retrievers.add(new SegmentTags()); diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TextRetrievalCommand.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TextRetrievalCommand.java index 90b42d833..6eeb3a2cf 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TextRetrievalCommand.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/cli/TextRetrievalCommand.java @@ -4,7 +4,7 @@ import com.github.rvesse.airline.annotations.Option; import java.util.ArrayList; import java.util.List; -import org.vitrivr.cineast.core.data.query.containers.TextQueryContainer; +import org.vitrivr.cineast.core.data.query.containers.TextQueryTermContainer; import org.vitrivr.cineast.core.features.AudioTranscriptionSearch; import org.vitrivr.cineast.core.features.DescriptionTextSearch; import org.vitrivr.cineast.core.features.OCRSearch; @@ -29,7 +29,7 @@ public class TextRetrievalCommand implements Runnable { public void run() { final ContinuousRetrievalLogic retrieval = new ContinuousRetrievalLogic(Config.sharedConfig().getDatabase()); System.out.println("Querying for text " + text); - TextQueryContainer qc = new TextQueryContainer(text); + TextQueryTermContainer qc = new TextQueryTermContainer(text); List retrievers = new ArrayList<>(); retrievers.add(new SubtitleFulltextSearch()); retrievers.add(new OCRSearch()); diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/evaluation/EvaluationRuntime.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/evaluation/EvaluationRuntime.java index fe2339829..0e9c739df 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/evaluation/EvaluationRuntime.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/evaluation/EvaluationRuntime.java @@ -8,7 +8,7 @@ import org.vitrivr.cineast.core.config.ReadableQueryConfig; import org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor; import org.vitrivr.cineast.core.data.entities.MediaSegmentDescriptor; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader; import org.vitrivr.cineast.core.db.dao.reader.MediaSegmentReader; @@ -130,7 +130,7 @@ public Triple call() throws EvaluationException, IOExce } /* Try to create a QueryContainer. If this fails, the file is skipped. */ - final QueryContainer container = converter.convert(path); + final AbstractQueryTermContainer container = converter.convert(path); if (container == null) { LOGGER.warn("Failed to convert the file {}. File is being skipped...", path.getFileName()); this.error += 1; diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/ContinuousQueryDispatcher.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/ContinuousQueryDispatcher.java index 37b541266..5bcb4d371 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/ContinuousQueryDispatcher.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/ContinuousQueryDispatcher.java @@ -8,7 +8,7 @@ import org.vitrivr.cineast.core.config.ReadableQueryConfig; import org.vitrivr.cineast.core.data.LimitedQueue; import org.vitrivr.cineast.core.data.Pair; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.BooleanSegmentScoreElement; import org.vitrivr.cineast.core.data.score.ObjectScoreElement; import org.vitrivr.cineast.core.data.score.ScoreElement; @@ -48,7 +48,7 @@ public class ContinuousQueryDispatcher { private final MediaSegmentReader mediaSegmentReader; private final double retrieverWeightSum; - public static List retrieve(QueryContainer query, + public static List retrieve(AbstractQueryTermContainer query, TObjectDoubleHashMap retrievers, RetrieverInitializer initializer, ReadableQueryConfig config, diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/RetrievalTask.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/RetrievalTask.java index 5364775ca..e154d3018 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/RetrievalTask.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/runtime/RetrievalTask.java @@ -6,7 +6,7 @@ import org.apache.logging.log4j.Logger; import org.vitrivr.cineast.core.config.ReadableQueryConfig; import org.vitrivr.cineast.core.data.Pair; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.ScoreElement; import org.vitrivr.cineast.core.features.retriever.Retriever; import org.vitrivr.cineast.standalone.monitoring.RetrievalTaskMonitor; @@ -14,20 +14,20 @@ public class RetrievalTask implements Callable>> { private final Retriever retriever; - private final QueryContainer query; + private final AbstractQueryTermContainer query; private final String segmentId; private static final Logger LOGGER = LogManager.getLogger(); private final ReadableQueryConfig config; - public RetrievalTask(Retriever retriever, QueryContainer query, ReadableQueryConfig qc) { + public RetrievalTask(Retriever retriever, AbstractQueryTermContainer query, ReadableQueryConfig qc) { this.retriever = retriever; this.query = query; this.config = qc; this.segmentId = null; } - public RetrievalTask(Retriever retriever, QueryContainer query) { + public RetrievalTask(Retriever retriever, AbstractQueryTermContainer query) { this(retriever, query, null); } @@ -74,7 +74,7 @@ public Retriever getRetriever() { return retriever; } - public QueryContainer getQuery() { + public AbstractQueryTermContainer getQuery() { return query; } diff --git a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/util/ContinuousRetrievalLogic.java b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/util/ContinuousRetrievalLogic.java index 8cdb65a34..7c51b3daf 100644 --- a/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/util/ContinuousRetrievalLogic.java +++ b/cineast-runtime/src/main/java/org/vitrivr/cineast/standalone/util/ContinuousRetrievalLogic.java @@ -5,7 +5,7 @@ import org.apache.logging.log4j.Logger; import org.vitrivr.cineast.core.config.DatabaseConfig; import org.vitrivr.cineast.core.config.ReadableQueryConfig; -import org.vitrivr.cineast.core.data.query.containers.QueryContainer; +import org.vitrivr.cineast.core.data.query.containers.AbstractQueryTermContainer; import org.vitrivr.cineast.core.data.score.SegmentScoreElement; import org.vitrivr.cineast.core.db.dao.reader.MediaSegmentReader; import org.vitrivr.cineast.core.features.retriever.Retriever; @@ -31,7 +31,7 @@ public ContinuousRetrievalLogic(DatabaseConfig config){ this.segmentReader = new MediaSegmentReader(this.config.getSelectorSupplier().get()); } - public List retrieve(QueryContainer qc, String category, + public List retrieve(AbstractQueryTermContainer qc, String category, ReadableQueryConfig config) { TObjectDoubleHashMap retrievers = Config.sharedConfig().getRetriever() .getRetrieversByCategory(category); @@ -74,7 +74,7 @@ public List retrieveByRetriever(String segmentId, Retriever return ContinuousQueryDispatcher.retrieve(segmentId, map, initializer, config, this.segmentReader); } - public List retrieveByRetriever(QueryContainer qc, + public List retrieveByRetriever(AbstractQueryTermContainer qc, Retriever retriever, ReadableQueryConfig config) { TObjectDoubleHashMap map = new TObjectDoubleHashMap<>(); @@ -82,7 +82,7 @@ public List retrieveByRetriever(QueryContainer qc, return ContinuousQueryDispatcher.retrieve(qc, map, initializer, config, this.segmentReader); } - public List retrieveByRetrieverName(QueryContainer qc, + public List retrieveByRetrieverName(AbstractQueryTermContainer qc, String retrieverName, ReadableQueryConfig config) { Optional retriever = Config.sharedConfig().getRetriever()