Skip to content
Snippets Groups Projects
Commit 8b428e98 authored by Sahbi Thairi's avatar Sahbi Thairi
Browse files

JAVAAPI-562 Less open/close of dataspaces in one hdfDataItem

parent fc87196e
No related branches found
No related tags found
No related merge requests found
......@@ -57,15 +57,15 @@ public abstract class ReferencedData {
protected abstract String getDataName();
/**
* Finalizes what has to be finalized after threaded multiple data reading
* Finalizes what has to be finalized after big data reading
*/
public void finalizeAfterMultiReading() {
public void finalizeReading() {
ICDMAReader reader = getReader();
if (reader != null) {
IDataItem item = reader.getDataItem(contextDataItem);
if (item != null) {
try {
item.finalizeAfterMultiReading();
item.finalizeReading();
} catch (DataAccessException e) {
Factory.getLogger().error("Failed to finalize " + getDataName() + " after multiple reading", e);
}
......
......@@ -211,19 +211,19 @@ public abstract class StackedData extends ReferencedData {
}
/**
* Prepares everything necessary before threaded multiple data reading and returns the number of data that can be
* read in a block.
* Prepares everything necessary before data reading and returns the number of data that can be
* read in a block. The reading process can be done on a single thread only or on a multiple threads
*
* @return The number of data that can be read in a block.
*/
public int prepareForMultiReading() {
public int prepareForReading(boolean isSingleReadThreadOnly) {
int dataPerBlock = 1;
ICDMAReader reader = getReader();
if (reader != null) {
IDataItem item = reader.getDataItem(contextDataItem);
if (item != null) {
try {
dataPerBlock = item.prepareForMultiReading(getDataRank());
dataPerBlock = item.prepareForReading(getDataRank(), isSingleReadThreadOnly);
} catch (DataAccessException e) {
Factory.getLogger().error("Failed to prepare " + getDataName() + " for multiple reading", e);
}
......
......@@ -448,8 +448,37 @@ public class ScanData {
* @return The number of images that can be read in a block.
*/
public int prepareImageStackForMultipleReading() {
return images == null ? 0 : images.prepareForMultiReading();
return images == null ? 0 : images.prepareForReading(false);
}
/**
* Prepares everything necessary before reading images on a single thread and returns the number of images
* that can be read in a block.
*
* @return The number of images that can be read in a block.
*/
public int prepareImageStackForSingleThreadReading() {
return images == null ? 0 : images.prepareForReading(true);
}
/**
* Prepares everything necessary before threaded multiple spectrums reading and returns the number of spectrums that
* can be read in a block.
*
* @return The number of spectrums that can be read in a block.
*/
public int prepareSpectrumStackFoMultipleReading() {
return spectrumStack == null ? 0 : spectrumStack.prepareForReading(false);
}
/**
* Prepares everything necessary before reading spectrums on a single thread and returns the number of spectrums
* that can be read in a block.
*
* @return The number of spectrums that can be read in a block.
*/
public int prepareSpectrumStackForSingleThreadReading() {
return spectrumStack == null ? 0 : spectrumStack.prepareForReading(true);
}
/**
......@@ -457,7 +486,7 @@ public class ScanData {
*/
public void finalizeImageStackAfterMultipleReading() {
if (images != null) {
images.finalizeAfterMultiReading();
images.finalizeReading();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment