Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning no Metadata if Metadata Spec is Empty #271

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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