Skip to content

Commit

Permalink
Some progress addressing the performance on the very high file count …
Browse files Browse the repository at this point in the history
…prod. datasets. #9725
  • Loading branch information
landreev committed Jul 27, 2023
1 parent dcfe17e commit bcb93ba
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
55 changes: 34 additions & 21 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void setSelectedHostDataverse(Dataverse selectedHostDataverse) {

private Boolean hasRsyncScript = false;

private Boolean hasTabular = false;
/*private Boolean hasTabular = false;*/


/**
Expand All @@ -355,6 +355,12 @@ public void setSelectedHostDataverse(Dataverse selectedHostDataverse) {
* sometimes you want to know about the current version ("no tabular files
* currently"). Like all files, tabular files can be deleted.
*/
/**
* There doesn't seem to be an actual real life case where we need to know
* if this dataset "has ever had a tabular file" - for all practical purposes
* only the versionHasTabular appears to be in use. I'm going to remove the
* other boolean.
*/
private boolean versionHasTabular = false;

private boolean showIngestSuccess;
Expand Down Expand Up @@ -1904,9 +1910,9 @@ private String init(boolean initFull) {
logger.fine("retrieved version: id: " + workingVersion.getId() + ", state: " + this.workingVersion.getVersionState());

versionId = workingVersion.getId();
this.workingVersion = null;
this.dataset = null;

this.workingVersion = null;
this.dataset = null;

}

Expand All @@ -1915,7 +1921,6 @@ private String init(boolean initFull) {
if (versionId != null) {
this.workingVersion = datasetVersionService.findDeep(versionId);
dataset = workingVersion.getDataset();

}

if (workingVersion == null) {
Expand Down Expand Up @@ -2117,23 +2122,18 @@ private String init(boolean initFull) {
displayLockInfo(dataset);
displayPublishMessage();

// TODO: replace this loop, and the loop in the method that calculates
// the total "originals" size of the dataset with direct custom queries;
// then we'll be able to drop the lookup hint for DataTable from the
// findDeep() method for the version and further speed up the lookup
// a little bit.
for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
if (fmd.getDataFile().isTabularData()) {
versionHasTabular = true;
break;
}
}
for(DataFile f : dataset.getFiles()) {
// TODO: Consider uncommenting this optimization.
// if (versionHasTabular) {
// hasTabular = true;
// break;
// }
if(f.isTabularData()) {
hasTabular = true;
break;
}
}

//Show ingest success message if refresh forces a page reload after ingest success
//This is needed to display the explore buttons (the fileDownloadHelper needs to be reloaded via page
if (showIngestSuccess) {
Expand Down Expand Up @@ -2417,9 +2417,9 @@ private DefaultTreeNode createFileTreeNode(FileMetadata fileMetadata, TreeNode p
return fileNode;
}

public boolean isHasTabular() {
/*public boolean isHasTabular() {
return hasTabular;
}
}*/

public boolean isVersionHasTabular() {
return versionHasTabular;
Expand Down Expand Up @@ -3057,19 +3057,32 @@ public void setTooLargeToDownload(boolean tooLargeToDownload) {
this.tooLargeToDownload = tooLargeToDownload;
}

private Long sizeOfDatasetArchival = null;
private Long sizeOfDatasetOriginal = null;


public Long getSizeOfDatasetNumeric() {
if (this.hasTabular){
if (this.versionHasTabular){
return Math.min(getSizeOfDatasetOrigNumeric(), getSizeOfDatasetArchivalNumeric());
}
return getSizeOfDatasetOrigNumeric();
}

public Long getSizeOfDatasetOrigNumeric() {
return DatasetUtil.getDownloadSizeNumeric(workingVersion, true);
if (versionHasTabular) {
if (sizeOfDatasetOriginal == null) {
sizeOfDatasetOriginal = DatasetUtil.getDownloadSizeNumeric(workingVersion, true);
}
return sizeOfDatasetOriginal;
}
return getSizeOfDatasetArchivalNumeric();
}

public Long getSizeOfDatasetArchivalNumeric() {
return DatasetUtil.getDownloadSizeNumeric(workingVersion, false);
if (sizeOfDatasetArchival == null) {
sizeOfDatasetArchival = DatasetUtil.getDownloadSizeNumeric(workingVersion, false);
}
return sizeOfDatasetArchival;
}

public String getSizeOfSelectedAsString(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,11 @@ public DatasetVersion findDeep(Object pk) {
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.ingestRequest")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.thumbnailForDataset")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.dataTables")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.auxiliaryFiles")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.ingestReports")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.dataFileTags")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.fileCategories")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.embargo")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.fileAccessRequests")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.datasetVersion")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.releaseUser")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.creator")
.setHint("eclipselink.left-join-fetch", "o.fileMetadatas.dataFile.roleAssignments")
.getSingleResult();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/filesFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
<div jsf:id="downloadButtonBlockNormal" class="btn-group"
jsf:rendered="#{(!(empty DatasetPage.workingVersion.fileMetadatas)
and DatasetPage.workingVersion.fileMetadatas.size() > 1) and DatasetPage.downloadButtonAvailable
and !DatasetPage.isHasTabular()}">
and !DatasetPage.isVersionHasTabular()}">
<p:commandLink
styleClass="btn btn-default btn-download"
disabled="#{false and DatasetPage.lockedFromDownload}"
Expand All @@ -451,7 +451,7 @@
<div jsf:id="downloadButtonBlockTabular" class="btn-group"
jsf:rendered="#{(!(empty DatasetPage.workingVersion.fileMetadatas)
and DatasetPage.workingVersion.fileMetadatas.size() > 1) and DatasetPage.downloadButtonAvailable
and DatasetPage.isHasTabular()}">
and DatasetPage.isVersionHasTabular()}">
<button type="button" class="btn btn-default btn-download dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-download-alt"/> #{bundle.download} <span class="caret"></span>
</button>
Expand Down

0 comments on commit bcb93ba

Please sign in to comment.