Skip to content

Commit

Permalink
Refs #11505 Use openLocal when possible
Browse files Browse the repository at this point in the history
`openLocal` performs far better than open, and we're able to use it when
loading multidimensional data sets in LoadNexusesProcessed, so let's.
  • Loading branch information
Harry Jeffery committed Apr 9, 2015
1 parent 6882c22 commit 408db3b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Code/Mantid/Framework/DataHandling/src/LoadNexusProcessed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ Workspace_sptr LoadNexusProcessed::doAccelleratedMultiPeriodLoading(
periodWorkspace->setX(i, tempMatrixWorkspace->refX(i));
}

NXEntry mtdEntry = root.openEntry(entryName);
const std::string groupName = "workspace";
if (!mtdEntry.containsGroup(groupName)) {
NXEntry mtdEntry(root, entryName);
mtdEntry.openLocal();

NXData wsEntry(mtdEntry, "workspace");
if (!wsEntry.openLocal()) {
std::stringstream buffer;
buffer
<< "Group entry " << p - 1
Expand All @@ -295,7 +297,6 @@ Workspace_sptr LoadNexusProcessed::doAccelleratedMultiPeriodLoading(
throw std::runtime_error(buffer.str());
}

NXData wsEntry = mtdEntry.openNXData(groupName);
if (wsEntry.isValid("frac_area")) {
std::stringstream buffer;
buffer << "Group entry " << p - 1 << " has fractional area present. Try "
Expand All @@ -304,8 +305,10 @@ Workspace_sptr LoadNexusProcessed::doAccelleratedMultiPeriodLoading(
throw std::runtime_error(buffer.str());
}

NXDataSetTyped<double> data = wsEntry.openDoubleData();
NXDataSetTyped<double> errors = wsEntry.openNXDouble("errors");
NXDataSetTyped<double> data(wsEntry, "values");
data.openLocal();
NXDataSetTyped<double> errors(wsEntry, "errors");
errors.openLocal();

const int nChannels = data.dim1();

Expand Down Expand Up @@ -360,6 +363,9 @@ Workspace_sptr LoadNexusProcessed::doAccelleratedMultiPeriodLoading(
g_log.information(e.what());
}

wsEntry.close();
mtdEntry.close();

const double fractionComplete = double(p - 1) / double(nWorkspaceEntries);
progress(fractionComplete, "Loading multiperiod entry");
return periodWorkspace;
Expand Down

0 comments on commit 408db3b

Please sign in to comment.