Skip to content

Commit

Permalink
Better search for dependents
Browse files Browse the repository at this point in the history
  • Loading branch information
gmagnu committed Jul 31, 2024
1 parent 94c0c9a commit fa7bf10
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
4 changes: 3 additions & 1 deletion model/src/main/java/org/gorpipe/gor/driver/DataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ default String getAccessValidationPath() {
/**
* Get date type - e.g. BAM, GOR .. for files.
*/
DataType getDataType();
default DataType getDataType() {
return DataType.fromFileName(getName());
};

/**
* Does this source support writing
Expand Down
40 changes: 23 additions & 17 deletions model/src/main/java/org/gorpipe/gor/driver/meta/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,36 @@
* Created by villi on 23/08/15.
*/
public enum DataType {
GOR(VARIANTS, ".gor"),
GORZ(VARIANTS, ".gorz"),
GORGZ(VARIANTS, ".gor.gz"),
GOR(VARIANTS, ".gor", true),
GORZ(VARIANTS, ".gorz", true),
GORGZ(VARIANTS, ".gor.gz", true),
PARQUET(VARIANTS, ".parquet"),
GORI(INDEX, ".gori"),
SAM(VARIANTS, ".sam"),
BAM(VARIANTS, ".bam"),
BGEN(VARIANTS, ".bgen"),
BAM(VARIANTS, ".bam", true),
BAI(INDEX, ".bai"),
BGEN(VARIANTS, ".bgen", true),
BGI(INDEX, ".bgi"),
VCF(VARIANTS, ".vcf"),
GVCF(VARIANTS, ".gvcf"),
GVCF(VARIANTS, ".gvcf", true),
BCF(VARIANTS, ".bcf"),
VCFGZ(VARIANTS, ".vcf.gz"),
VCFBGZ(VARIANTS, ".vcf.bgz"),
GVCFGZ(VARIANTS, ".gvcf.gz"),
BAI(INDEX, ".bai"),
VCFGZ(VARIANTS, ".vcf.gz", true),
VCFBGZ(VARIANTS, ".vcf.bgz", true),
GVCFGZ(VARIANTS, ".gvcf.gz", true),
TBI(INDEX, ".tbi"),
CSI(INDEX, ".csi"),
GORD(TABLE, ".gord"),
GORT(TABLE, ".gort"),
GORP(TABLE, ".gorp"),
GORD(TABLE, ".gord", false), // Note: gord is not handled by the driver framework, so must set dpendents as false (even though it has meta).
GORT(TABLE, ".gort", true),
GORP(TABLE, ".gorp", true),
GORQ(REPORT, ".gorq"),
LINK(REFERENCE, ".link"),
LOCAL_LINK(REFERENCE, ".link.local"),
CRAM(VARIANTS, ".cram"),
CRAM(VARIANTS, ".cram", true),
CRAI(INDEX, ".crai"),
SPEC(VARIANTS, ".spec"),
NOR(VARIANTS, ".nor"),
NORZ(VARIANTS, ".norz"),
NORD(TABLE, ".nord"),
NOR(VARIANTS, ".nor", true),
NORZ(VARIANTS, ".norz", true),
NORD(TABLE, ".nord", true),
CSV(VARIANTS, ".csv"),
CSVGZ(VARIANTS, ".csv.gz"),
TSV(VARIANTS, ".tsv"),
Expand All @@ -78,10 +78,16 @@ public enum DataType {

public final String suffix;
public final FileNature nature;
public final boolean hasDependents;

DataType(FileNature nature, String suffix) {
this(nature, suffix, false);
}

DataType(FileNature nature, String suffix, boolean hasDependents) {
this.nature = nature;
this.suffix = suffix;
this.hasDependents = hasDependents;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,10 @@ private Stream<DataSource[]> getDependentDestStream(String source, String dest,
}

private List<DataSource> getValidatedDependents(DataSource source) throws IOException {
if (source.getDataType() != null && !source.getDataType().hasDependents) {
return List.of();
}

List<DataSource> dependents = new ArrayList<>();
DataSource metaSource = resolveUrl(source.getName() + DataType.META.suffix, true);
if (metaSource != null && metaSource.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/data
Submodule data updated from a195f5 to 3a1d60

0 comments on commit fa7bf10

Please sign in to comment.