Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CDMABox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software Control System
Libraries
java
CDMABox
Commits
83a482ef
Commit
83a482ef
authored
Dec 20, 2019
by
Raphael GIRARDOT
Browse files
Options
Downloads
Patches
Plain Diff
The choice of allowing unsafe reading is not done in prepareForReading, but later.
parent
1372ef88
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fr/soleil/cdma/box/data/StackedData.java
+45
-4
45 additions, 4 deletions
src/main/java/fr/soleil/cdma/box/data/StackedData.java
src/main/java/fr/soleil/cdma/box/data/scan/ScanData.java
+50
-21
50 additions, 21 deletions
src/main/java/fr/soleil/cdma/box/data/scan/ScanData.java
with
95 additions
and
25 deletions
src/main/java/fr/soleil/cdma/box/data/StackedData.java
+
45
−
4
View file @
83a482ef
...
...
@@ -212,18 +212,21 @@ public abstract class StackedData extends ReferencedData {
/**
* 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
* read in a block. The reading process can be done on a single thread only or on a multiple threads.
* <p>
* Don't forget to call {@link #setUnsafeReadingEnabled(boolean)}, in order to say whether reading will be done in a
* single or in multiple thread(s).
* </p>
*
* @return The number of data that can be read in a block.
*/
public
int
prepareForReading
(
boolean
isSingleReadThreadOnly
)
{
public
int
prepareForReading
()
{
int
dataPerBlock
=
1
;
ICDMAReader
reader
=
getReader
();
if
(
reader
!=
null
)
{
IDataItem
item
=
reader
.
getDataItem
(
contextDataItem
);
if
(
item
!=
null
)
{
try
{
dataPerBlock
=
item
.
prepareForReading
(
getDataRank
()
,
isSingleReadThreadOnly
);
dataPerBlock
=
item
.
prepareForReading
(
getDataRank
());
}
catch
(
DataAccessException
e
)
{
Factory
.
getLogger
().
error
(
"Failed to prepare "
+
getDataName
()
+
" for multiple reading"
,
e
);
}
...
...
@@ -232,4 +235,42 @@ public abstract class StackedData extends ReferencedData {
return
dataPerBlock
;
}
/**
* Returns whether unsafe reading is enabled.
*
* @return Whether unsafe reading is enabled.
*/
public
boolean
isUnsafeReadingEnabled
()
{
boolean
unsafeReadingEnabled
=
false
;
ICDMAReader
reader
=
getReader
();
if
(
reader
!=
null
)
{
IDataItem
item
=
reader
.
getDataItem
(
contextDataItem
);
if
(
item
!=
null
)
{
unsafeReadingEnabled
=
item
.
isUnsafeReadingEnabled
();
}
}
return
unsafeReadingEnabled
;
}
/**
* Sets whether the reading process can be unsafe (i.e. no thread safe).
* <p>
* Unsafe reading might be more efficient than safe reading, at the cost of thread safety.
* </p>
* <p>
* Typically, if you read data in a single thread, you can use unsafe reading.
* </p>
*
* @param unsafeReadingEnabled Whether the reading process can be unsafe.
*/
public
void
setUnsafeReadingEnabled
(
boolean
unsafeReadingEnabled
)
{
ICDMAReader
reader
=
getReader
();
if
(
reader
!=
null
)
{
IDataItem
item
=
reader
.
getDataItem
(
contextDataItem
);
if
(
item
!=
null
)
{
item
.
setUnsafeReadingEnabled
(
unsafeReadingEnabled
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/fr/soleil/cdma/box/data/scan/ScanData.java
+
50
−
21
View file @
83a482ef
...
...
@@ -442,51 +442,80 @@ public class ScanData {
// }
/**
* Prepares everything necessary before
threaded
multiple images reading and returns the number of images that can
* Prepares everything necessary before multiple images reading 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
prepareImageStackFor
Multiple
Reading
()
{
return
images
==
null
?
0
:
images
.
prepareForReading
(
false
);
public
int
prepareImageStackForReading
()
{
return
images
==
null
?
0
:
images
.
prepareForReading
();
}
/**
* Prepares everything necessary before read
ing images on a single th
read and returns the number of
images
*
that
can be read in a block.
* Prepares everything necessary before
th
read
ed spectra
read
ing
and returns the number of
spectra that
* can be read in a block.
*
* @return The number of
image
s that can be read in a block.
* @return The number of
spectrum
s that can be read in a block.
*/
public
int
prepare
ImageStackForSingleThread
Reading
()
{
return
images
==
null
?
0
:
images
.
prepareForReading
(
true
);
public
int
prepare
SpectrumStackFor
Reading
()
{
return
spectrumStack
==
null
?
0
:
spectrumStack
.
prepareForReading
();
}
/**
* Prepares everything necessary before threaded multiple spectrums reading and returns the number of spectrums that
* can be read in a block.
* Finalizes what has to be finalized after multiple images reading.
*/
public
void
finalizeImageStackAfterReading
()
{
if
(
images
!=
null
)
{
images
.
finalizeReading
();
}
}
/**
* Finalizes what has to be finalized after multiple spectra reading.
*/
public
void
finalizeSpectrumStackAfterReading
()
{
if
(
spectrumStack
!=
null
)
{
spectrumStack
.
finalizeReading
();
}
}
/**
* Returns whether unsafe (i.e. not thread safe) image reading is enabled.
*
* @return
The number of spectrums that can be read in a block
.
* @return
A <code>boolean</code>
.
*/
public
int
prepareSpectrumStackFoMultipl
eReading
()
{
return
spectrumStack
==
null
?
0
:
spectrumStack
.
prepareForReading
(
false
);
public
boolean
isUnsafeImag
eReading
Enabled
()
{
return
images
==
null
?
false
:
images
.
isUnsafeReadingEnabled
(
);
}
/**
* Prepares everything necessary before reading spectrums on a single thread and returns the number of spectrums
* that can be read in a block.
* Returns whether unsafe (i.e. not thread safe) spectrum reading is enabled.
*
* @return
The number of spectrums that can be read in a block
.
* @return
A <code>boolean</code>
.
*/
public
int
prepareSpectrumStackForSingleThreadReading
()
{
return
spectrumStack
==
null
?
0
:
spectrumStack
.
prepareForReading
(
true
);
public
boolean
isUnsafeSpectrumReadingEnabled
()
{
return
spectrumStack
==
null
?
false
:
spectrumStack
.
isUnsafeReadingEnabled
(
);
}
/**
* Finalizes what has to be finalized after threaded multiple images reading
* Sets whether unsafe (i.e. not thread safe) image reading should be enabled.
*
* @param unsafeReadingEnabled Whether unsafe image reading should be enabled.
*/
public
void
finalizeImageStackAfterMultipleReading
(
)
{
public
void
setUnsafeImageReadingEnabled
(
boolean
unsafeReadingEnabled
)
{
if
(
images
!=
null
)
{
images
.
finalizeReading
();
images
.
setUnsafeReadingEnabled
(
unsafeReadingEnabled
);
}
}
/**
* Sets whether unsafe (i.e. not thread safe) spectrum reading should be enabled.
*
* @param unsafeReadingEnabled Whether unsafe spectrum reading should be enabled.
*/
public
void
setUnsafeSpectrumReadingEnabled
(
boolean
unsafeReadingEnabled
)
{
if
(
spectrumStack
!=
null
)
{
spectrumStack
.
setUnsafeReadingEnabled
(
unsafeReadingEnabled
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment