diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/DBSelector.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/DBSelector.java index 97c65a39f..e93476782 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/DBSelector.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/DBSelector.java @@ -237,20 +237,20 @@ default List> getMetadataByIdAndSpec(List> getMetadataBySpec(List> getMetadataByIdAndSpec(List ids, List spec, String idColName, String dbQueryID) { + if (ids.isEmpty()) { + LOGGER.trace("No ids specified, not fetching any metadata for query id {}", dbQueryID); + return new ArrayList<>(); + } final Query query = new Query(this.fqn).select("*", null).queryId(dbQueryID == null ? "md-id-spec" : dbQueryID); final Optional predicates = generateQueryFromMetadataSpec(spec); final Expression segmentIds = new Expression(idColName, "IN", ids.toArray()); @@ -434,11 +438,11 @@ public List> getMetadataByIdAndSpec(List generateQueryFromMetadataSpec(List spec) { final List> atomics = spec.stream().map(s -> { List singleSpecPredicates = new ArrayList<>(); - if (!s.domain.isEmpty() && !s.domain.equals("*")) { - singleSpecPredicates.add(new Expression(DOMAIN_COL_NAME, "=", s.domain)); + if (!s.domain().isEmpty() && !s.domain().equals("*")) { + singleSpecPredicates.add(new Expression(DOMAIN_COL_NAME, "=", s.domain())); } - if (!s.key.isEmpty() && !s.key.equals("*")) { - singleSpecPredicates.add(new Expression(KEY_COL_NAME, "=", s.key)); + if (!s.key().isEmpty() && !s.key().equals("*")) { + singleSpecPredicates.add(new Expression(KEY_COL_NAME, "=", s.key())); } return singleSpecPredicates.stream().reduce(And::new); }).collect(Collectors.toList()); diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/MetadataAccessSpecification.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/MetadataAccessSpecification.java index 4372cc342..6e32598fa 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/MetadataAccessSpecification.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/MetadataAccessSpecification.java @@ -1,22 +1,8 @@ package org.vitrivr.cineast.core.db.dao; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * Use '*' in either domain or key to retrieve simply all information. In general, if an empty specification list is provided, no metadata is returned. */ -public class MetadataAccessSpecification { - - public final MetadataType type; - public final String domain; - public final String key; +public record MetadataAccessSpecification(MetadataType type, String domain, String key) { - public MetadataAccessSpecification( - @JsonProperty("type") MetadataType type, - @JsonProperty("domain") String domain, - @JsonProperty("key") String key) { - this.type = type; - this.domain = domain; - this.key = key; - } } diff --git a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/reader/AbstractMetadataReader.java b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/reader/AbstractMetadataReader.java index bb5acb5af..c8b85f8b8 100644 --- a/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/reader/AbstractMetadataReader.java +++ b/cineast-core/src/main/java/org/vitrivr/cineast/core/db/dao/reader/AbstractMetadataReader.java @@ -144,14 +144,14 @@ public List sanitizeSpec(List el.type != MetadataType.OBJECT)) { + if (Objects.equals(this.tableName, MediaObjectMetadataDescriptor.ENTITY) && spec.stream().anyMatch(el -> el.type() != MetadataType.OBJECT)) { LOGGER.trace("provided spec-list includes non-object tuples, but this is an object reader. These will be ignored."); - spec = spec.stream().filter(el -> el.type == MetadataType.OBJECT).collect(Collectors.toList()); + spec = spec.stream().filter(el -> el.type() == MetadataType.OBJECT).collect(Collectors.toList()); } // filter non-segment specs if this is a segment reader - if (Objects.equals(this.tableName, MediaSegmentMetadataDescriptor.ENTITY) && spec.stream().anyMatch(el -> el.type != MetadataType.SEGMENT)) { + if (Objects.equals(this.tableName, MediaSegmentMetadataDescriptor.ENTITY) && spec.stream().anyMatch(el -> el.type() != MetadataType.SEGMENT)) { LOGGER.trace("provided spec-list includes non-segment tuples, but this is a segment reader. These will be ignored."); - spec = spec.stream().filter(el -> el.type == MetadataType.SEGMENT).collect(Collectors.toList()); + spec = spec.stream().filter(el -> el.type() == MetadataType.SEGMENT).collect(Collectors.toList()); } return spec; } 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 de76611d3..9af96cf8a 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 @@ -59,7 +59,7 @@ public Pair> call() throws Exception { long stop = System.currentTimeMillis(); RetrievalTaskMonitor.reportExecutionTime(retriever.getClass().getSimpleName(), stop - start); LOGGER.debug("{}.getSimilar() done in {} ms, {} results", retriever.getClass().getSimpleName(), stop - start, result.size()); - return LOGGER.traceExit(new Pair>(this, result)); + return new Pair<>(this, result); } private void nameThread() { diff --git a/cineast-runtime/src/main/resources/log4j2.xml b/cineast-runtime/src/main/resources/log4j2.xml index 1b8d26786..377714b43 100644 --- a/cineast-runtime/src/main/resources/log4j2.xml +++ b/cineast-runtime/src/main/resources/log4j2.xml @@ -1,34 +1,34 @@ + + [%d{MM-dd HH:mm:ss.SSS}][%-5level][%t] %C{1} - %msg%n + - logs/cineast.log logs/%d{yyyy-MM-dd-hh}-%i.log.zip - + + + + + + + + - - - - - - - - [%d{MM-dd HH:mm:ss.SSS}][%-5level][%t] %C{1} - %msg%n -