Skip to content

Commit

Permalink
Returning no Metadata if Metadata Spec is Empty (#271)
Browse files Browse the repository at this point in the history
* actually returning 0 results if spec is empty. This is backwards-compatible because all metadata is fetched if the provided spec is null


Former-commit-id: 06a7812
  • Loading branch information
silvanheller authored Mar 3, 2022
1 parent 58fe7bf commit 7597ee7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ allprojects {
group = 'org.vitrivr'

/* Our current version, on dev branch this should always be release+1-SNAPSHOT */
version = '3.8.2'
version = '3.8.3'

apply plugin: 'java-library'
apply plugin: 'maven-publish'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class TemporalQuery extends Query {
*/
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
*/
private final List<MetadataAccessSpecification> metadataAccessSpec;

@JsonCreator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Use '*' in either domain or key to retrieve simply all information
* 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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public List<R> findBySpec(List<String> ids, List<MetadataAccessSpecification> sp
LOGGER.warn("provided id-list {} or spec {} is null, returning empty list", ids, spec);
return new ArrayList<>();
}
if (spec.size() == 0) {
LOGGER.trace("Not returning any metadata since spec was an empty list.");
return new ArrayList<>();
}
StopWatch watch = StopWatch.createStarted();
ids = sanitizeIds(ids);
spec = sanitizeSpec(spec);
Expand All @@ -69,6 +73,14 @@ public List<R> findBySpec(List<String> ids, List<MetadataAccessSpecification> sp
}

public List<R> findBySpec(List<MetadataAccessSpecification> spec) {
if (spec == null) {
LOGGER.warn("Provided spec is null, returning empty list");
return new ArrayList<>();
}
if (spec.size() == 0) {
LOGGER.trace("Not returning any metadata since spec was an empty list.");
return new ArrayList<>();
}
StopWatch watch = StopWatch.createStarted();
spec = sanitizeSpec(spec);
List<Map<String, PrimitiveTypeProvider>> results = selector.getMetadataBySpec(spec);
Expand Down

0 comments on commit 7597ee7

Please sign in to comment.