Skip to content

Commit

Permalink
[#437] Filter out duplicate entries over multiple result sets
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonvansparrentak authored and korydraughn committed Aug 13, 2024
1 parent 6d47204 commit f401e50
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ List<CollectionAndDataObjectListingEntry> listDataObjectsUnderPath(final ObjStat
files = listUnderPathWhenSpecColl(objStat, effectiveAbsolutePath, false, partialStartIndex);
} else {

files = listDataObjectsUnderPathViaGenQuery(objStat, partialStartIndex, effectiveAbsolutePath);
files = listDataObjectsUnderPathViaGenQuery(objStat, partialStartIndex, effectiveAbsolutePath, "");
}

return files;
Expand Down Expand Up @@ -825,21 +825,24 @@ List<CollectionAndDataObjectListingEntry> listAllDataObjectsUnderPath(final ObjS
boolean complete = false;
int myOffset = partialStartIndex;

String lastPath = "";
while (!complete) {

if (objStat.getSpecColType() == SpecColType.STRUCT_FILE_COLL
|| objStat.getSpecColType() == SpecColType.MOUNTED_COLL) {
entries.addAll(listUnderPathWhenSpecColl(objStat, effectiveAbsolutePath, false, myOffset));
} else {
entries.addAll(listDataObjectsUnderPathViaGenQuery(objStat, myOffset, effectiveAbsolutePath));
entries.addAll(listDataObjectsUnderPathViaGenQuery(objStat, myOffset, effectiveAbsolutePath, lastPath));
}

if (entries.isEmpty()) {
complete = true;
} else if (entries.get(entries.size() - 1).isLastResult()) {
complete = true;
} else {
myOffset = entries.get(entries.size() - 1).getCount();
CollectionAndDataObjectListingEntry lastEntry = entries.get(entries.size() - 1);
lastPath = lastEntry.getParentPath() + "/" + lastEntry.getPathOrName();
myOffset = lastEntry.getCount();
}
}

Expand All @@ -848,7 +851,7 @@ List<CollectionAndDataObjectListingEntry> listAllDataObjectsUnderPath(final ObjS
}

private List<CollectionAndDataObjectListingEntry> listDataObjectsUnderPathViaGenQuery(final ObjStat objStat,
final int partialStartIndex, final String effectiveAbsolutePath) throws JargonException {
final int partialStartIndex, final String effectiveAbsolutePath, String lastPath) throws JargonException {
IRODSGenQueryBuilder builder = new IRODSGenQueryBuilder(true, false, true, null);

IRODSFileSystemAOHelper.buildQueryListAllDataObjectsWithSizeAndDateInfo(effectiveAbsolutePath, builder);
Expand All @@ -867,7 +870,6 @@ private List<CollectionAndDataObjectListingEntry> listDataObjectsUnderPathViaGen
* the query that gives the necessary data will cause duplication when there are
* replicas, so discard duplicates. This is the nature of GenQuery.
*/
String lastPath = "";
String currentPath = "";
CollectionAndDataObjectListingEntry entry;
for (IRODSQueryResultRow row : resultSet.getResults()) {
Expand Down

0 comments on commit f401e50

Please sign in to comment.