Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Server_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Server_Extension
Commits
0e361d13
Commit
0e361d13
authored
4 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Prepare Server to handle request for compressed data.
parent
62c3c086
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/bdv/server/CellHandler.java
+45
-41
45 additions, 41 deletions
src/main/java/bdv/server/CellHandler.java
with
45 additions
and
41 deletions
src/main/java/bdv/server/CellHandler.java
+
45
−
41
View file @
0e361d13
...
@@ -3,14 +3,8 @@ package bdv.server;
...
@@ -3,14 +3,8 @@ package bdv.server;
import
azgracompress.cache.ICacheFile
;
import
azgracompress.cache.ICacheFile
;
import
azgracompress.cache.QuantizationCacheManager
;
import
azgracompress.cache.QuantizationCacheManager
;
import
azgracompress.compression.CompressionOptions
;
import
azgracompress.compression.CompressionOptions
;
import
azgracompress.compression.IImageCompressor
;
import
azgracompress.compression.ImageCompressor
;
import
azgracompress.compression.ImageCompressor
;
import
azgracompress.data.V3
;
import
azgracompress.data.V3i
;
import
azgracompress.io.FileInputData
;
import
azgracompress.io.FileInputData
;
import
azgracompress.io.FlatBufferInputData
;
import
azgracompress.io.InputData
;
import
azgracompress.quantization.vector.VQCodebook
;
import
bdv.BigDataViewer
;
import
bdv.BigDataViewer
;
import
bdv.cache.CacheHints
;
import
bdv.cache.CacheHints
;
import
bdv.cache.LoadingStrategy
;
import
bdv.cache.LoadingStrategy
;
...
@@ -149,6 +143,27 @@ public class CellHandler extends ContextHandler {
...
@@ -149,6 +143,27 @@ public class CellHandler extends ContextHandler {
}
}
}
}
private
short
[]
getCachedVolatileCellData
(
final
String
[]
parts
,
final
int
[]
cellDims
)
{
final
int
index
=
Integer
.
parseInt
(
parts
[
1
]);
final
int
timepoint
=
Integer
.
parseInt
(
parts
[
2
]);
final
int
setup
=
Integer
.
parseInt
(
parts
[
3
]);
final
int
level
=
Integer
.
parseInt
(
parts
[
4
]);
final
Key
key
=
new
VolatileGlobalCellCache
.
Key
(
timepoint
,
setup
,
level
,
index
);
VolatileCell
<?>
cell
=
cache
.
getLoadingVolatileCache
().
getIfPresent
(
key
,
cacheHints
);
final
long
[]
cellMin
=
new
long
[]{
Long
.
parseLong
(
parts
[
8
]),
Long
.
parseLong
(
parts
[
9
]),
Long
.
parseLong
(
parts
[
10
])};
if
(
cell
==
null
)
{
cell
=
cache
.
getLoadingVolatileCache
().
get
(
key
,
cacheHints
,
new
VolatileCellLoader
<>(
loader
,
timepoint
,
setup
,
level
,
cellDims
,
cellMin
));
}
//noinspection unchecked
return
((
VolatileCell
<
VolatileShortArray
>)
cell
).
getData
().
getCurrentStorageArray
();
}
@Override
@Override
public
void
doHandle
(
final
String
target
,
public
void
doHandle
(
final
String
target
,
final
Request
baseRequest
,
final
Request
baseRequest
,
...
@@ -171,63 +186,52 @@ public class CellHandler extends ContextHandler {
...
@@ -171,63 +186,52 @@ public class CellHandler extends ContextHandler {
respondWithString
(
baseRequest
,
response
,
"application/xml"
,
datasetXmlString
);
respondWithString
(
baseRequest
,
response
,
"application/xml"
,
datasetXmlString
);
return
;
return
;
}
}
final
String
[]
parts
=
cellString
.
split
(
"/"
);
final
String
[]
parts
=
cellString
.
split
(
"/"
);
if
(
parts
[
0
].
equals
(
"cell"
))
{
if
(
parts
[
0
].
equals
(
"cell"
))
{
final
int
index
=
Integer
.
parseInt
(
parts
[
1
]);
final
int
timepoint
=
Integer
.
parseInt
(
parts
[
2
]);
final
int
setup
=
Integer
.
parseInt
(
parts
[
3
]);
final
int
level
=
Integer
.
parseInt
(
parts
[
4
]);
final
Key
key
=
new
VolatileGlobalCellCache
.
Key
(
timepoint
,
setup
,
level
,
index
);
VolatileCell
<?>
cell
=
cache
.
getLoadingVolatileCache
().
getIfPresent
(
key
,
cacheHints
);
final
int
[]
cellDims
=
new
int
[]{
final
int
[]
cellDims
=
new
int
[]{
Integer
.
parseInt
(
parts
[
5
]),
Integer
.
parseInt
(
parts
[
5
]),
Integer
.
parseInt
(
parts
[
6
]),
Integer
.
parseInt
(
parts
[
6
]),
Integer
.
parseInt
(
parts
[
7
])};
Integer
.
parseInt
(
parts
[
7
])};
final
long
[]
cellMin
=
new
long
[]{
final
short
[]
data
=
getCachedVolatileCellData
(
parts
,
cellDims
);
Long
.
parseLong
(
parts
[
8
]),
Long
.
parseLong
(
parts
[
9
]),
final
OutputStream
responseStream
=
response
.
getOutputStream
();
Long
.
parseLong
(
parts
[
10
])};
if
(
cell
==
null
)
{
final
byte
[]
buf
=
new
byte
[
2
*
data
.
length
];
cell
=
cache
.
getLoadingVolatileCache
().
get
(
key
,
for
(
int
i
=
0
,
j
=
0
;
i
<
data
.
length
;
i
++)
{
cacheHints
,
final
short
s
=
data
[
i
];
new
VolatileCellLoader
<>(
loader
,
buf
[
j
++]
=
(
byte
)
((
s
>>
8
)
&
0xff
);
timepoint
,
buf
[
j
++]
=
(
byte
)
(
s
&
0xff
);
setup
,
level
,
cellDims
,
cellMin
));
}
}
response
.
setContentLength
(
buf
.
length
);
responseStream
.
write
(
buf
);
responseStream
.
close
();
@SuppressWarnings
(
"unchecked"
)
response
.
setContentType
(
"application/octet-stream"
);
short
[]
data
=
((
VolatileCell
<
VolatileShortArray
>)
cell
).
getData
().
getCurrentStorageArray
();
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
}
else
if
(
parts
[
0
].
equals
(
"cell_qcmp"
))
{
final
int
[]
cellDims
=
new
int
[]{
Integer
.
parseInt
(
parts
[
5
]),
Integer
.
parseInt
(
parts
[
6
]),
Integer
.
parseInt
(
parts
[
7
])};
final
short
[]
data
=
getCachedVolatileCellData
(
parts
,
cellDims
);
final
OutputStream
responseStream
=
response
.
getOutputStream
();
final
OutputStream
responseStream
=
response
.
getOutputStream
();
if
(
compressor
==
null
||
true
)
{
assert
(
compressor
!=
null
);
final
byte
[]
buf
=
new
byte
[
2
*
data
.
length
];
for
(
int
i
=
0
,
j
=
0
;
i
<
data
.
length
;
i
++)
{
final
int
contentLength
=
compressor
.
streamCompress
(
responseStream
);
final
short
s
=
data
[
i
];
buf
[
j
++]
=
(
byte
)
((
s
>>
8
)
&
0xff
);
buf
[
j
++]
=
(
byte
)
(
s
&
0xff
);
}
response
.
setContentLength
(
buf
.
length
);
responseStream
.
write
(
buf
);
}
else
{
// TODO(Moravec): Implement.
}
responseStream
.
close
();
responseStream
.
close
();
response
.
setContentLength
(
contentLength
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
baseRequest
.
setHandled
(
true
);
}
else
if
(
parts
[
0
].
equals
(
"init"
))
{
}
else
if
(
parts
[
0
].
equals
(
"init"
))
{
respondWithString
(
baseRequest
,
response
,
"application/json"
,
metadataJson
);
respondWithString
(
baseRequest
,
response
,
"application/json"
,
metadataJson
);
}
else
if
(
parts
[
0
].
equals
(
"init_qcmp"
))
{
}
else
if
(
parts
[
0
].
equals
(
"init_qcmp"
))
{
if
(
compressor
==
null
)
{
if
(
compressor
==
null
)
{
LOG
.
info
(
"QCMP initialization request was refused, QCMP compression is not enabled."
);
respondWithString
(
baseRequest
,
response
,
respondWithString
(
baseRequest
,
response
,
"text/plain"
,
"QCMP Compression wasn't enabled on BigDataViewer server."
,
"text/plain"
,
"QCMP Compression wasn't enabled on BigDataViewer server."
,
HttpServletResponse
.
SC_BAD_REQUEST
);
HttpServletResponse
.
SC_BAD_REQUEST
);
...
...
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